rouge 4.1.3 → 4.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +10 -7
- data/LICENSE +2 -1
- data/lib/rouge/cli.rb +4 -5
- data/lib/rouge/demos/bicep +10 -0
- data/lib/rouge/demos/cobol +103 -0
- data/lib/rouge/demos/codeowners +6 -0
- data/lib/rouge/demos/gjs +23 -0
- data/lib/rouge/demos/gts +36 -0
- data/lib/rouge/demos/iecst +21 -0
- data/lib/rouge/demos/json5 +12 -0
- data/lib/rouge/demos/mojo +10 -0
- data/lib/rouge/demos/p4 +99 -0
- data/lib/rouge/demos/svelte +29 -0
- data/lib/rouge/formatters/html_legacy.rb +0 -3
- data/lib/rouge/guessers/disambiguation.rb +24 -3
- data/lib/rouge/lexer.rb +8 -6
- data/lib/rouge/lexers/ada.rb +5 -5
- data/lib/rouge/lexers/bicep.rb +111 -0
- data/lib/rouge/lexers/bpf.rb +10 -10
- data/lib/rouge/lexers/brainfuck.rb +1 -0
- data/lib/rouge/lexers/clean.rb +4 -4
- data/lib/rouge/lexers/cobol.rb +137 -0
- data/lib/rouge/lexers/codeowners.rb +30 -0
- data/lib/rouge/lexers/cpp.rb +5 -4
- data/lib/rouge/lexers/crystal.rb +17 -17
- data/lib/rouge/lexers/csharp.rb +37 -34
- data/lib/rouge/lexers/css.rb +192 -150
- data/lib/rouge/lexers/dart.rb +1 -1
- data/lib/rouge/lexers/docker.rb +2 -2
- data/lib/rouge/lexers/ecl.rb +2 -2
- data/lib/rouge/lexers/eiffel.rb +1 -1
- data/lib/rouge/lexers/elixir.rb +5 -1
- data/lib/rouge/lexers/gdscript.rb +4 -4
- data/lib/rouge/lexers/ghc_cmm.rb +3 -3
- data/lib/rouge/lexers/gjs.rb +39 -0
- data/lib/rouge/lexers/go.rb +7 -5
- data/lib/rouge/lexers/groovy.rb +6 -4
- data/lib/rouge/lexers/gts.rb +39 -0
- data/lib/rouge/lexers/hcl.rb +1 -0
- data/lib/rouge/lexers/html.rb +1 -1
- data/lib/rouge/lexers/iecst.rb +92 -0
- data/lib/rouge/lexers/ini.rb +7 -5
- data/lib/rouge/lexers/java.rb +1 -1
- data/lib/rouge/lexers/javascript.rb +4 -4
- data/lib/rouge/lexers/json5.rb +74 -0
- data/lib/rouge/lexers/julia.rb +3 -2
- data/lib/rouge/lexers/kotlin.rb +1 -1
- data/lib/rouge/lexers/lua.rb +24 -3
- data/lib/rouge/lexers/make.rb +5 -1
- data/lib/rouge/lexers/markdown.rb +2 -1
- data/lib/rouge/lexers/mathematica.rb +1 -1
- data/lib/rouge/lexers/meson.rb +0 -1
- data/lib/rouge/lexers/mojo.rb +35 -0
- data/lib/rouge/lexers/nasm.rb +5 -4
- data/lib/rouge/lexers/nginx.rb +1 -0
- data/lib/rouge/lexers/objective_c/common.rb +0 -2
- data/lib/rouge/lexers/objective_c.rb +1 -1
- data/lib/rouge/lexers/ocl.rb +2 -2
- data/lib/rouge/lexers/openedge.rb +0 -2
- data/lib/rouge/lexers/p4.rb +81 -0
- data/lib/rouge/lexers/php/keywords.rb +86 -136
- data/lib/rouge/lexers/php.rb +42 -2
- data/lib/rouge/lexers/plsql.rb +5 -5
- data/lib/rouge/lexers/python.rb +59 -32
- data/lib/rouge/lexers/robot_framework.rb +1 -1
- data/lib/rouge/lexers/ruby.rb +21 -21
- data/lib/rouge/lexers/sass/common.rb +1 -1
- data/lib/rouge/lexers/scala.rb +5 -2
- data/lib/rouge/lexers/sql.rb +1 -1
- data/lib/rouge/lexers/svelte.rb +91 -0
- data/lib/rouge/lexers/syzlang.rb +0 -1
- data/lib/rouge/lexers/tcl.rb +7 -2
- data/lib/rouge/lexers/terraform.rb +4 -3
- data/lib/rouge/lexers/toml.rb +56 -45
- data/lib/rouge/lexers/ttcn3.rb +0 -2
- data/lib/rouge/lexers/typescript/common.rb +9 -0
- data/lib/rouge/lexers/xojo.rb +6 -6
- data/lib/rouge/lexers/yang.rb +1 -1
- data/lib/rouge/regex_lexer.rb +13 -0
- data/lib/rouge/tex_theme_renderer.rb +1 -1
- data/lib/rouge/themes/base16.rb +23 -18
- data/lib/rouge/themes/bw.rb +1 -0
- data/lib/rouge/themes/colorful.rb +1 -0
- data/lib/rouge/themes/github.rb +1 -0
- data/lib/rouge/themes/gruvbox.rb +4 -1
- data/lib/rouge/themes/igor_pro.rb +3 -0
- data/lib/rouge/themes/magritte.rb +1 -0
- data/lib/rouge/themes/molokai.rb +2 -1
- data/lib/rouge/themes/monokai.rb +2 -1
- data/lib/rouge/themes/monokai_sublime.rb +4 -3
- data/lib/rouge/themes/pastie.rb +1 -0
- data/lib/rouge/themes/thankful_eyes.rb +1 -0
- data/lib/rouge/themes/tulip.rb +1 -0
- data/lib/rouge/token.rb +2 -1
- data/lib/rouge/version.rb +1 -1
- metadata +23 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e05371bcf7512316daaccf75a2f7c24da653b802892662c9956cbf7bcfe42f51
|
|
4
|
+
data.tar.gz: 6280b9bb9841c1bab6d563649a981c71ac996e248fe3d895bf0e38dbb4562ea0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: df0cb13e8befea6fa4d387753e245cc3ed9ace57471979cbf6869ddde69d6e2703ddc9dbfdff09da1b0e6c1b871abd9ec47325f2a5c034df5ad8cd0820dec39e
|
|
7
|
+
data.tar.gz: 32224ae94596fd50173264ab44a97d9928cc3b3f1fc2e3bb4fb1f40004e18637d8afd44cf3e482f028ac95157598f9b932238c3f593d4d3ac65ec4d4df486da7
|
data/Gemfile
CHANGED
|
@@ -10,22 +10,22 @@ gem 'minitest', '>= 5.0'
|
|
|
10
10
|
gem 'minitest-power_assert'
|
|
11
11
|
gem 'power_assert', '~> 2.0'
|
|
12
12
|
|
|
13
|
-
gem 'rubocop', '~> 1.0', '<= 1.11'
|
|
14
|
-
gem 'rubocop-performance'
|
|
15
|
-
|
|
16
13
|
# don't try to install redcarpet under jruby
|
|
17
14
|
gem 'redcarpet', platforms: :ruby
|
|
18
15
|
|
|
19
16
|
# Profiling
|
|
20
17
|
gem 'memory_profiler', require: false
|
|
21
18
|
|
|
22
|
-
# Needed for a Rake task
|
|
23
|
-
gem 'git'
|
|
24
|
-
gem 'yard'
|
|
25
|
-
|
|
26
19
|
group :development do
|
|
27
20
|
gem 'pry'
|
|
28
21
|
|
|
22
|
+
# Needed for a Rake task
|
|
23
|
+
gem 'git'
|
|
24
|
+
gem 'yard'
|
|
25
|
+
|
|
26
|
+
gem 'rubocop', '~> 1.0', '<= 1.11'
|
|
27
|
+
gem 'rubocop-performance'
|
|
28
|
+
|
|
29
29
|
# docs
|
|
30
30
|
gem 'github-markup'
|
|
31
31
|
|
|
@@ -35,4 +35,7 @@ group :development do
|
|
|
35
35
|
# Ruby 3 no longer ships with a web server
|
|
36
36
|
gem 'puma' if RUBY_VERSION >= '3'
|
|
37
37
|
gem 'shotgun'
|
|
38
|
+
|
|
39
|
+
gem "mutex_m" if RUBY_VERSION >= '3.4'
|
|
40
|
+
gem "base64" if RUBY_VERSION >= '3.4'
|
|
38
41
|
end
|
data/LICENSE
CHANGED
|
@@ -21,8 +21,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
21
21
|
THE SOFTWARE.
|
|
22
22
|
|
|
23
23
|
# SPECIAL NOTE:
|
|
24
|
+
|
|
24
25
|
Many of the lexers in this project are adaptations of those in Pygments
|
|
25
|
-
(pygments.org).
|
|
26
|
+
(pygments.org). The license for Pygments is as follows:
|
|
26
27
|
|
|
27
28
|
# BEGIN pygments/LICENSE #
|
|
28
29
|
|
data/lib/rouge/cli.rb
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
# to use this module, require 'rouge/cli'.
|
|
6
6
|
|
|
7
7
|
require 'rbconfig'
|
|
8
|
+
require 'uri'
|
|
8
9
|
|
|
9
10
|
module Rouge
|
|
10
11
|
class FileReader
|
|
@@ -347,9 +348,8 @@ module Rouge
|
|
|
347
348
|
formatter.format(lexer.lex(input), &method(:print))
|
|
348
349
|
end
|
|
349
350
|
|
|
350
|
-
private_class_method
|
|
351
|
-
|
|
352
|
-
pairs = CGI.parse(str).map { |k, v| [k.to_sym, v.first] }
|
|
351
|
+
private_class_method def self.parse_cgi(str)
|
|
352
|
+
pairs = URI.decode_www_form(str).map { |k, v| [k.to_sym, v] }
|
|
353
353
|
Hash[pairs]
|
|
354
354
|
end
|
|
355
355
|
end
|
|
@@ -511,8 +511,7 @@ module Rouge
|
|
|
511
511
|
end
|
|
512
512
|
|
|
513
513
|
|
|
514
|
-
private_class_method
|
|
515
|
-
def self.normalize_syntax(argv)
|
|
514
|
+
private_class_method def self.normalize_syntax(argv)
|
|
516
515
|
out = []
|
|
517
516
|
argv.each do |arg|
|
|
518
517
|
case arg
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
targetScope = 'subscription' // To create a resource group
|
|
2
|
+
|
|
3
|
+
@description('The Azure region to create the resources in.')
|
|
4
|
+
param location string
|
|
5
|
+
|
|
6
|
+
// Create a resource group
|
|
7
|
+
resource rg 'Microsoft.Resources/resourceGroups@2021-04-01' = {
|
|
8
|
+
name: 'rg-sample'
|
|
9
|
+
location: location
|
|
10
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
*-----------------------
|
|
2
|
+
* This file was sourced from https://github.com/openmainframeproject/cobol-programming-course
|
|
3
|
+
* Credits:
|
|
4
|
+
* The course materials were made available through a joint collaboration between IBM, its clients, and
|
|
5
|
+
* American River College and proposed as a new project by IBM.
|
|
6
|
+
*-----------------------
|
|
7
|
+
* Copyright Contributors to the COBOL Programming Course
|
|
8
|
+
* SPDX-License-Identifier: CC-BY-4.0
|
|
9
|
+
*-----------------------
|
|
10
|
+
IDENTIFICATION DIVISION.
|
|
11
|
+
*-----------------------
|
|
12
|
+
PROGRAM-ID. CBL0001
|
|
13
|
+
AUTHOR. Otto B. Fun.
|
|
14
|
+
*--------------------
|
|
15
|
+
ENVIRONMENT DIVISION.
|
|
16
|
+
*--------------------
|
|
17
|
+
INPUT-OUTPUT SECTION.
|
|
18
|
+
FILE-CONTROL.
|
|
19
|
+
SELECT PRINT-LINE ASSIGN TO PRTLINE.
|
|
20
|
+
SELECT ACCT-REC ASSIGN TO ACCTREC.
|
|
21
|
+
*SELECT clause creates an internal file name
|
|
22
|
+
*ASSIGN clause creates a name for an external data source,
|
|
23
|
+
*which is associated with the JCL DDNAME used by the z/OS
|
|
24
|
+
*e.g. ACCTREC is linked in JCL file CBL0001J to &SYSUID..DATA
|
|
25
|
+
*where &SYSUID. stands for Your z/OS user id
|
|
26
|
+
*e.g. if Your user id is Z54321,
|
|
27
|
+
*the data set used for ACCTREC is Z54321.DATA
|
|
28
|
+
*-------------
|
|
29
|
+
DATA DIVISION.
|
|
30
|
+
*-------------
|
|
31
|
+
FILE SECTION.
|
|
32
|
+
FD PRINT-LINE RECORDING MODE F.
|
|
33
|
+
01 PRINT-REC.
|
|
34
|
+
05 ACCT-NO-O PIC X(8).
|
|
35
|
+
05 ACCT-LIMIT-O PIC $$,$$$,$$9.99.
|
|
36
|
+
05 ACCT-BALANCE-O PIC $$,$$$,$$9.99.
|
|
37
|
+
* PIC $$,$$$,$$9.99 -- Alternative for PIC on chapter 7.2.3,
|
|
38
|
+
* using $ to allow values of different amounts of digits
|
|
39
|
+
* and .99 instead of v99 to allow period display on output
|
|
40
|
+
05 LAST-NAME-O PIC X(20).
|
|
41
|
+
05 FIRST-NAME-O PIC X(15).
|
|
42
|
+
05 COMMENTS-O PIC X(50).
|
|
43
|
+
* since the level 05 is higher than level 01,
|
|
44
|
+
* all variables belong to PRINT-REC (see chapter 7.3.3)
|
|
45
|
+
*
|
|
46
|
+
FD ACCT-REC RECORDING MODE F.
|
|
47
|
+
01 ACCT-FIELDS.
|
|
48
|
+
05 ACCT-NO PIC X(8).
|
|
49
|
+
05 ACCT-LIMIT PIC S9(7)V99 COMP-3.
|
|
50
|
+
05 ACCT-BALANCE PIC S9(7)V99 COMP-3.
|
|
51
|
+
* PIC S9(7)v99 -- seven-digit plus a sign digit value
|
|
52
|
+
* COMP-3 -- packed BCD (binary coded decimal) representation
|
|
53
|
+
05 LAST-NAME PIC X(20).
|
|
54
|
+
05 FIRST-NAME PIC X(15).
|
|
55
|
+
05 CLIENT-ADDR.
|
|
56
|
+
10 STREET-ADDR PIC X(25).
|
|
57
|
+
10 CITY-COUNTY PIC X(20).
|
|
58
|
+
10 USA-STATE PIC X(15).
|
|
59
|
+
05 RESERVED PIC X(7).
|
|
60
|
+
05 COMMENTS PIC X(50).
|
|
61
|
+
*
|
|
62
|
+
WORKING-STORAGE SECTION.
|
|
63
|
+
01 FLAGS.
|
|
64
|
+
05 LASTREC PIC X VALUE SPACE.
|
|
65
|
+
*------------------
|
|
66
|
+
PROCEDURE DIVISION.
|
|
67
|
+
*------------------
|
|
68
|
+
OPEN-FILES.
|
|
69
|
+
OPEN INPUT ACCT-REC.
|
|
70
|
+
OPEN OUTPUT PRINT-LINE.
|
|
71
|
+
*
|
|
72
|
+
READ-NEXT-RECORD.
|
|
73
|
+
PERFORM READ-RECORD
|
|
74
|
+
* The previous statement is needed before entering the loop.
|
|
75
|
+
* Both the loop condition LASTREC = 'Y'
|
|
76
|
+
* and the call to WRITE-RECORD depend on READ-RECORD having
|
|
77
|
+
* been executed before.
|
|
78
|
+
* The loop starts at the next line with PERFORM UNTIL
|
|
79
|
+
PERFORM UNTIL LASTREC = 'Y'
|
|
80
|
+
PERFORM WRITE-RECORD
|
|
81
|
+
PERFORM READ-RECORD
|
|
82
|
+
END-PERFORM
|
|
83
|
+
.
|
|
84
|
+
*
|
|
85
|
+
CLOSE-STOP.
|
|
86
|
+
CLOSE ACCT-REC.
|
|
87
|
+
CLOSE PRINT-LINE.
|
|
88
|
+
GOBACK.
|
|
89
|
+
*
|
|
90
|
+
READ-RECORD.
|
|
91
|
+
READ ACCT-REC
|
|
92
|
+
AT END MOVE 'Y' TO LASTREC
|
|
93
|
+
END-READ.
|
|
94
|
+
*
|
|
95
|
+
WRITE-RECORD.
|
|
96
|
+
MOVE ACCT-NO TO ACCT-NO-O.
|
|
97
|
+
MOVE ACCT-LIMIT TO ACCT-LIMIT-O.
|
|
98
|
+
MOVE ACCT-BALANCE TO ACCT-BALANCE-O.
|
|
99
|
+
MOVE LAST-NAME TO LAST-NAME-O.
|
|
100
|
+
MOVE FIRST-NAME TO FIRST-NAME-O.
|
|
101
|
+
MOVE COMMENTS TO COMMENTS-O.
|
|
102
|
+
WRITE PRINT-REC.
|
|
103
|
+
*
|
data/lib/rouge/demos/gjs
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { LinkTo } from '@ember/routing';
|
|
2
|
+
import { local } from 'embroider-css-modules';
|
|
3
|
+
|
|
4
|
+
import styles from './navigation-menu.css';
|
|
5
|
+
|
|
6
|
+
const NavigationMenu = <template>
|
|
7
|
+
<nav aria-label={{@name}} data-test-nav={{@name}}>
|
|
8
|
+
<ul class={{styles.list}}>
|
|
9
|
+
{{#each @menuItems as |menuItem|}}
|
|
10
|
+
<li>
|
|
11
|
+
<LinkTo
|
|
12
|
+
class={{local styles "link"}}
|
|
13
|
+
data-test-link={{menuItem.label}}
|
|
14
|
+
>
|
|
15
|
+
{{menuItem.label}}
|
|
16
|
+
</LinkTo>
|
|
17
|
+
</li>
|
|
18
|
+
{{/each}}
|
|
19
|
+
</ul>
|
|
20
|
+
</nav>
|
|
21
|
+
</template>;
|
|
22
|
+
|
|
23
|
+
export default NavigationMenu;
|
data/lib/rouge/demos/gts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { TOC } from '@ember/component/template-only';
|
|
2
|
+
import { LinkTo } from '@ember/routing';
|
|
3
|
+
import { local } from 'embroider-css-modules';
|
|
4
|
+
|
|
5
|
+
import styles from './navigation-menu.css';
|
|
6
|
+
|
|
7
|
+
type MenuItem = {
|
|
8
|
+
label: string;
|
|
9
|
+
route: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
interface NavigationMenuSignature {
|
|
13
|
+
Args: {
|
|
14
|
+
menuItems: MenuItem[];
|
|
15
|
+
name?: string;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const NavigationMenu = <template>
|
|
20
|
+
<nav aria-label={{@name}} data-test-nav={{@name}}>
|
|
21
|
+
<ul class={{styles.list}}>
|
|
22
|
+
{{#each @menuItems as |menuItem|}}
|
|
23
|
+
<li>
|
|
24
|
+
<LinkTo
|
|
25
|
+
class={{local styles "link"}}
|
|
26
|
+
data-test-link={{menuItem.label}}
|
|
27
|
+
>
|
|
28
|
+
{{menuItem.label}}
|
|
29
|
+
</LinkTo>
|
|
30
|
+
</li>
|
|
31
|
+
{{/each}}
|
|
32
|
+
</ul>
|
|
33
|
+
</nav>
|
|
34
|
+
</template> satisfies TOC<NavigationMenuSignature>;
|
|
35
|
+
|
|
36
|
+
export default NavigationMenu;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// first-order lag derivative term
|
|
2
|
+
(*
|
|
3
|
+
Parameter K must be set to T / (T + T1)
|
|
4
|
+
*)
|
|
5
|
+
FUNCTION_BLOCK DT2
|
|
6
|
+
|
|
7
|
+
VAR_INPUT
|
|
8
|
+
IN : REAL;
|
|
9
|
+
K : REAL;
|
|
10
|
+
END_VAR
|
|
11
|
+
VAR_OUTPUT
|
|
12
|
+
Q : REAL;
|
|
13
|
+
END_VAR
|
|
14
|
+
VAR
|
|
15
|
+
H : REAL := 0.0;
|
|
16
|
+
END_VAR
|
|
17
|
+
|
|
18
|
+
BEGIN
|
|
19
|
+
Q := IN - H;
|
|
20
|
+
H := H + K * Q;
|
|
21
|
+
END_FUNCTION_BLOCK
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
// comments
|
|
3
|
+
unquoted: 'and you can quote me on that',
|
|
4
|
+
singleQuotes: 'I can use "double quotes" here',
|
|
5
|
+
lineBreaks: "Look, Mom! \
|
|
6
|
+
No \\n's!",
|
|
7
|
+
hexadecimal: 0xdecaf,
|
|
8
|
+
leadingDecimalPoint: .8675309, andTrailing: 8675309.,
|
|
9
|
+
positiveSign: +1,
|
|
10
|
+
trailingComma: 'in objects', andIn: ['arrays',],
|
|
11
|
+
"backwardsCompatible": "with JSON",
|
|
12
|
+
}
|
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;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<!-- This file is made up from several examples on https://svelte.dev/examples and is not expected to function. -->
|
|
2
|
+
<script lang="ts">
|
|
3
|
+
import Image from './Image.svelte';
|
|
4
|
+
|
|
5
|
+
let src: string = '/tutorial/image.gif';
|
|
6
|
+
let count: number = 1;
|
|
7
|
+
$: doubled = count * 2; // the `$:` is special in svelte
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<Image {src} bind:alt="{name.capitalize()} dancing" user={name.toUpperCase(false, 42, {key: 'value'})}
|
|
11
|
+
tooltip="I'm helping" false text=asdf on:message={handleMessage} />
|
|
12
|
+
|
|
13
|
+
{#await loadSrc(src)}
|
|
14
|
+
loading...
|
|
15
|
+
{:then data}
|
|
16
|
+
{#each cats as { name }, i}
|
|
17
|
+
<li>{name}</li>
|
|
18
|
+
{/each}
|
|
19
|
+
|
|
20
|
+
<!-- Keyed Each Block -->
|
|
21
|
+
{#each cats as cat (cat.id)}
|
|
22
|
+
<li>{cat.name}</li>
|
|
23
|
+
{/each}
|
|
24
|
+
{:catch err}
|
|
25
|
+
{@debug err}
|
|
26
|
+
{#await solveErr(err, {x: 'asdf'}) then reason}{@html reason}{/await}
|
|
27
|
+
{/await}
|
|
28
|
+
|
|
29
|
+
<style>p {font-family: 'Comic Sans MS', cursive;}</style>
|
|
@@ -66,6 +66,12 @@ module Rouge
|
|
|
66
66
|
end
|
|
67
67
|
end
|
|
68
68
|
|
|
69
|
+
disambiguate '*.cfg' do
|
|
70
|
+
next CiscoIos if matches?(/\A\s*(version|banner|interface)\b/)
|
|
71
|
+
|
|
72
|
+
INI
|
|
73
|
+
end
|
|
74
|
+
|
|
69
75
|
disambiguate '*.pl' do
|
|
70
76
|
next Perl if contains?('my $')
|
|
71
77
|
next Prolog if contains?(':-')
|
|
@@ -84,14 +90,24 @@ module Rouge
|
|
|
84
90
|
disambiguate '*.m' do
|
|
85
91
|
next ObjectiveC if matches?(/@(end|implementation|protocol|property)\b/)
|
|
86
92
|
next ObjectiveC if contains?('@"')
|
|
93
|
+
|
|
94
|
+
# Objective-C dereferenced pointers and Mathematica comments are similar.
|
|
95
|
+
# Disambiguate for Mathematica by looking for any amount of whitespace (or no whitespace)
|
|
96
|
+
# followed by "(*" (e.g. `(* comment *)`).
|
|
97
|
+
next Mathematica if matches?(/^\s*\(\*/)
|
|
98
|
+
|
|
99
|
+
# Disambiguate for objc by looking for a deref'd pointer in a statement (e.g. `if (*foo == 0)`).
|
|
100
|
+
# This pattern is less specific than the Mathematica pattern, so its positioned after it.
|
|
101
|
+
next ObjectiveC if matches?(/^\s*(if|while|for|switch|do)\s*\([^)]*\*[^)]*\)/)
|
|
87
102
|
|
|
88
|
-
next Mathematica if contains?('(*')
|
|
89
103
|
next Mathematica if contains?(':=')
|
|
90
104
|
|
|
91
105
|
next Mason if matches?(/<%(def|method|text|doc|args|flags|attr|init|once|shared|perl|cleanup|filter)([^>]*)(>)/)
|
|
92
106
|
|
|
93
107
|
next Matlab if matches?(/^\s*?%/)
|
|
94
|
-
|
|
108
|
+
# Matlab cell array creation: data = {
|
|
109
|
+
next Matlab if matches?(/^\s*[a-zA-Z]\w*\s*=\s*\{/)
|
|
110
|
+
|
|
95
111
|
next Mason if matches? %r!(</?%|<&)!
|
|
96
112
|
end
|
|
97
113
|
|
|
@@ -140,12 +156,17 @@ module Rouge
|
|
|
140
156
|
|
|
141
157
|
Puppet
|
|
142
158
|
end
|
|
143
|
-
|
|
159
|
+
|
|
144
160
|
disambiguate '*.p' do
|
|
145
161
|
next Prolog if contains?(':-')
|
|
146
162
|
next Prolog if matches?(/\A\w+(\(\w+\,\s*\w+\))*\./)
|
|
147
163
|
next OpenEdge
|
|
148
164
|
end
|
|
165
|
+
|
|
166
|
+
disambiguate '*.st' do
|
|
167
|
+
next IecST if matches?(/^\s*END_/i)
|
|
168
|
+
next Smalltalk
|
|
169
|
+
end
|
|
149
170
|
end
|
|
150
171
|
end
|
|
151
172
|
end
|
data/lib/rouge/lexer.rb
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
|
|
4
4
|
# stdlib
|
|
5
5
|
require 'strscan'
|
|
6
|
-
require 'cgi'
|
|
7
6
|
require 'set'
|
|
7
|
+
require 'uri'
|
|
8
8
|
|
|
9
9
|
module Rouge
|
|
10
10
|
# @abstract
|
|
@@ -52,17 +52,19 @@ module Rouge
|
|
|
52
52
|
name, opts = str ? str.split('?', 2) : [nil, '']
|
|
53
53
|
|
|
54
54
|
# parse the options hash from a cgi-style string
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
cgi_opts = Hash.new { |hash, key| hash[key] = [] }
|
|
56
|
+
URI.decode_www_form(opts || '').each do |k, val|
|
|
57
|
+
cgi_opts[k] << val
|
|
58
|
+
end
|
|
59
|
+
cgi_opts.transform_values! do |vals|
|
|
60
|
+
case vals.size
|
|
57
61
|
when 0 then true
|
|
58
62
|
when 1 then vals[0]
|
|
59
63
|
else vals
|
|
60
64
|
end
|
|
61
|
-
|
|
62
|
-
[ k.to_s, val ]
|
|
63
65
|
end
|
|
64
66
|
|
|
65
|
-
opts = default_options.merge(
|
|
67
|
+
opts = default_options.merge(cgi_opts)
|
|
66
68
|
|
|
67
69
|
lexer_class = case name
|
|
68
70
|
when 'guess', nil
|
data/lib/rouge/lexers/ada.rb
CHANGED
|
@@ -5,7 +5,7 @@ module Rouge
|
|
|
5
5
|
module Lexers
|
|
6
6
|
class Ada < RegexLexer
|
|
7
7
|
tag 'ada'
|
|
8
|
-
filenames '*.ada', '*.ads', '*.adb', '*.gpr'
|
|
8
|
+
filenames '*.ada', '*.ads', '*.adb', '*.adc', '*.gpr'
|
|
9
9
|
mimetypes 'text/x-ada'
|
|
10
10
|
|
|
11
11
|
title 'Ada'
|
|
@@ -26,7 +26,7 @@ module Rouge
|
|
|
26
26
|
abort abstract accept access aliased all array at begin body
|
|
27
27
|
case constant declare delay delta digits do else elsif end
|
|
28
28
|
exception exit for generic goto if in interface is limited
|
|
29
|
-
loop new null of others out overriding pragma private
|
|
29
|
+
loop new null of others out overriding parallel pragma private
|
|
30
30
|
protected raise range record renames requeue return reverse
|
|
31
31
|
select separate some synchronized tagged task terminate then
|
|
32
32
|
until use when while with
|
|
@@ -143,8 +143,8 @@ module Rouge
|
|
|
143
143
|
end
|
|
144
144
|
|
|
145
145
|
# Operators and punctuation characters.
|
|
146
|
-
rule %r{[+*/&<=>|]|-|=>|\.\.|\*\*|[:></]
|
|
147
|
-
rule %r{[.,:;()]}, Punctuation
|
|
146
|
+
rule %r{[+*/&<=>|]|-|=>|\.\.|\*\*|[:></]=|<<|>>|<>|@}, Operator
|
|
147
|
+
rule %r{[.,:;()\[\]]}, Punctuation
|
|
148
148
|
|
|
149
149
|
rule ID do |m|
|
|
150
150
|
t = self.class.idents[m[0].downcase]
|
|
@@ -155,7 +155,7 @@ module Rouge
|
|
|
155
155
|
end
|
|
156
156
|
|
|
157
157
|
# Flag word-like things that don't match the ID pattern.
|
|
158
|
-
rule %r{\b(\p{Pc}|[[alpha]])\p{Word}*}, Error
|
|
158
|
+
rule %r{\b(\p{Pc}|[[:alpha:]])\p{Word}*}, Error
|
|
159
159
|
end
|
|
160
160
|
end
|
|
161
161
|
end
|