rouge 3.1.0 → 3.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile +17 -3
- data/bin/rougify +1 -0
- data/lib/rouge.rb +67 -42
- data/lib/rouge/cli.rb +87 -18
- data/lib/rouge/demos/ada +26 -0
- data/lib/rouge/demos/apex +9 -0
- data/lib/rouge/demos/armasm +12 -0
- data/lib/rouge/demos/batchfile +3 -0
- data/lib/rouge/demos/bbcbasic +6 -0
- data/lib/rouge/demos/bpf +7 -0
- data/lib/rouge/demos/brainfuck +5 -0
- data/lib/rouge/demos/clean +6 -0
- data/lib/rouge/demos/cmhg +8 -0
- data/lib/rouge/demos/crystal +45 -0
- data/lib/rouge/demos/csvs +8 -0
- data/lib/rouge/demos/cuda +11 -0
- data/lib/rouge/demos/cypher +5 -0
- data/lib/rouge/demos/cython +6 -0
- data/lib/rouge/demos/datastudio +21 -0
- data/lib/rouge/demos/ecl +18 -0
- data/lib/rouge/demos/eex +1 -0
- data/lib/rouge/demos/epp +4 -0
- data/lib/rouge/demos/escape +3 -0
- data/lib/rouge/demos/freefem +16 -0
- data/lib/rouge/demos/gdscript +18 -0
- data/lib/rouge/demos/ghc-cmm +23 -0
- data/lib/rouge/demos/ghc-core +26 -0
- data/lib/rouge/demos/haxe +5 -0
- data/lib/rouge/demos/hcl +7 -0
- data/lib/rouge/demos/hocon +8 -0
- data/lib/rouge/demos/hql +5 -0
- data/lib/rouge/demos/isbl +4 -0
- data/lib/rouge/demos/jsl +3 -0
- data/lib/rouge/demos/jsp +29 -0
- data/lib/rouge/demos/liquid +0 -1
- data/lib/rouge/demos/lustre +6 -0
- data/lib/rouge/demos/lutin +18 -0
- data/lib/rouge/demos/m68k +16 -0
- data/lib/rouge/demos/magik +6 -0
- data/lib/rouge/demos/mason +22 -0
- data/lib/rouge/demos/mathematica +8 -0
- data/lib/rouge/demos/minizinc +23 -0
- data/lib/rouge/demos/msgtrans +4 -0
- data/lib/rouge/demos/nasm +6 -6
- data/lib/rouge/demos/nesasm +11 -0
- data/lib/rouge/demos/objective_cpp +17 -0
- data/lib/rouge/demos/openedge +4 -0
- data/lib/rouge/demos/opentype_feature_file +6 -0
- data/lib/rouge/demos/plist +1 -132
- data/lib/rouge/demos/powershell +12 -48
- data/lib/rouge/demos/q +6 -0
- data/lib/rouge/demos/reasonml +12 -0
- data/lib/rouge/demos/rego +8 -0
- data/lib/rouge/demos/robot_framework +27 -0
- data/lib/rouge/demos/sas +13 -0
- data/lib/rouge/demos/slice +10 -0
- data/lib/rouge/demos/solidity +13 -0
- data/lib/rouge/demos/sparql +6 -0
- data/lib/rouge/demos/sqf +14 -0
- data/lib/rouge/demos/supercollider +11 -0
- data/lib/rouge/demos/terraform +16 -0
- data/lib/rouge/demos/ttcn3 +6 -0
- data/lib/rouge/demos/vcl +12 -0
- data/lib/rouge/demos/xojo +14 -0
- data/lib/rouge/demos/xpath +2 -0
- data/lib/rouge/demos/xquery +22 -0
- data/lib/rouge/demos/yang +17 -0
- data/lib/rouge/formatter.rb +39 -2
- data/lib/rouge/formatters/html.rb +21 -2
- data/lib/rouge/formatters/html_inline.rb +1 -0
- data/lib/rouge/formatters/html_legacy.rb +1 -0
- data/lib/rouge/formatters/html_line_table.rb +53 -0
- data/lib/rouge/formatters/html_linewise.rb +7 -11
- data/lib/rouge/formatters/html_pygments.rb +2 -0
- data/lib/rouge/formatters/html_table.rb +21 -31
- data/lib/rouge/formatters/null.rb +1 -0
- data/lib/rouge/formatters/terminal256.rb +23 -5
- data/lib/rouge/formatters/terminal_truecolor.rb +37 -0
- data/lib/rouge/formatters/tex.rb +92 -0
- data/lib/rouge/guesser.rb +2 -0
- data/lib/rouge/guessers/disambiguation.rb +35 -0
- data/lib/rouge/guessers/filename.rb +2 -0
- data/lib/rouge/guessers/glob_mapping.rb +3 -1
- data/lib/rouge/guessers/mimetype.rb +2 -0
- data/lib/rouge/guessers/modeline.rb +3 -1
- data/lib/rouge/guessers/source.rb +3 -1
- data/lib/rouge/guessers/util.rb +2 -0
- data/lib/rouge/lexer.rb +71 -15
- data/lib/rouge/lexers/abap.rb +13 -11
- data/lib/rouge/lexers/actionscript.rb +35 -34
- data/lib/rouge/lexers/ada.rb +162 -0
- data/lib/rouge/lexers/apache.rb +13 -15
- data/lib/rouge/lexers/apache/keywords.rb +15 -0
- data/lib/rouge/lexers/apex.rb +126 -0
- data/lib/rouge/lexers/apiblueprint.rb +2 -0
- data/lib/rouge/lexers/apple_script.rb +17 -14
- data/lib/rouge/lexers/armasm.rb +145 -0
- data/lib/rouge/lexers/awk.rb +26 -25
- data/lib/rouge/lexers/batchfile.rb +164 -0
- data/lib/rouge/lexers/bbcbasic.rb +112 -0
- data/lib/rouge/lexers/biml.rb +6 -4
- data/lib/rouge/lexers/bpf.rb +118 -0
- data/lib/rouge/lexers/brainfuck.rb +53 -0
- data/lib/rouge/lexers/bsl.rb +13 -12
- data/lib/rouge/lexers/c.rb +35 -57
- data/lib/rouge/lexers/ceylon.rb +7 -34
- data/lib/rouge/lexers/cfscript.rb +27 -26
- data/lib/rouge/lexers/clean.rb +156 -0
- data/lib/rouge/lexers/clojure.rb +15 -14
- data/lib/rouge/lexers/cmake.rb +16 -14
- data/lib/rouge/lexers/cmhg.rb +34 -0
- data/lib/rouge/lexers/coffeescript.rb +90 -49
- data/lib/rouge/lexers/common_lisp.rb +39 -38
- data/lib/rouge/lexers/conf.rb +7 -6
- data/lib/rouge/lexers/console.rb +92 -38
- data/lib/rouge/lexers/coq.rb +27 -23
- data/lib/rouge/lexers/cpp.rb +24 -13
- data/lib/rouge/lexers/crystal.rb +430 -0
- data/lib/rouge/lexers/csharp.rb +29 -29
- data/lib/rouge/lexers/css.rb +24 -23
- data/lib/rouge/lexers/csvs.rb +44 -0
- data/lib/rouge/lexers/cuda.rb +35 -0
- data/lib/rouge/lexers/cypher.rb +108 -0
- data/lib/rouge/lexers/cython.rb +151 -0
- data/lib/rouge/lexers/d.rb +64 -63
- data/lib/rouge/lexers/dart.rb +34 -33
- data/lib/rouge/lexers/datastudio.rb +138 -0
- data/lib/rouge/lexers/diff.rb +10 -4
- data/lib/rouge/lexers/digdag.rb +3 -1
- data/lib/rouge/lexers/docker.rb +12 -11
- data/lib/rouge/lexers/dot.rb +19 -18
- data/lib/rouge/lexers/ecl.rb +175 -0
- data/lib/rouge/lexers/eex.rb +52 -0
- data/lib/rouge/lexers/eiffel.rb +21 -20
- data/lib/rouge/lexers/elixir.rb +52 -36
- data/lib/rouge/lexers/elm.rb +30 -29
- data/lib/rouge/lexers/epp.rb +51 -0
- data/lib/rouge/lexers/erb.rb +5 -4
- data/lib/rouge/lexers/erlang.rb +1 -0
- data/lib/rouge/lexers/escape.rb +58 -0
- data/lib/rouge/lexers/factor.rb +41 -40
- data/lib/rouge/lexers/fortran.rb +36 -34
- data/lib/rouge/lexers/freefem.rb +240 -0
- data/lib/rouge/lexers/fsharp.rb +33 -31
- data/lib/rouge/lexers/gdscript.rb +171 -0
- data/lib/rouge/lexers/ghc_cmm.rb +340 -0
- data/lib/rouge/lexers/ghc_core.rb +151 -0
- data/lib/rouge/lexers/gherkin.rb +17 -14
- data/lib/rouge/lexers/gherkin/keywords.rb +2 -0
- data/lib/rouge/lexers/glsl.rb +2 -5
- data/lib/rouge/lexers/go.rb +3 -2
- data/lib/rouge/lexers/gradle.rb +1 -0
- data/lib/rouge/lexers/graphql.rb +78 -60
- data/lib/rouge/lexers/groovy.rb +24 -25
- data/lib/rouge/lexers/hack.rb +2 -1
- data/lib/rouge/lexers/haml.rb +26 -29
- data/lib/rouge/lexers/handlebars.rb +32 -20
- data/lib/rouge/lexers/haskell.rb +78 -61
- data/lib/rouge/lexers/haxe.rb +246 -0
- data/lib/rouge/lexers/hcl.rb +163 -0
- data/lib/rouge/lexers/hocon.rb +86 -0
- data/lib/rouge/lexers/hql.rb +139 -0
- data/lib/rouge/lexers/html.rb +36 -33
- data/lib/rouge/lexers/http.rb +10 -9
- data/lib/rouge/lexers/hylang.rb +15 -14
- data/lib/rouge/lexers/idlang.rb +34 -32
- data/lib/rouge/lexers/igorpro.rb +481 -225
- data/lib/rouge/lexers/ini.rb +13 -12
- data/lib/rouge/lexers/io.rb +10 -9
- data/lib/rouge/lexers/irb.rb +6 -5
- data/lib/rouge/lexers/isbl.rb +97 -0
- data/lib/rouge/lexers/isbl/builtins.rb +17 -0
- data/lib/rouge/lexers/java.rb +30 -26
- data/lib/rouge/lexers/javascript.rb +59 -61
- data/lib/rouge/lexers/jinja.rb +39 -22
- data/lib/rouge/lexers/jsl.rb +55 -0
- data/lib/rouge/lexers/json.rb +54 -11
- data/lib/rouge/lexers/json_doc.rb +8 -5
- data/lib/rouge/lexers/jsonnet.rb +19 -18
- data/lib/rouge/lexers/jsp.rb +120 -0
- data/lib/rouge/lexers/jsx.rb +18 -16
- data/lib/rouge/lexers/julia.rb +192 -74
- data/lib/rouge/lexers/kotlin.rb +79 -27
- data/lib/rouge/lexers/lasso.rb +54 -58
- data/lib/rouge/lexers/lasso/keywords.rb +14 -0
- data/lib/rouge/lexers/liquid.rb +116 -118
- data/lib/rouge/lexers/literate_coffeescript.rb +3 -2
- data/lib/rouge/lexers/literate_haskell.rb +6 -5
- data/lib/rouge/lexers/llvm.rb +66 -49
- data/lib/rouge/lexers/lua.rb +43 -4
- data/lib/rouge/lexers/lua/builtins.rb +2 -0
- data/lib/rouge/lexers/lustre.rb +79 -0
- data/lib/rouge/lexers/lutin.rb +33 -0
- data/lib/rouge/lexers/m68k.rb +143 -0
- data/lib/rouge/lexers/magik.rb +127 -0
- data/lib/rouge/lexers/make.rb +57 -34
- data/lib/rouge/lexers/markdown.rb +67 -39
- data/lib/rouge/lexers/mason.rb +110 -0
- data/lib/rouge/lexers/mathematica.rb +96 -0
- data/lib/rouge/lexers/mathematica/builtins.rb +13 -0
- data/lib/rouge/lexers/matlab.rb +26 -17
- data/lib/rouge/lexers/matlab/builtins.rb +4 -4
- data/lib/rouge/lexers/minizinc.rb +87 -0
- data/lib/rouge/lexers/moonscript.rb +4 -3
- data/lib/rouge/lexers/mosel.rb +64 -63
- data/lib/rouge/lexers/msgtrans.rb +26 -0
- data/lib/rouge/lexers/mxml.rb +19 -18
- data/lib/rouge/lexers/nasm.rb +43 -169
- data/lib/rouge/lexers/nesasm.rb +78 -0
- data/lib/rouge/lexers/nginx.rb +15 -14
- data/lib/rouge/lexers/nim.rb +4 -2
- data/lib/rouge/lexers/nix.rb +48 -42
- data/lib/rouge/lexers/objective_c.rb +5 -178
- data/lib/rouge/lexers/objective_c/common.rb +184 -0
- data/lib/rouge/lexers/objective_cpp.rb +31 -0
- data/lib/rouge/lexers/ocaml.rb +29 -64
- data/lib/rouge/lexers/ocaml/common.rb +53 -0
- data/lib/rouge/lexers/openedge.rb +429 -0
- data/lib/rouge/lexers/opentype_feature_file.rb +113 -0
- data/lib/rouge/lexers/pascal.rb +6 -5
- data/lib/rouge/lexers/perl.rb +103 -68
- data/lib/rouge/lexers/php.rb +91 -53
- data/lib/rouge/lexers/php/builtins.rb +183 -174
- data/lib/rouge/lexers/plain_text.rb +2 -1
- data/lib/rouge/lexers/plist.rb +16 -14
- data/lib/rouge/lexers/pony.rb +21 -20
- data/lib/rouge/lexers/powershell.rb +190 -638
- data/lib/rouge/lexers/praat.rb +76 -75
- data/lib/rouge/lexers/prolog.rb +27 -19
- data/lib/rouge/lexers/prometheus.rb +32 -30
- data/lib/rouge/lexers/properties.rb +13 -12
- data/lib/rouge/lexers/protobuf.rb +23 -22
- data/lib/rouge/lexers/puppet.rb +33 -32
- data/lib/rouge/lexers/python.rb +124 -99
- data/lib/rouge/lexers/q.rb +17 -14
- data/lib/rouge/lexers/qml.rb +13 -12
- data/lib/rouge/lexers/r.rb +13 -13
- data/lib/rouge/lexers/racket.rb +47 -22
- data/lib/rouge/lexers/reasonml.rb +65 -0
- data/lib/rouge/lexers/rego.rb +45 -0
- data/lib/rouge/lexers/robot_framework.rb +249 -0
- data/lib/rouge/lexers/ruby.rb +88 -71
- data/lib/rouge/lexers/rust.rb +45 -44
- data/lib/rouge/lexers/sas.rb +563 -0
- data/lib/rouge/lexers/sass.rb +9 -8
- data/lib/rouge/lexers/sass/common.rb +41 -40
- data/lib/rouge/lexers/scala.rb +67 -40
- data/lib/rouge/lexers/scheme.rb +19 -18
- data/lib/rouge/lexers/scss.rb +4 -3
- data/lib/rouge/lexers/sed.rb +31 -30
- data/lib/rouge/lexers/shell.rb +67 -55
- data/lib/rouge/lexers/sieve.rb +10 -9
- data/lib/rouge/lexers/slice.rb +32 -0
- data/lib/rouge/lexers/slim.rb +27 -26
- data/lib/rouge/lexers/smalltalk.rb +34 -33
- data/lib/rouge/lexers/smarty.rb +20 -19
- data/lib/rouge/lexers/sml.rb +68 -67
- data/lib/rouge/lexers/solidity.rb +185 -0
- data/lib/rouge/lexers/sparql.rb +129 -0
- data/lib/rouge/lexers/sqf.rb +109 -0
- data/lib/rouge/lexers/sqf/commands.rb +15 -0
- data/lib/rouge/lexers/sql.rb +47 -26
- data/lib/rouge/lexers/supercollider.rb +116 -0
- data/lib/rouge/lexers/swift.rb +50 -45
- data/lib/rouge/lexers/tap.rb +22 -20
- data/lib/rouge/lexers/tcl.rb +28 -27
- data/lib/rouge/lexers/terraform.rb +128 -0
- data/lib/rouge/lexers/tex.rb +20 -19
- data/lib/rouge/lexers/toml.rb +59 -20
- data/lib/rouge/lexers/tsx.rb +1 -0
- data/lib/rouge/lexers/ttcn3.rb +119 -0
- data/lib/rouge/lexers/tulip.rb +38 -36
- data/lib/rouge/lexers/turtle.rb +36 -38
- data/lib/rouge/lexers/twig.rb +1 -0
- data/lib/rouge/lexers/typescript.rb +12 -0
- data/lib/rouge/lexers/typescript/common.rb +1 -0
- data/lib/rouge/lexers/vala.rb +19 -18
- data/lib/rouge/lexers/varnish.rb +168 -0
- data/lib/rouge/lexers/vb.rb +28 -27
- data/lib/rouge/lexers/verilog.rb +27 -28
- data/lib/rouge/lexers/vhdl.rb +13 -12
- data/lib/rouge/lexers/viml.rb +15 -14
- data/lib/rouge/lexers/viml/keywords.rb +2 -0
- data/lib/rouge/lexers/vue.rb +19 -12
- data/lib/rouge/lexers/wollok.rb +27 -26
- data/lib/rouge/lexers/xml.rb +18 -21
- data/lib/rouge/lexers/xojo.rb +61 -0
- data/lib/rouge/lexers/xpath.rb +332 -0
- data/lib/rouge/lexers/xquery.rb +145 -0
- data/lib/rouge/lexers/yaml.rb +64 -61
- data/lib/rouge/lexers/yang.rb +147 -0
- data/lib/rouge/plugins/redcarpet.rb +9 -2
- data/lib/rouge/regex_lexer.rb +27 -25
- data/lib/rouge/template_lexer.rb +1 -0
- data/lib/rouge/tex_theme_renderer.rb +132 -0
- data/lib/rouge/text_analyzer.rb +1 -0
- data/lib/rouge/theme.rb +5 -0
- data/lib/rouge/themes/base16.rb +1 -0
- data/lib/rouge/themes/bw.rb +41 -0
- data/lib/rouge/themes/colorful.rb +1 -0
- data/lib/rouge/themes/github.rb +1 -0
- data/lib/rouge/themes/gruvbox.rb +1 -0
- data/lib/rouge/themes/igor_pro.rb +1 -0
- data/lib/rouge/themes/magritte.rb +78 -0
- data/lib/rouge/themes/molokai.rb +1 -0
- data/lib/rouge/themes/monokai.rb +1 -0
- data/lib/rouge/themes/monokai_sublime.rb +4 -1
- data/lib/rouge/themes/pastie.rb +2 -1
- data/lib/rouge/themes/thankful_eyes.rb +2 -1
- data/lib/rouge/themes/tulip.rb +2 -1
- data/lib/rouge/token.rb +31 -22
- data/lib/rouge/util.rb +3 -2
- data/lib/rouge/version.rb +2 -1
- data/rouge.gemspec +6 -3
- metadata +136 -8
- data/lib/rouge/lexers/apache/keywords.yml +0 -764
- data/lib/rouge/lexers/lasso/keywords.yml +0 -446
data/lib/rouge/lexers/d.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# -*- coding: utf-8 -*- #
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Rouge
|
4
5
|
module Lexers
|
@@ -34,75 +35,75 @@ module Rouge
|
|
34
35
|
)
|
35
36
|
|
36
37
|
keywords_pseudo = %w(
|
37
|
-
__FILE__ __MODULE__ __LINE__ __FUNCTION__
|
38
|
-
|
39
|
-
__VERSION__
|
38
|
+
__FILE__ __FILE_FULL_PATH__ __MODULE__ __LINE__ __FUNCTION__
|
39
|
+
__PRETTY_FUNCTION__ __DATE__ __EOF__ __TIME__ __TIMESTAMP__
|
40
|
+
__VENDOR__ __VERSION__
|
40
41
|
)
|
41
42
|
|
42
43
|
state :whitespace do
|
43
|
-
rule /\n/m, Text
|
44
|
-
rule /\s+/m, Text
|
44
|
+
rule %r/\n/m, Text
|
45
|
+
rule %r/\s+/m, Text
|
45
46
|
end
|
46
47
|
|
47
48
|
state :root do
|
48
49
|
mixin :whitespace
|
49
50
|
# Comments
|
50
|
-
rule %r(
|
51
|
+
rule %r(//.*), Comment::Single
|
51
52
|
rule %r(/(\\\n)?[*](.|\n)*?[*](\\\n)?/), Comment::Multiline
|
52
53
|
rule %r(/\+), Comment::Multiline, :nested_comment
|
53
54
|
# Keywords
|
54
|
-
rule /(#{keywords.join('|')})\b/, Keyword
|
55
|
-
rule /(#{keywords_type.join('|')})\b/, Keyword::Type
|
56
|
-
rule /(false|true|null)\b/, Keyword::Constant
|
57
|
-
rule /(#{keywords_pseudo.join('|')})\b/, Keyword::Pseudo
|
58
|
-
rule /macro\b/, Keyword::Reserved
|
59
|
-
rule /(string|wstring|dstring|size_t|ptrdiff_t)\b/, Name::Builtin
|
55
|
+
rule %r/(#{keywords.join('|')})\b/, Keyword
|
56
|
+
rule %r/(#{keywords_type.join('|')})\b/, Keyword::Type
|
57
|
+
rule %r/(false|true|null)\b/, Keyword::Constant
|
58
|
+
rule %r/(#{keywords_pseudo.join('|')})\b/, Keyword::Pseudo
|
59
|
+
rule %r/macro\b/, Keyword::Reserved
|
60
|
+
rule %r/(string|wstring|dstring|size_t|ptrdiff_t)\b/, Name::Builtin
|
60
61
|
# Literals
|
61
62
|
# HexFloat
|
62
|
-
rule /0[xX]([0-9a-fA-F_]*\.[0-9a-fA-F_]+|[0-9a-fA-F_]+)[pP][+\-]?[0-9_]+[fFL]?[i]?/, Num::Float
|
63
|
+
rule %r/0[xX]([0-9a-fA-F_]*\.[0-9a-fA-F_]+|[0-9a-fA-F_]+)[pP][+\-]?[0-9_]+[fFL]?[i]?/, Num::Float
|
63
64
|
# DecimalFloat
|
64
|
-
rule /[0-9_]+(\.[0-9_]+[eE][+\-]?[0-9_]+|\.[0-9_]*|[eE][+\-]?[0-9_]+)[fFL]?[i]?/, Num::Float
|
65
|
-
rule /\.(0|[1-9][0-9_]*)([eE][+\-]?[0-9_]+)?[fFL]?[i]?/, Num::Float
|
65
|
+
rule %r/[0-9_]+(\.[0-9_]+[eE][+\-]?[0-9_]+|\.[0-9_]*|[eE][+\-]?[0-9_]+)[fFL]?[i]?/, Num::Float
|
66
|
+
rule %r/\.(0|[1-9][0-9_]*)([eE][+\-]?[0-9_]+)?[fFL]?[i]?/, Num::Float
|
66
67
|
# IntegerLiteral
|
67
68
|
# Binary
|
68
|
-
rule /0[Bb][01_]+/, Num::Bin
|
69
|
+
rule %r/0[Bb][01_]+/, Num::Bin
|
69
70
|
# Octal
|
70
71
|
# TODO: 0[0-7] isn't supported use octal![0-7] instead
|
71
|
-
rule /0[0-7_]+/, Num::Oct
|
72
|
+
rule %r/0[0-7_]+/, Num::Oct
|
72
73
|
# Hexadecimal
|
73
|
-
rule /0[xX][0-9a-fA-F_]+/, Num::Hex
|
74
|
+
rule %r/0[xX][0-9a-fA-F_]+/, Num::Hex
|
74
75
|
# Decimal
|
75
|
-
rule /(0|[1-9][0-9_]*)([LUu]|Lu|LU|uL|UL)?/, Num::Integer
|
76
|
+
rule %r/(0|[1-9][0-9_]*)([LUu]|Lu|LU|uL|UL)?/, Num::Integer
|
76
77
|
# CharacterLiteral
|
77
|
-
rule /'(\\['"?\\abfnrtv]|\\x[0-9a-fA-F]{2}|\\[0-7]{1,3}|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}|\\&\w+;|.)'/, Str::Char
|
78
|
+
rule %r/'(\\['"?\\abfnrtv]|\\x[0-9a-fA-F]{2}|\\[0-7]{1,3}|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}|\\&\w+;|.)'/, Str::Char
|
78
79
|
# StringLiteral
|
79
80
|
# WysiwygString
|
80
|
-
rule /r"[^"]*"[cwd]?/, Str
|
81
|
+
rule %r/r"[^"]*"[cwd]?/, Str
|
81
82
|
# Alternate WysiwygString
|
82
|
-
rule /`[^`]*`[cwd]?/, Str
|
83
|
+
rule %r/`[^`]*`[cwd]?/, Str
|
83
84
|
# DoubleQuotedString
|
84
|
-
rule /"(\\\\|\\"|[^"])*"[cwd]?/, Str
|
85
|
+
rule %r/"(\\\\|\\"|[^"])*"[cwd]?/, Str
|
85
86
|
# EscapeSequence
|
86
|
-
rule /\\(['\"?\\abfnrtv]|x[0-9a-fA-F]{2}|[0-7]{1,3}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8}|&\w+;)/, Str
|
87
|
+
rule %r/\\(['\"?\\abfnrtv]|x[0-9a-fA-F]{2}|[0-7]{1,3}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8}|&\w+;)/, Str
|
87
88
|
# HexString
|
88
|
-
rule /x"[0-9a-fA-F_\s]*"[cwd]?/, Str
|
89
|
+
rule %r/x"[0-9a-fA-F_\s]*"[cwd]?/, Str
|
89
90
|
# DelimitedString
|
90
|
-
rule /q"\[/, Str, :delimited_bracket
|
91
|
-
rule /q"\(/, Str, :delimited_parenthesis
|
92
|
-
rule /q"</, Str, :delimited_angle
|
93
|
-
rule /q"\{/, Str, :delimited_curly
|
94
|
-
rule /q"([a-zA-Z_]\w*)\n.*?\n\1"/, Str
|
95
|
-
rule /q"(.).*?\1"/, Str
|
91
|
+
rule %r/q"\[/, Str, :delimited_bracket
|
92
|
+
rule %r/q"\(/, Str, :delimited_parenthesis
|
93
|
+
rule %r/q"</, Str, :delimited_angle
|
94
|
+
rule %r/q"\{/, Str, :delimited_curly
|
95
|
+
rule %r/q"([a-zA-Z_]\w*)\n.*?\n\1"/, Str
|
96
|
+
rule %r/q"(.).*?\1"/, Str
|
96
97
|
# TokenString
|
97
|
-
rule /q\{/, Str, :token_string
|
98
|
+
rule %r/q\{/, Str, :token_string
|
98
99
|
# Attributes
|
99
|
-
rule /@([a-zA-Z_]\w*)?/, Name::Decorator
|
100
|
+
rule %r/@([a-zA-Z_]\w*)?/, Name::Decorator
|
100
101
|
# Tokens
|
101
102
|
rule %r`(~=|\^=|%=|\*=|==|!>=|!<=|!<>=|!<>|!<|!>|!=|>>>=|>>>|>>=|>>|>=|<>=|<>|<<=|<<|<=|\+\+|\+=|--|-=|\|\||\|=|&&|&=|\.\.\.|\.\.|/=)|[/.&|\-+<>!()\[\]{}?,;:$=*%^~]`, Punctuation
|
102
103
|
# Identifier
|
103
|
-
rule /[a-zA-Z_]\w*/, Name
|
104
|
+
rule %r/[a-zA-Z_]\w*/, Name
|
104
105
|
# Line
|
105
|
-
rule /#line\s.*\n/, Comment::Special
|
106
|
+
rule %r/#line\s.*\n/, Comment::Special
|
106
107
|
end
|
107
108
|
|
108
109
|
state :nested_comment do
|
@@ -113,63 +114,63 @@ module Rouge
|
|
113
114
|
end
|
114
115
|
|
115
116
|
state :token_string do
|
116
|
-
rule /\{/, Punctuation, :token_string_nest
|
117
|
-
rule /\}/, Str, :pop!
|
117
|
+
rule %r/\{/, Punctuation, :token_string_nest
|
118
|
+
rule %r/\}/, Str, :pop!
|
118
119
|
mixin :root
|
119
120
|
end
|
120
121
|
|
121
122
|
state :token_string_nest do
|
122
|
-
rule /\{/, Punctuation, :push
|
123
|
-
rule /\}/, Punctuation, :pop!
|
123
|
+
rule %r/\{/, Punctuation, :push
|
124
|
+
rule %r/\}/, Punctuation, :pop!
|
124
125
|
mixin :root
|
125
126
|
end
|
126
127
|
|
127
128
|
state :delimited_bracket do
|
128
|
-
rule /[^\[\]]+/, Str
|
129
|
-
rule /\[/, Str, :delimited_inside_bracket
|
130
|
-
rule /\]"/, Str, :pop!
|
129
|
+
rule %r/[^\[\]]+/, Str
|
130
|
+
rule %r/\[/, Str, :delimited_inside_bracket
|
131
|
+
rule %r/\]"/, Str, :pop!
|
131
132
|
end
|
132
133
|
|
133
134
|
state :delimited_inside_bracket do
|
134
|
-
rule /[^\[\]]+/, Str
|
135
|
-
rule /\[/, Str, :push
|
136
|
-
rule /\]/, Str, :pop!
|
135
|
+
rule %r/[^\[\]]+/, Str
|
136
|
+
rule %r/\[/, Str, :push
|
137
|
+
rule %r/\]/, Str, :pop!
|
137
138
|
end
|
138
139
|
|
139
140
|
state :delimited_parenthesis do
|
140
|
-
rule /[^()]+/, Str
|
141
|
-
rule /\(/, Str, :delimited_inside_parenthesis
|
142
|
-
rule /\)"/, Str, :pop!
|
141
|
+
rule %r/[^()]+/, Str
|
142
|
+
rule %r/\(/, Str, :delimited_inside_parenthesis
|
143
|
+
rule %r/\)"/, Str, :pop!
|
143
144
|
end
|
144
145
|
|
145
146
|
state :delimited_inside_parenthesis do
|
146
|
-
rule /[^()]+/, Str
|
147
|
-
rule /\(/, Str, :push
|
148
|
-
rule /\)/, Str, :pop!
|
147
|
+
rule %r/[^()]+/, Str
|
148
|
+
rule %r/\(/, Str, :push
|
149
|
+
rule %r/\)/, Str, :pop!
|
149
150
|
end
|
150
151
|
|
151
152
|
state :delimited_angle do
|
152
|
-
rule /[^<>]+/, Str
|
153
|
-
rule /</, Str, :delimited_inside_angle
|
154
|
-
rule />"/, Str, :pop!
|
153
|
+
rule %r/[^<>]+/, Str
|
154
|
+
rule %r/</, Str, :delimited_inside_angle
|
155
|
+
rule %r/>"/, Str, :pop!
|
155
156
|
end
|
156
157
|
|
157
158
|
state :delimited_inside_angle do
|
158
|
-
rule /[^<>]+/, Str
|
159
|
-
rule /</, Str, :push
|
160
|
-
rule />/, Str, :pop!
|
159
|
+
rule %r/[^<>]+/, Str
|
160
|
+
rule %r/</, Str, :push
|
161
|
+
rule %r/>/, Str, :pop!
|
161
162
|
end
|
162
163
|
|
163
164
|
state :delimited_curly do
|
164
|
-
rule /[^{}]+/, Str
|
165
|
-
rule /\{/, Str, :delimited_inside_curly
|
166
|
-
rule /\}"/, Str, :pop!
|
165
|
+
rule %r/[^{}]+/, Str
|
166
|
+
rule %r/\{/, Str, :delimited_inside_curly
|
167
|
+
rule %r/\}"/, Str, :pop!
|
167
168
|
end
|
168
169
|
|
169
170
|
state :delimited_inside_curly do
|
170
|
-
rule /[^{}]+/, Str
|
171
|
-
rule /\{/, Str, :push
|
172
|
-
rule /\}/, Str, :pop!
|
171
|
+
rule %r/[^{}]+/, Str
|
172
|
+
rule %r/\{/, Str, :push
|
173
|
+
rule %r/\}/, Str, :pop!
|
173
174
|
end
|
174
175
|
end
|
175
176
|
end
|
data/lib/rouge/lexers/dart.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# -*- coding: utf-8 -*- #
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Rouge
|
4
5
|
module Lexers
|
@@ -29,8 +30,8 @@ module Rouge
|
|
29
30
|
state :root do
|
30
31
|
rule %r(^
|
31
32
|
(\s*(?:[a-zA-Z_][a-zA-Z\d_.\[\]]*\s+)+?) # return arguments
|
32
|
-
([a-zA-Z_]
|
33
|
-
(\s*)(\()
|
33
|
+
([a-zA-Z_]\w*) # method name
|
34
|
+
(\s*)(\() # signature start
|
34
35
|
)mx do |m|
|
35
36
|
# TODO: do this better, this shouldn't need a delegation
|
36
37
|
delegate Dart, m[1]
|
@@ -39,65 +40,65 @@ module Rouge
|
|
39
40
|
token Punctuation, m[4]
|
40
41
|
end
|
41
42
|
|
42
|
-
rule /\s+/, Text
|
43
|
+
rule %r/\s+/, Text
|
43
44
|
rule %r(//.*?$), Comment::Single
|
44
45
|
rule %r(/\*.*?\*/)m, Comment::Multiline
|
45
|
-
rule /"/, Str, :dqs
|
46
|
-
rule /'/, Str, :sqs
|
47
|
-
rule /r"[^"]*"/, Str::Other
|
48
|
-
rule /r'[^']*'/, Str::Other
|
49
|
-
rule /##{id}*/i, Str::Symbol
|
50
|
-
rule /@#{id}/, Name::Decorator
|
51
|
-
rule /(?:#{keywords.join('|')})\b/, Keyword
|
52
|
-
rule /(?:#{declarations.join('|')})\b/, Keyword::Declaration
|
53
|
-
rule /(?:#{types.join('|')})\b/, Keyword::Type
|
54
|
-
rule /(?:true|false|null)\b/, Keyword::Constant
|
55
|
-
rule /(?:class|interface)\b/, Keyword::Declaration, :class
|
56
|
-
rule /(?:#{imports.join('|')})\b/, Keyword::Namespace, :import
|
57
|
-
rule /(\.)(#{id})/ do
|
46
|
+
rule %r/"/, Str, :dqs
|
47
|
+
rule %r/'/, Str, :sqs
|
48
|
+
rule %r/r"[^"]*"/, Str::Other
|
49
|
+
rule %r/r'[^']*'/, Str::Other
|
50
|
+
rule %r/##{id}*/i, Str::Symbol
|
51
|
+
rule %r/@#{id}/, Name::Decorator
|
52
|
+
rule %r/(?:#{keywords.join('|')})\b/, Keyword
|
53
|
+
rule %r/(?:#{declarations.join('|')})\b/, Keyword::Declaration
|
54
|
+
rule %r/(?:#{types.join('|')})\b/, Keyword::Type
|
55
|
+
rule %r/(?:true|false|null)\b/, Keyword::Constant
|
56
|
+
rule %r/(?:class|interface)\b/, Keyword::Declaration, :class
|
57
|
+
rule %r/(?:#{imports.join('|')})\b/, Keyword::Namespace, :import
|
58
|
+
rule %r/(\.)(#{id})/ do
|
58
59
|
groups Operator, Name::Attribute
|
59
60
|
end
|
60
61
|
|
61
|
-
rule /#{id}:/, Name::Label
|
62
|
-
rule /\$?#{id}/, Name
|
63
|
-
rule /[~^*!%&\[\](){}<>\|+=:;,.\/?-]/, Operator
|
64
|
-
rule /\d*\.\d+([eE]\-?\d+)?/, Num::Float
|
65
|
-
rule /0x[\da-fA-F]+/, Num::Hex
|
66
|
-
rule /\d+L?/, Num::Integer
|
67
|
-
rule /\n/, Text
|
62
|
+
rule %r/#{id}:/, Name::Label
|
63
|
+
rule %r/\$?#{id}/, Name
|
64
|
+
rule %r/[~^*!%&\[\](){}<>\|+=:;,.\/?-]/, Operator
|
65
|
+
rule %r/\d*\.\d+([eE]\-?\d+)?/, Num::Float
|
66
|
+
rule %r/0x[\da-fA-F]+/, Num::Hex
|
67
|
+
rule %r/\d+L?/, Num::Integer
|
68
|
+
rule %r/\n/, Text
|
68
69
|
end
|
69
70
|
|
70
71
|
state :class do
|
71
|
-
rule /\s+/m, Text
|
72
|
+
rule %r/\s+/m, Text
|
72
73
|
rule id, Name::Class, :pop!
|
73
74
|
end
|
74
75
|
|
75
76
|
state :dqs do
|
76
|
-
rule /"/, Str, :pop!
|
77
|
-
rule /[^\\\$"]+/, Str
|
77
|
+
rule %r/"/, Str, :pop!
|
78
|
+
rule %r/[^\\\$"]+/, Str
|
78
79
|
mixin :string
|
79
80
|
end
|
80
81
|
|
81
82
|
state :sqs do
|
82
|
-
rule /'/, Str, :pop!
|
83
|
-
rule /[^\\\$']+/, Str
|
83
|
+
rule %r/'/, Str, :pop!
|
84
|
+
rule %r/[^\\\$']+/, Str
|
84
85
|
mixin :string
|
85
86
|
end
|
86
87
|
|
87
88
|
state :import do
|
88
|
-
rule /;/, Operator, :pop!
|
89
|
-
rule /(?:show|hide)\b/, Keyword::Declaration
|
89
|
+
rule %r/;/, Operator, :pop!
|
90
|
+
rule %r/(?:show|hide)\b/, Keyword::Declaration
|
90
91
|
mixin :root
|
91
92
|
end
|
92
93
|
|
93
94
|
state :string do
|
94
95
|
mixin :interpolation
|
95
|
-
rule /\\[nrt\"\'\\]/, Str::Escape
|
96
|
+
rule %r/\\[nrt\"\'\\]/, Str::Escape
|
96
97
|
end
|
97
98
|
|
98
99
|
state :interpolation do
|
99
|
-
rule /\$#{id}/, Str::Interpol
|
100
|
-
rule /\$\{[^\}]+\}/, Str::Interpol
|
100
|
+
rule %r/\$#{id}/, Str::Interpol
|
101
|
+
rule %r/\$\{[^\}]+\}/, Str::Interpol
|
101
102
|
end
|
102
103
|
end
|
103
104
|
end
|
@@ -0,0 +1,138 @@
|
|
1
|
+
# -*- coding: utf-8 -*- #
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Rouge
|
5
|
+
module Lexers
|
6
|
+
class Datastudio < RegexLexer
|
7
|
+
tag 'datastudio'
|
8
|
+
filenames '*.job'
|
9
|
+
mimetypes 'text/x-datastudio'
|
10
|
+
|
11
|
+
title "Datastudio"
|
12
|
+
desc 'Datastudio scripting language'
|
13
|
+
|
14
|
+
id = /@?[_a-z]\w*/i
|
15
|
+
|
16
|
+
def self.sql_keywords
|
17
|
+
@sql_keywords ||= %w(
|
18
|
+
ABORT ABS ABSOLUTE ACCESS ADA ADD ADMIN AFTER AGGREGATE ALIAS
|
19
|
+
ALL ALLOCATE ALTER ANALYSE ANALYZE AND ANY ARE AS ASC ASENSITIVE
|
20
|
+
ASSERTION ASSIGNMENT ASYMMETRIC AT ATOMIC AUTHORIZATION
|
21
|
+
AVG BACKWARD BEFORE BEGIN BETWEEN BITVAR BIT_LENGTH BOTH
|
22
|
+
BREADTH BY C CACHE CALL CALLED CARDINALITY CASCADE CASCADED
|
23
|
+
CASE CAST CATALOG CATALOG_NAME CHAIN CHARACTERISTICS
|
24
|
+
CHARACTER_LENGTH CHARACTER_SET_CATALOG CHARACTER_SET_NAME
|
25
|
+
CHARACTER_SET_SCHEMA CHAR_LENGTH CHECK CHECKED CHECKPOINT
|
26
|
+
CLASS CLASS_ORIGIN CLOB CLOSE CLUSTER COALSECE COBOL COLLATE
|
27
|
+
COLLATION COLLATION_CATALOG COLLATION_NAME COLLATION_SCHEMA
|
28
|
+
COLUMN COLUMN_NAME COMMAND_FUNCTION COMMAND_FUNCTION_CODE
|
29
|
+
COMMENT COMMIT COMMITTED COMPLETION CONDITION_NUMBER
|
30
|
+
CONNECT CONNECTION CONNECTION_NAME CONSTRAINT CONSTRAINTS
|
31
|
+
CONSTRAINT_CATALOG CONSTRAINT_NAME CONSTRAINT_SCHEMA
|
32
|
+
CONSTRUCTOR CONTAINS CONTINUE CONVERSION CONVERT COPY
|
33
|
+
CORRESPONTING COUNT CREATE CREATEDB CREATEUSER CROSS CUBE
|
34
|
+
CURRENT CURRENT_DATE CURRENT_PATH CURRENT_ROLE CURRENT_TIME
|
35
|
+
CURRENT_TIMESTAMP CURRENT_USER CURSOR CURSOR_NAME CYCLE DATA
|
36
|
+
DATABASE DATETIME_INTERVAL_CODE DATETIME_INTERVAL_PRECISION
|
37
|
+
DAY DEALLOCATE DECLARE DEFAULT DEFAULTS DEFERRABLE DEFERRED
|
38
|
+
DEFINED DEFINER DELETE DELIMITER DELIMITERS DEREF DESC DESCRIBE
|
39
|
+
DESCRIPTOR DESTROY DESTRUCTOR DETERMINISTIC DIAGNOSTICS
|
40
|
+
DICTIONARY DISCONNECT DISPATCH DISTINCT DO DOMAIN DROP
|
41
|
+
DYNAMIC DYNAMIC_FUNCTION DYNAMIC_FUNCTION_CODE EACH ELSE
|
42
|
+
ENCODING ENCRYPTED END END-EXEC EQUALS ESCAPE EVERY EXCEPT
|
43
|
+
ESCEPTION EXCLUDING EXCLUSIVE EXEC EXECUTE EXISTING EXISTS
|
44
|
+
EXPLAIN EXTERNAL EXTRACT FALSE FETCH FINAL FIRST FOR FORCE
|
45
|
+
FOREIGN FORTRAN FORWARD FOUND FREE FREEZE FROM FULL FUNCTION
|
46
|
+
G GENERAL GENERATED GET GLOBAL GO GOTO GRANT GRANTED GROUP
|
47
|
+
GROUPING HANDLER HAVING HIERARCHY HOLD HOST IDENTITY IGNORE
|
48
|
+
ILIKE IMMEDIATE IMMUTABLE IMPLEMENTATION IMPLICIT IN INCLUDING
|
49
|
+
INCREMENT INDEX INDITCATOR INFIX INHERITS INITIALIZE INITIALLY
|
50
|
+
INNER INOUT INPUT INSENSITIVE INSERT INSTANTIABLE INSTEAD
|
51
|
+
INTERSECT INTO INVOKER IS ISNULL ISOLATION ITERATE JOIN KEY
|
52
|
+
KEY_MEMBER KEY_TYPE LANCOMPILER LANGUAGE LARGE LAST LATERAL
|
53
|
+
LEADING LEFT LENGTH LESS LEVEL LIKE LIMIT LISTEN LOAD LOCAL
|
54
|
+
LOCALTIME LOCALTIMESTAMP LOCATION LOCATOR LOCK LOWER MAP MATCH
|
55
|
+
MAX MAXVALUE MESSAGE_LENGTH MESSAGE_OCTET_LENGTH MESSAGE_TEXT
|
56
|
+
METHOD MIN MINUTE MINVALUE MOD MODE MODIFIES MODIFY MONTH
|
57
|
+
MORE MOVE MUMPS NAMES NATURAL NCLOB NEW NEXT
|
58
|
+
NO NOCREATEDB NOCREATEUSER NONE NOT NOTHING NOTIFY NOTNULL
|
59
|
+
NULL NULLABLE NULLIF OBJECT OCTET_LENGTH OF OFF OFFSET OIDS
|
60
|
+
OLD ON ONLY OPEN OPERATION OPERATOR OPTION OPTIONS OR ORDER
|
61
|
+
ORDINALITY OUT OUTER OUTPUT OVERLAPS OVERLAY OVERRIDING
|
62
|
+
OWNER PAD PARAMETER PARAMETERS PARAMETER_MODE PARAMATER_NAME
|
63
|
+
PARAMATER_ORDINAL_POSITION PARAMETER_SPECIFIC_CATALOG
|
64
|
+
PARAMETER_SPECIFIC_NAME PARAMATER_SPECIFIC_SCHEMA PARTIAL PASCAL
|
65
|
+
PENDANT PLACING PLI POSITION POSTFIX PREFIX PREORDER
|
66
|
+
PREPARE PRESERVE PRIMARY PRIOR PRIVILEGES PROCEDURAL PROCEDURE
|
67
|
+
PUBLIC READ READS RECHECK RECURSIVE REF REFERENCES REFERENCING
|
68
|
+
REINDEX RELATIVE RENAME REPEATABLE REPLACE RESET RESTART
|
69
|
+
RESTRICT RESULT RETURN RETURNED_LENGTH RETURNED_OCTET_LENGTH
|
70
|
+
RETURNED_SQLSTATE RETURNS REVOKE RIGHT ROLE ROLLBACK ROLLUP
|
71
|
+
ROUTINE ROUTINE_CATALOG ROUTINE_NAME ROUTINE_SCHEMA ROW ROWS
|
72
|
+
ROW_COUNT RULE SAVE_POINT SCALE SCHEMA SCHEMA_NAME SCOPE SCROLL
|
73
|
+
SEARCH SECOND SECURITY SELECT SELF SENSITIVE SERIALIZABLE
|
74
|
+
SERVER_NAME SESSION SESSION_USER SET SETOF SETS SHARE SHOW
|
75
|
+
SIMILAR SIMPLE SIZE SOME SOURCE SPACE SPECIFIC SPECIFICTYPE
|
76
|
+
SPECIFIC_NAME SQL SQLCODE SQLERROR SQLEXCEPTION SQLSTATE
|
77
|
+
SQLWARNINIG STABLE START STATE STATEMENT STATIC STATISTICS
|
78
|
+
STDIN STDOUT STORAGE STRICT STRUCTURE STYPE SUBCLASS_ORIGIN
|
79
|
+
SUBLIST SUBSTRING SUM SYMMETRIC SYSID SYSTEM SYSTEM_USER
|
80
|
+
TABLE TABLE_NAME TEMP TEMPLATE TEMPORARY TERMINATE THAN THEN
|
81
|
+
TIMEZONE_HOUR TIMEZONE_MINUTE TO TOAST TRAILING
|
82
|
+
TRANSATION TRANSACTIONS_COMMITTED TRANSACTIONS_ROLLED_BACK
|
83
|
+
TRANSATION_ACTIVE TRANSFORM TRANSFORMS TRANSLATE TRANSLATION
|
84
|
+
TREAT TRIGGER TRIGGER_CATALOG TRIGGER_NAME TRIGGER_SCHEMA TRIM
|
85
|
+
TRUE TRUNCATE TRUSTED TYPE UNCOMMITTED UNDER UNENCRYPTED UNION
|
86
|
+
UNIQUE UNKNOWN UNLISTEN UNNAMED UNNEST UNTIL UPDATE UPPER
|
87
|
+
USAGE USER USER_DEFINED_TYPE_CATALOG USER_DEFINED_TYPE_NAME
|
88
|
+
USER_DEFINED_TYPE_SCHEMA USING VACUUM VALID VALIDATOR VALUES
|
89
|
+
VARIABLE VERBOSE VERSION VIEW VOLATILE WHEN WHENEVER WHERE
|
90
|
+
WITH WITHOUT WORK WRITE ZONE
|
91
|
+
)
|
92
|
+
end
|
93
|
+
|
94
|
+
state :whitespace do
|
95
|
+
rule %r/\s+/m, Text
|
96
|
+
rule %r(//.*?$), Comment::Single
|
97
|
+
rule %r(/[*].*?[*]/)m, Comment::Multiline
|
98
|
+
end
|
99
|
+
|
100
|
+
state :string do
|
101
|
+
rule %r/%(\\.|.)+?%/, Str::Escape
|
102
|
+
rule %r/\\"/, Str::Double
|
103
|
+
rule %r/"/, Str::Double, :pop!
|
104
|
+
rule %r/./m, Str::Double
|
105
|
+
end
|
106
|
+
|
107
|
+
state :string_s do
|
108
|
+
rule %r/%(\\.|.)+?%/, Str::Escape
|
109
|
+
rule %r/\\'/, Str::Single
|
110
|
+
rule %r/'/, Str::Single, :pop!
|
111
|
+
rule %r/./m, Str::Single
|
112
|
+
end
|
113
|
+
|
114
|
+
state :root do
|
115
|
+
mixin :whitespace
|
116
|
+
|
117
|
+
rule %r/^:#{id}/, Name::Label
|
118
|
+
rule %r/@#{id}(\.#{id})?/m, Name::Entity
|
119
|
+
rule %r/%(\\.|.)+?%/, Name::Variable
|
120
|
+
rule %r/[~!%^&*()+=|\[\]{}:;,.<>\/?-]/, Punctuation
|
121
|
+
rule %r/"/, Str::Double, :string
|
122
|
+
rule %r/'/, Str::Single, :string_s
|
123
|
+
rule %r/\d(\.\d*)?/i, Num
|
124
|
+
rule %r/#{id}(?=\s*[(])/, Name::Function
|
125
|
+
rule id do |m|
|
126
|
+
name = m[0].upcase
|
127
|
+
|
128
|
+
if self.class.sql_keywords.include? name
|
129
|
+
token Keyword
|
130
|
+
else
|
131
|
+
token Name
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|