rouge_ecl 0.0.1 → 1.0.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.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -4
  3. data/lib/rouge.rb +7 -9
  4. data/lib/rouge/cli.rb +2 -36
  5. data/lib/rouge/guessers/glob_mapping.rb +6 -3
  6. data/lib/rouge/guessers/modeline.rb +3 -4
  7. data/lib/rouge/guessers/source.rb +16 -6
  8. data/lib/rouge/lexer.rb +11 -20
  9. data/lib/rouge/lexers/apiblueprint.rb +4 -0
  10. data/lib/rouge/lexers/awk.rb +2 -2
  11. data/lib/rouge/lexers/biml.rb +2 -2
  12. data/lib/rouge/lexers/c.rb +6 -1
  13. data/lib/rouge/lexers/coffeescript.rb +2 -2
  14. data/lib/rouge/lexers/coq.rb +4 -0
  15. data/lib/rouge/lexers/diff.rb +4 -4
  16. data/lib/rouge/lexers/digdag.rb +4 -0
  17. data/lib/rouge/lexers/ecl.rb +32 -20
  18. data/lib/rouge/lexers/erb.rb +4 -0
  19. data/lib/rouge/lexers/erlang.rb +4 -0
  20. data/lib/rouge/lexers/factor.rb +2 -2
  21. data/lib/rouge/lexers/fsharp.rb +1 -1
  22. data/lib/rouge/lexers/gherkin.rb +2 -2
  23. data/lib/rouge/lexers/go.rb +4 -0
  24. data/lib/rouge/lexers/groovy.rb +2 -2
  25. data/lib/rouge/lexers/haml.rb +4 -0
  26. data/lib/rouge/lexers/haskell.rb +5 -4
  27. data/lib/rouge/lexers/html.rb +5 -6
  28. data/lib/rouge/lexers/idlang.rb +6 -0
  29. data/lib/rouge/lexers/ini.rb +4 -0
  30. data/lib/rouge/lexers/io.rb +2 -2
  31. data/lib/rouge/lexers/javascript.rb +2 -2
  32. data/lib/rouge/lexers/julia.rb +2 -2
  33. data/lib/rouge/lexers/kotlin.rb +15 -10
  34. data/lib/rouge/lexers/lasso.rb +6 -3
  35. data/lib/rouge/lexers/llvm.rb +4 -0
  36. data/lib/rouge/lexers/lua.rb +2 -2
  37. data/lib/rouge/lexers/make.rb +4 -0
  38. data/lib/rouge/lexers/matlab.rb +4 -0
  39. data/lib/rouge/lexers/moonscript.rb +2 -2
  40. data/lib/rouge/lexers/mosel.rb +3 -3
  41. data/lib/rouge/lexers/nasm.rb +5 -0
  42. data/lib/rouge/lexers/objective_c.rb +14 -0
  43. data/lib/rouge/lexers/perl.rb +4 -3
  44. data/lib/rouge/lexers/php.rb +6 -6
  45. data/lib/rouge/lexers/plist.rb +4 -0
  46. data/lib/rouge/lexers/powershell.rb +1 -1
  47. data/lib/rouge/lexers/praat.rb +2 -2
  48. data/lib/rouge/lexers/prolog.rb +5 -0
  49. data/lib/rouge/lexers/properties.rb +4 -0
  50. data/lib/rouge/lexers/puppet.rb +3 -3
  51. data/lib/rouge/lexers/python.rb +2 -3
  52. data/lib/rouge/lexers/q.rb +4 -0
  53. data/lib/rouge/lexers/r.rb +2 -2
  54. data/lib/rouge/lexers/racket.rb +4 -5
  55. data/lib/rouge/lexers/ruby.rb +3 -3
  56. data/lib/rouge/lexers/rust.rb +4 -4
  57. data/lib/rouge/lexers/sass.rb +3 -3
  58. data/lib/rouge/lexers/scheme.rb +2 -2
  59. data/lib/rouge/lexers/scss.rb +2 -2
  60. data/lib/rouge/lexers/sed.rb +2 -2
  61. data/lib/rouge/lexers/shell.rb +9 -18
  62. data/lib/rouge/lexers/smarty.rb +11 -0
  63. data/lib/rouge/lexers/sml.rb +4 -0
  64. data/lib/rouge/lexers/swift.rb +1 -21
  65. data/lib/rouge/lexers/tap.rb +4 -0
  66. data/lib/rouge/lexers/tcl.rb +4 -4
  67. data/lib/rouge/lexers/tex.rb +2 -2
  68. data/lib/rouge/lexers/toml.rb +4 -0
  69. data/lib/rouge/lexers/tulip.rb +3 -2
  70. data/lib/rouge/lexers/turtle.rb +14 -5
  71. data/lib/rouge/lexers/vue.rb +6 -4
  72. data/lib/rouge/lexers/wollok.rb +4 -0
  73. data/lib/rouge/lexers/xml.rb +6 -4
  74. data/lib/rouge/lexers/yaml.rb +2 -2
  75. data/lib/rouge/version.rb +1 -1
  76. data/rouge.gemspec +1 -6
  77. metadata +4 -13
  78. data/lib/rouge/demos/ecl +0 -1
  79. data/lib/rouge/demos/elm +0 -4
  80. data/lib/rouge/demos/hack +0 -5
  81. data/lib/rouge/guessers/disambiguation.rb +0 -101
  82. data/lib/rouge/guessers/util.rb +0 -32
  83. data/lib/rouge/lexers/elm.rb +0 -89
  84. data/lib/rouge/lexers/hack.rb +0 -48
@@ -75,10 +75,10 @@ module Rouge
75
75
  )
76
76
  end
77
77
 
78
- def self.detect?(text)
79
- return true if text.shebang?('php')
80
- return false if /^<\?hh/ =~ text
81
- return true if /^<\?php/ =~ text
78
+ def self.analyze_text(text)
79
+ return 1 if text.shebang?('php')
80
+ return 0.3 if /<\?(?!xml)/ =~ text
81
+ 0
82
82
  end
83
83
 
84
84
  state :root do
@@ -99,8 +99,8 @@ module Rouge
99
99
  # heredocs
100
100
  rule /<<<('?)(#{id})\1\n.*?\n\2;?\n/im, Str::Heredoc
101
101
  rule /\s+/, Text
102
- rule /#.*?$/, Comment::Single
103
- rule %r(//.*?$), Comment::Single
102
+ rule /#.*?\n/, Comment::Single
103
+ rule %r(//.*?\n), Comment::Single
104
104
  # empty comment, otherwise seen as the start of a docstring
105
105
  rule %r(/\*\*/), Comment::Multiline
106
106
  rule %r(/\*\*.*?\*/)m, Str::Doc
@@ -8,6 +8,10 @@ module Rouge
8
8
 
9
9
  mimetypes 'text/x-plist', 'application/x-plist'
10
10
 
11
+ def self.analyze_text(text)
12
+ return 0.6 if text.start_with?("// !$*UTF8*$!")
13
+ end
14
+
11
15
  state :whitespace do
12
16
  rule /\s+/, Text::Whitespace
13
17
  end
@@ -9,7 +9,7 @@ module Rouge
9
9
  desc 'powershell'
10
10
  tag 'powershell'
11
11
  aliases 'posh'
12
- filenames '*.ps1', '*.psm1', '*.psd1', '*.psrc', '*.pssc'
12
+ filenames '*.ps1', '*.psm1', '*.psd1'
13
13
  mimetypes 'text/x-powershell'
14
14
 
15
15
  ATTRIBUTES = %w(
@@ -10,8 +10,8 @@ module Rouge
10
10
 
11
11
  filenames '*.praat', '*.proc', '*.psc'
12
12
 
13
- def self.detect?(text)
14
- return true if text.shebang? 'praat'
13
+ def self.analyze_text(text)
14
+ return 1 if text.shebang? 'praat'
15
15
  end
16
16
 
17
17
  keywords = %w(
@@ -10,6 +10,11 @@ module Rouge
10
10
  filenames '*.pro', '*.P', '*.prolog', '*.pl'
11
11
  mimetypes 'text/x-prolog'
12
12
 
13
+ def self.analyze_text(text)
14
+ return 0.1 if text =~ /\A\w+(\(\w+\,\s*\w+\))*\./
15
+ return 0.1 if text.include? ':-'
16
+ end
17
+
13
18
  state :basic do
14
19
  rule /\s+/, Text
15
20
  rule /^#.*/, Comment::Single
@@ -10,6 +10,10 @@ module Rouge
10
10
  filenames '*.properties'
11
11
  mimetypes 'text/x-java-properties'
12
12
 
13
+ def self.analyze_text(text)
14
+ return 0.1 if text =~ /\A\[[\w.-]+\]\s*\w+=\w+/
15
+ end
16
+
13
17
  identifier = /[\w.-]+/
14
18
 
15
19
  state :basic do
@@ -9,9 +9,9 @@ module Rouge
9
9
  aliases 'pp'
10
10
  filenames '*.pp'
11
11
 
12
- def self.detect?(text)
13
- return true if text.shebang? 'puppet-apply'
14
- return true if text.shebang? 'puppet'
12
+ def self.analyze_text(text)
13
+ return 1 if text.shebang? 'puppet-apply'
14
+ return 1 if text.shebang? 'puppet'
15
15
  end
16
16
 
17
17
  def self.keywords
@@ -10,8 +10,8 @@ module Rouge
10
10
  filenames '*.py', '*.pyw', '*.sc', 'SConstruct', 'SConscript', '*.tac'
11
11
  mimetypes 'text/x-python', 'application/x-python'
12
12
 
13
- def self.detect?(text)
14
- return true if text.shebang?(/pythonw?(3|2(\.\d)?)?/)
13
+ def self.analyze_text(text)
14
+ return 1 if text.shebang?(/pythonw?(3|2(\.\d)?)?/)
15
15
  end
16
16
 
17
17
  def self.keywords
@@ -19,7 +19,6 @@ module Rouge
19
19
  assert break continue del elif else except exec
20
20
  finally for global if lambda pass print raise
21
21
  return try while yield as with from import yield
22
- async await
23
22
  )
24
23
  end
25
24
 
@@ -32,6 +32,10 @@ module Rouge
32
32
  ]
33
33
  end
34
34
 
35
+ def self.analyze_text(text)
36
+ return 0
37
+ end
38
+
35
39
  state :root do
36
40
  # q allows a file to start with a shebang
37
41
  rule /#!(.*?)$/, Comment::Preproc, :top
@@ -43,8 +43,8 @@ module Rouge
43
43
  trigamma trunc unclass untracemem UseMethod xtfrm
44
44
  )
45
45
 
46
- def self.detect?(text)
47
- return true if text.shebang? 'Rscript'
46
+ def self.analyze_text(text)
47
+ return 1 if text.shebang? 'Rscript'
48
48
  end
49
49
 
50
50
  state :root do
@@ -9,11 +9,10 @@ module Rouge
9
9
  filenames '*.rkt', '*.rktd', '*.rktl'
10
10
  mimetypes 'text/x-racket', 'application/x-racket'
11
11
 
12
- def self.detect?(text)
13
- text =~ /\A#lang\s*(.*?)$/
14
- lang_attr = $1
15
- return false unless lang_attr
16
- return true if lang_attr =~ /racket|scribble/
12
+ def self.analyze_text(text)
13
+ text = text.strip
14
+ return 1 if text.start_with? '#lang racket'
15
+ return 0.6 if text =~ %r(\A#lang [a-z/-]+$)i
17
16
  end
18
17
 
19
18
  def self.keywords
@@ -9,12 +9,12 @@ module Rouge
9
9
  aliases 'rb'
10
10
  filenames '*.rb', '*.ruby', '*.rbw', '*.rake', '*.gemspec', '*.podspec',
11
11
  'Rakefile', 'Guardfile', 'Gemfile', 'Capfile', 'Podfile',
12
- 'Vagrantfile', '*.ru', '*.prawn', 'Berksfile', '*.arb'
12
+ 'Vagrantfile', '*.ru', '*.prawn', 'Berksfile'
13
13
 
14
14
  mimetypes 'text/x-ruby', 'application/x-ruby'
15
15
 
16
- def self.detect?(text)
17
- return true if text.shebang? 'ruby'
16
+ def self.analyze_text(text)
17
+ return 1 if text.shebang? 'ruby'
18
18
  end
19
19
 
20
20
  state :symbols do
@@ -10,16 +10,16 @@ module Rouge
10
10
  filenames '*.rs'
11
11
  mimetypes 'text/x-rust'
12
12
 
13
- def self.detect?(text)
14
- return true if text.shebang? 'rustc'
13
+ def self.analyze_text(text)
14
+ return 1 if text.shebang? 'rustc'
15
15
  end
16
16
 
17
17
  def self.keywords
18
18
  @keywords ||= %w(
19
19
  as assert break const copy do drop else enum extern fail false
20
20
  fn for if impl let log loop match mod move mut priv pub pure
21
- ref return self static struct true trait type unsafe use where
22
- while box
21
+ ref return self static struct true trait type unsafe use while
22
+ box
23
23
  )
24
24
  end
25
25
 
@@ -23,7 +23,7 @@ module Rouge
23
23
 
24
24
  state :content do
25
25
  # block comments
26
- rule %r(//.*?$) do
26
+ rule %r(//.*?\n) do
27
27
  token Comment::Single
28
28
  pop!; starts_block :single_comment
29
29
  end
@@ -42,13 +42,13 @@ module Rouge
42
42
 
43
43
  rule /:/, Name::Attribute, :old_style_attr
44
44
 
45
- rule(/(?=[^\[\n]+?:([^a-z]|$))/) { push :attribute }
45
+ rule(/(?=.+?:([^a-z]|$))/) { push :attribute }
46
46
 
47
47
  rule(//) { push :selector }
48
48
  end
49
49
 
50
50
  state :single_comment do
51
- rule /.*?$/, Comment::Single, :pop!
51
+ rule /.*?\n/, Comment::Single, :pop!
52
52
  end
53
53
 
54
54
  state :multi_comment do
@@ -85,8 +85,8 @@ module Rouge
85
85
  groups Str::Symbol, Text, Punctuation
86
86
  end
87
87
 
88
- rule /\(|\[/, Punctuation, :command
89
- rule /\)|\]/, Punctuation
88
+ rule /\(/, Punctuation, :command
89
+ rule /\)/, Punctuation
90
90
 
91
91
  rule id, Name::Variable
92
92
  end
@@ -13,14 +13,14 @@ module Rouge
13
13
 
14
14
  state :root do
15
15
  rule /\s+/, Text
16
- rule %r(//.*?$), Comment::Single
16
+ rule %r(//.*?\n), Comment::Single
17
17
  rule %r(/[*].*?[*]/)m, Comment::Multiline
18
18
  rule /@import\b/, Keyword, :value
19
19
 
20
20
  mixin :content_common
21
21
 
22
22
  rule(/(?=[^;{}][;}])/) { push :attribute }
23
- rule(/(?=[^;{}:\[]+:[^a-z])/) { push :attribute }
23
+ rule(/(?=[^;{}:]+:[^a-z])/) { push :attribute }
24
24
 
25
25
  rule(//) { push :selector }
26
26
  end
@@ -10,8 +10,8 @@ module Rouge
10
10
  filenames '*.sed'
11
11
  mimetypes 'text/x-sed'
12
12
 
13
- def self.detect?(text)
14
- return true if text.shebang? 'sed'
13
+ def self.analyze_text(text)
14
+ return 1 if text.shebang? 'sed'
15
15
  end
16
16
 
17
17
  class Regex < RegexLexer
@@ -13,8 +13,8 @@ module Rouge
13
13
 
14
14
  mimetypes 'application/x-sh', 'application/x-shellscript'
15
15
 
16
- def self.detect?(text)
17
- return true if text.shebang?(/(ba|z|k)?sh/)
16
+ def self.analyze_text(text)
17
+ text.shebang?(/(ba|z|k)?sh/) ? 1 : 0
18
18
  end
19
19
 
20
20
  KEYWORDS = %w(
@@ -24,22 +24,13 @@ module Rouge
24
24
 
25
25
  BUILTINS = %w(
26
26
  alias bg bind break builtin caller cd command compgen
27
- complete declare dirs disown enable eval exec exit
28
- export false fc fg getopts hash help history jobs let
29
- local logout mapfile popd pushd pwd read readonly set
30
- shift shopt source suspend test time times trap true type
31
- typeset ulimit umask unalias unset wait
32
-
33
- cat tac nl od base32 base64 fmt pr fold head tail split csplit
34
- wc sum cksum b2sum md5sum sha1sum sha224sum sha256sum sha384sum
35
- sha512sum sort shuf uniq comm ptx tsort cut paste join tr expand
36
- unexpand ls dir vdir dircolors cp dd install mv rm shred link ln
37
- mkdir mkfifo mknod readlink rmdir unlink chown chgrp chmod touch
38
- df du stat sync truncate echo printf yes expr tee basename dirname
39
- pathchk mktemp realpath pwd stty printenv tty id logname whoami
40
- groups users who date arch nproc uname hostname hostid uptime chcon
41
- runcon chroot env nice nohup stdbuf timeout kill sleep factor numfmt
42
- seq tar grep sudo awk sed gzip gunzip
27
+ complete declare dirs disown echo enable eval exec exit
28
+ export false fc fg getopts hash help history jobs kill let
29
+ local logout popd printf pushd pwd read readonly set shift
30
+ shopt source suspend test time times trap true type typeset
31
+ ulimit umask unalias unset wait
32
+
33
+ ls tar cat grep sudo
43
34
  ).join('|')
44
35
 
45
36
  state :basic do
@@ -10,6 +10,17 @@ module Rouge
10
10
  filenames '*.tpl', '*.smarty'
11
11
  mimetypes 'application/x-smarty', 'text/x-smarty'
12
12
 
13
+ def self.analyze_text(text)
14
+ rv = 0.0
15
+ rv += 0.15 if text =~ /\{if\s+.*?\}.*?\{\/if\}/
16
+ rv += 0.15 if text =~ /\{include\s+file=.*?\}/
17
+ rv += 0.15 if text =~ /\{foreach\s+.*?\}.*?\{\/foreach\}/
18
+ rv += 0.01 if text =~ /\{\$.*?\}/
19
+ return rv
20
+ end
21
+
22
+
23
+
13
24
  def self.builtins
14
25
  @builtins ||= %w(
15
26
  append assign block call capture config_load debug extends
@@ -28,6 +28,10 @@ module Rouge
28
28
  id = /[\w']+/i
29
29
  symbol = %r([!%&$#/:<=>?@\\~`^|*+-]+)
30
30
 
31
+ def self.analyze_text(text)
32
+ return 0
33
+ end
34
+
31
35
  state :whitespace do
32
36
  rule /\s+/m, Text
33
37
  rule /[(][*]/, Comment, :comment
@@ -66,7 +66,7 @@ module Rouge
66
66
  mixin :whitespace
67
67
  rule /\$(([1-9]\d*)?\d)/, Name::Variable
68
68
 
69
- rule %r{[()\[\]{}:;,?\\]}, Punctuation
69
+ rule %r{[()\[\]{}:;,?]}, Punctuation
70
70
  rule %r([-/=+*%<>!&|^.~]+), Operator
71
71
  rule /@?"/, Str, :dq
72
72
  rule /'(\\.|.)'/, Str::Char
@@ -107,11 +107,6 @@ module Rouge
107
107
  groups Keyword, Text, Name::Variable
108
108
  end
109
109
 
110
- rule /(let|var)\b(\s*)([(])/ do
111
- groups Keyword, Text, Punctuation
112
- push :tuple
113
- end
114
-
115
110
  rule /(?!\b(if|while|for|private|internal|unowned|switch|case)\b)\b#{id}(?=(\?|!)?\s*[(])/ do |m|
116
111
  if m[0] =~ /^[[:upper:]]/
117
112
  token Keyword::Type
@@ -140,21 +135,6 @@ module Rouge
140
135
  token Name
141
136
  end
142
137
  end
143
-
144
- rule /(`)(#{id})(`)/ do
145
- groups Punctuation, Name::Variable, Punctuation
146
- end
147
- end
148
-
149
- state :tuple do
150
- rule /(#{id})/, Name::Variable
151
- rule /(`)(#{id})(`)/ do
152
- groups Punctuation, Name::Variable, Punctuation
153
- end
154
- rule /,/, Punctuation
155
- rule /[(]/, Punctuation, :push
156
- rule /[)]/, Punctuation, :pop!
157
- mixin :inline_whitespace
158
138
  end
159
139
 
160
140
  state :dq do
@@ -9,6 +9,10 @@ module Rouge
9
9
 
10
10
  mimetypes 'text/x-tap', 'application/x-tap'
11
11
 
12
+ def self.analyze_text(text)
13
+ return 0
14
+ end
15
+
12
16
  state :root do
13
17
  # A TAP version may be specified.
14
18
  rule /^TAP version \d+\n/, Name::Namespace
@@ -9,10 +9,10 @@ module Rouge
9
9
  filenames '*.tcl'
10
10
  mimetypes 'text/x-tcl', 'text/x-script.tcl', 'application/x-tcl'
11
11
 
12
- def self.detect?(text)
13
- return true if text.shebang? 'tclsh'
14
- return true if text.shebang? 'wish'
15
- return true if text.shebang? 'jimsh'
12
+ def self.analyze_text(text)
13
+ return 1 if text.shebang? 'tclsh'
14
+ return 1 if text.shebang? 'wish'
15
+ return 1 if text.shebang? 'jimsh'
16
16
  end
17
17
 
18
18
  KEYWORDS = %w(
@@ -11,8 +11,8 @@ module Rouge
11
11
  filenames '*.tex', '*.aux', '*.toc', '*.sty', '*.cls'
12
12
  mimetypes 'text/x-tex', 'text/x-latex'
13
13
 
14
- def self.detect?(text)
15
- return true if text =~ /\A\s*\\(documentclass|input|documentstyle|relax|ProvidesPackage|ProvidesClass)/
14
+ def self.analyze_text(text)
15
+ return 1 if text =~ /\A\s*\\(documentclass|input|documentstyle|relax|ProvidesPackage|ProvidesClass)/
16
16
  end
17
17
 
18
18
  command = /\\([a-z]+|\s+|.)/i
@@ -10,6 +10,10 @@ module Rouge
10
10
  filenames '*.toml'
11
11
  mimetypes 'text/x-toml'
12
12
 
13
+ def self.analyze_text(text)
14
+ return 0.1 if text =~ /\A\[[\w.]+\]\s*\w+\s*=\s*("\w+")+/
15
+ end
16
+
13
17
  identifier = /[\w.\S]+/
14
18
 
15
19
  state :basic do
@@ -9,8 +9,9 @@ module Rouge
9
9
 
10
10
  mimetypes 'text/x-tulip', 'application/x-tulip'
11
11
 
12
- def self.detect?(text)
13
- return true if text.shebang? 'tulip'
12
+ def self.analyze_text(text)
13
+ return 1 if text.shebang? 'tulip'
14
+ return 0
14
15
  end
15
16
 
16
17
  id = /[a-z][\w-]*/i