rouge 4.3.0 → 4.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rouge/demos/mojo +10 -0
- data/lib/rouge/demos/p4 +99 -0
- data/lib/rouge/lexers/docker.rb +2 -2
- data/lib/rouge/lexers/make.rb +4 -0
- data/lib/rouge/lexers/mojo.rb +35 -0
- data/lib/rouge/lexers/p4.rb +81 -0
- data/lib/rouge/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0edd954634b90e384ace60c0f23cc8eb60b53eb25600105b2e235e74edf38008
|
4
|
+
data.tar.gz: 8b3c50c71ca796236f2326a60ff0d84e5b2076fe6314a48c5393d1419e448c9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 671d9550dc89a8aef885d3efe1fd31f1cabeabaff551574f6cf9aac15fae73b03f2483ae3436c267685175500dc728d5dc8326e183d6bca0fa79b4fdf8eb712f
|
7
|
+
data.tar.gz: 4ee512eb60833a549e3ce3e3234857f4c547b143eb563dce090db626769f99a2386a8dbb06ca4e0fcc54fa8c4d3931fb8c2e904200b408d6b8ad3699da4f841c
|
data/lib/rouge/demos/p4
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
#include <core.p4>
|
2
|
+
#include <v1model.p4>
|
3
|
+
|
4
|
+
const bit<16> TYPE_IPV4 = 0x800;
|
5
|
+
typedef bit<9> egressSpec_t;
|
6
|
+
typedef bit<48> macAddr_t;
|
7
|
+
typedef bit<32> ip4Addr_t;
|
8
|
+
|
9
|
+
header ethernet_t {
|
10
|
+
macAddr_t dstAddr;
|
11
|
+
macAddr_t srcAddr;
|
12
|
+
bit<16> etherType;
|
13
|
+
}
|
14
|
+
|
15
|
+
header ipv4_t {
|
16
|
+
bit<4> version;
|
17
|
+
bit<4> ihl;
|
18
|
+
bit<8> diffserv;
|
19
|
+
bit<16> totalLen;
|
20
|
+
bit<16> identification;
|
21
|
+
bit<3> flags;
|
22
|
+
bit<13> fragOffset;
|
23
|
+
bit<8> ttl;
|
24
|
+
bit<8> protocol;
|
25
|
+
bit<16> hdrChecksum;
|
26
|
+
ip4Addr_t srcAddr;
|
27
|
+
ip4Addr_t dstAddr;
|
28
|
+
}
|
29
|
+
|
30
|
+
struct metadata { /* empty */ }
|
31
|
+
|
32
|
+
struct headers {
|
33
|
+
ethernet_t ethernet;
|
34
|
+
ipv4_t ipv4;
|
35
|
+
}
|
36
|
+
|
37
|
+
parser MyParser(packet_in packet,
|
38
|
+
out headers hdr,
|
39
|
+
inout metadata meta,
|
40
|
+
inout standard_metadata_t standard_metadata) {
|
41
|
+
|
42
|
+
state start { transition parse_ethernet; }
|
43
|
+
|
44
|
+
state parse_ethernet {
|
45
|
+
packet.extract(hdr.ethernet);
|
46
|
+
transition select(hdr.ethernet.etherType) {
|
47
|
+
TYPE_IPV4: parse_ipv4;
|
48
|
+
default: accept;
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
52
|
+
state parse_ipv4 {
|
53
|
+
packet.extract(hdr.ipv4);
|
54
|
+
transition accept;
|
55
|
+
}
|
56
|
+
|
57
|
+
}
|
58
|
+
|
59
|
+
control MyIngress(inout headers hdr,
|
60
|
+
inout metadata meta,
|
61
|
+
inout standard_metadata_t standard_metadata) {
|
62
|
+
action drop() {
|
63
|
+
mark_to_drop(standard_metadata);
|
64
|
+
}
|
65
|
+
|
66
|
+
action ipv4_forward(macAddr_t dstAddr, egressSpec_t port) {
|
67
|
+
standard_metadata.egress_spec = port;
|
68
|
+
hdr.ethernet.srcAddr = hdr.ethernet.dstAddr;
|
69
|
+
hdr.ethernet.dstAddr = dstAddr;
|
70
|
+
hdr.ipv4.ttl = hdr.ipv4.ttl - 1;
|
71
|
+
}
|
72
|
+
|
73
|
+
table ipv4_lpm {
|
74
|
+
key = { hdr.ipv4.dstAddr: lpm; }
|
75
|
+
actions = { ipv4_forward; drop; NoAction; }
|
76
|
+
size = 1024;
|
77
|
+
default_action = drop();
|
78
|
+
}
|
79
|
+
|
80
|
+
apply {
|
81
|
+
if (hdr.ipv4.isValid()) {
|
82
|
+
ipv4_lpm.apply();
|
83
|
+
}
|
84
|
+
}
|
85
|
+
}
|
86
|
+
|
87
|
+
|
88
|
+
control MyDeparser(packet_out packet, in headers hdr) {
|
89
|
+
apply {
|
90
|
+
packet.emit(hdr.ethernet);
|
91
|
+
packet.emit(hdr.ipv4);
|
92
|
+
}
|
93
|
+
}
|
94
|
+
|
95
|
+
V1Switch(
|
96
|
+
MyParser(),
|
97
|
+
MyIngress(),
|
98
|
+
MyDeparser()
|
99
|
+
) main;
|
data/lib/rouge/lexers/docker.rb
CHANGED
@@ -7,8 +7,8 @@ module Rouge
|
|
7
7
|
title "Docker"
|
8
8
|
desc "Dockerfile syntax"
|
9
9
|
tag 'docker'
|
10
|
-
aliases 'dockerfile', 'Dockerfile'
|
11
|
-
filenames 'Dockerfile', '*.Dockerfile', '*.docker'
|
10
|
+
aliases 'dockerfile', 'Dockerfile', 'containerfile', 'Containerfile'
|
11
|
+
filenames 'Dockerfile', '*.Dockerfile', '*.docker', 'Containerfile', '*.Containerfile'
|
12
12
|
mimetypes 'text/x-dockerfile-config'
|
13
13
|
|
14
14
|
KEYWORDS = %w(
|
data/lib/rouge/lexers/make.rb
CHANGED
@@ -40,6 +40,10 @@ module Rouge
|
|
40
40
|
groups Keyword, Text, Name::Variable
|
41
41
|
end
|
42
42
|
|
43
|
+
rule %r/(else\b)([\t ]+)((?:ifn?def|ifn?eq)\b)([\t ]+)([^#\n]+)/ do
|
44
|
+
groups Keyword, Text, Keyword, Text, Name::Variable
|
45
|
+
end
|
46
|
+
|
43
47
|
rule %r/(?:else|endif|endef|endfor)[\t ]*(?=[#\n])/, Keyword
|
44
48
|
|
45
49
|
rule %r/(export)([\t ]+)(?=[\w\${}()\t -]+\n)/ do
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# -*- coding: utf-8 -*- #
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Rouge
|
5
|
+
module Lexers
|
6
|
+
load_lexer 'python.rb'
|
7
|
+
|
8
|
+
class Mojo < Python
|
9
|
+
title "Mojo"
|
10
|
+
desc "The Mojo programming language (modular.com)"
|
11
|
+
tag 'mojo'
|
12
|
+
aliases 'mojo'
|
13
|
+
filenames '*.mojo', '*.🔥'
|
14
|
+
mimetypes 'text/x-mojo', 'application/x-mojo'
|
15
|
+
|
16
|
+
def self.detect?(text)
|
17
|
+
return true if text.shebang?(/mojow?(?:[23](?:\.\d+)?)?/)
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.keywords
|
21
|
+
@keywords ||= super + %w(
|
22
|
+
fn self alias inout borrowed owned ref var
|
23
|
+
struct trait raises with in match case
|
24
|
+
)
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.builtins
|
28
|
+
@builtins ||= super + %w(
|
29
|
+
__mlir_attr __mlir_type __mlir_op parameter alwaysinline
|
30
|
+
register_passable
|
31
|
+
)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# -*- coding: utf-8 -*- #
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Rouge
|
5
|
+
module Lexers
|
6
|
+
class P4 < RegexLexer
|
7
|
+
tag 'p4'
|
8
|
+
title 'P4'
|
9
|
+
desc 'The P4 programming language'
|
10
|
+
filenames '*.p4'
|
11
|
+
mimetypes 'text/x-p4'
|
12
|
+
|
13
|
+
def self.keywords
|
14
|
+
@keywords ||= %w(
|
15
|
+
abstract action actions apply const default default_action else enum
|
16
|
+
entries extern exit if in inout key list out package packet_in
|
17
|
+
packet_out return size select switch this transition tuple type
|
18
|
+
typedef
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.operators
|
23
|
+
@operators ||= %w(
|
24
|
+
\|\+\| \|-\| \? \& \&\&\& < > << >> \* \| ~ \^ - \+ /
|
25
|
+
\# \. = != <= >= \+\+
|
26
|
+
)
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.decls
|
30
|
+
@decls ||= %w(
|
31
|
+
control header header_union parser state struct table
|
32
|
+
value_set
|
33
|
+
)
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.builtins
|
37
|
+
@builtins ||= %w(
|
38
|
+
bit bool error extract int isValid setValid setInvalid match_kind
|
39
|
+
string varbit verify void
|
40
|
+
)
|
41
|
+
end
|
42
|
+
|
43
|
+
state :whitespace do
|
44
|
+
rule %r/\s+/m, Text
|
45
|
+
end
|
46
|
+
|
47
|
+
state :comment do
|
48
|
+
rule %r((//).*$\n?), Comment::Single
|
49
|
+
rule %r/\/\*(?:(?!\*\/).)*\*\//m, Comment::Multiline
|
50
|
+
end
|
51
|
+
|
52
|
+
state :number do
|
53
|
+
rule %r/([0-9]+[sw])?0[oO][0-7_]+/, Num
|
54
|
+
rule %r/([0-9]+[sw])?0[xX][0-9a-fA-F_]+/, Num
|
55
|
+
rule %r/([0-9]+[sw])?0[bB][01_]+/, Num
|
56
|
+
rule %r/([0-9]+[sw])?0[dD][0-9_]+/, Num
|
57
|
+
rule %r/([0-9]+[sw])?[0-9_]+/, Num
|
58
|
+
end
|
59
|
+
|
60
|
+
id = /[\p{XID_Start}_]\p{XID_Continue}*/
|
61
|
+
string_element = /\\"|[^"]/x
|
62
|
+
|
63
|
+
state :root do
|
64
|
+
mixin :whitespace
|
65
|
+
mixin :comment
|
66
|
+
|
67
|
+
rule %r/#\s*#{id}/, Comment::Preproc
|
68
|
+
rule %r/\b(?:#{P4.keywords.join('|')})\b/, Keyword
|
69
|
+
rule %r/\b(?:#{P4.decls.join('|')})\b/, Keyword::Declaration
|
70
|
+
rule %r/\b(?:#{P4.builtins.join('|')})\b/, Name::Builtin
|
71
|
+
rule %r/\b#{id}_[th]\b/x, Name::Class
|
72
|
+
rule %r/(?:#{P4.operators.join('|')})/x, Operator
|
73
|
+
rule %r/[(){}\[\]<>,:;\.]/, Punctuation
|
74
|
+
mixin :number
|
75
|
+
rule %r/@#{id}/x, Name::Label
|
76
|
+
rule %r/#{id}/x, Text
|
77
|
+
rule %r/"(?: #{string_element} )*"/x, Str::String
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
data/lib/rouge/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rouge
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeanine Adkisson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Rouge aims to a be a simple, easy-to-extend drop-in replacement for pygments.
|
14
14
|
email:
|
@@ -149,6 +149,7 @@ files:
|
|
149
149
|
- lib/rouge/demos/matlab
|
150
150
|
- lib/rouge/demos/meson
|
151
151
|
- lib/rouge/demos/minizinc
|
152
|
+
- lib/rouge/demos/mojo
|
152
153
|
- lib/rouge/demos/moonscript
|
153
154
|
- lib/rouge/demos/mosel
|
154
155
|
- lib/rouge/demos/msgtrans
|
@@ -165,6 +166,7 @@ files:
|
|
165
166
|
- lib/rouge/demos/ocl
|
166
167
|
- lib/rouge/demos/openedge
|
167
168
|
- lib/rouge/demos/opentype_feature_file
|
169
|
+
- lib/rouge/demos/p4
|
168
170
|
- lib/rouge/demos/pascal
|
169
171
|
- lib/rouge/demos/perl
|
170
172
|
- lib/rouge/demos/php
|
@@ -400,6 +402,7 @@ files:
|
|
400
402
|
- lib/rouge/lexers/matlab/keywords.rb
|
401
403
|
- lib/rouge/lexers/meson.rb
|
402
404
|
- lib/rouge/lexers/minizinc.rb
|
405
|
+
- lib/rouge/lexers/mojo.rb
|
403
406
|
- lib/rouge/lexers/moonscript.rb
|
404
407
|
- lib/rouge/lexers/mosel.rb
|
405
408
|
- lib/rouge/lexers/msgtrans.rb
|
@@ -418,6 +421,7 @@ files:
|
|
418
421
|
- lib/rouge/lexers/ocl.rb
|
419
422
|
- lib/rouge/lexers/openedge.rb
|
420
423
|
- lib/rouge/lexers/opentype_feature_file.rb
|
424
|
+
- lib/rouge/lexers/p4.rb
|
421
425
|
- lib/rouge/lexers/pascal.rb
|
422
426
|
- lib/rouge/lexers/perl.rb
|
423
427
|
- lib/rouge/lexers/php.rb
|