gitlab-rouge 1.9.2
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 +7 -0
- data/Gemfile +23 -0
- data/LICENSE +186 -0
- data/bin/rougify +16 -0
- data/gitlab-rouge.gemspec +17 -0
- data/lib/rouge.rb +57 -0
- data/lib/rouge/cli.rb +363 -0
- data/lib/rouge/demos/apache +21 -0
- data/lib/rouge/demos/applescript +2 -0
- data/lib/rouge/demos/c +8 -0
- data/lib/rouge/demos/clojure +5 -0
- data/lib/rouge/demos/coffeescript +5 -0
- data/lib/rouge/demos/common_lisp +1 -0
- data/lib/rouge/demos/conf +4 -0
- data/lib/rouge/demos/cpp +8 -0
- data/lib/rouge/demos/csharp +5 -0
- data/lib/rouge/demos/css +4 -0
- data/lib/rouge/demos/dart +6 -0
- data/lib/rouge/demos/diff +7 -0
- data/lib/rouge/demos/elixir +1 -0
- data/lib/rouge/demos/erb +1 -0
- data/lib/rouge/demos/erlang +7 -0
- data/lib/rouge/demos/factor +5 -0
- data/lib/rouge/demos/gherkin +17 -0
- data/lib/rouge/demos/glsl +14 -0
- data/lib/rouge/demos/go +7 -0
- data/lib/rouge/demos/groovy +9 -0
- data/lib/rouge/demos/haml +5 -0
- data/lib/rouge/demos/handlebars +7 -0
- data/lib/rouge/demos/haskell +6 -0
- data/lib/rouge/demos/html +8 -0
- data/lib/rouge/demos/http +14 -0
- data/lib/rouge/demos/ini +4 -0
- data/lib/rouge/demos/io +11 -0
- data/lib/rouge/demos/java +5 -0
- data/lib/rouge/demos/javascript +1 -0
- data/lib/rouge/demos/json +1 -0
- data/lib/rouge/demos/json-doc +1 -0
- data/lib/rouge/demos/liquid +11 -0
- data/lib/rouge/demos/literate_coffeescript +3 -0
- data/lib/rouge/demos/literate_haskell +7 -0
- data/lib/rouge/demos/llvm +20 -0
- data/lib/rouge/demos/lua +12 -0
- data/lib/rouge/demos/make +6 -0
- data/lib/rouge/demos/markdown +4 -0
- data/lib/rouge/demos/matlab +6 -0
- data/lib/rouge/demos/moonscript +16 -0
- data/lib/rouge/demos/nginx +5 -0
- data/lib/rouge/demos/nim +27 -0
- data/lib/rouge/demos/objective_c +14 -0
- data/lib/rouge/demos/ocaml +12 -0
- data/lib/rouge/demos/perl +5 -0
- data/lib/rouge/demos/php +3 -0
- data/lib/rouge/demos/plaintext +1 -0
- data/lib/rouge/demos/powershell +49 -0
- data/lib/rouge/demos/prolog +9 -0
- data/lib/rouge/demos/properties +7 -0
- data/lib/rouge/demos/puppet +6 -0
- data/lib/rouge/demos/python +6 -0
- data/lib/rouge/demos/qml +9 -0
- data/lib/rouge/demos/r +8 -0
- data/lib/rouge/demos/racket +24 -0
- data/lib/rouge/demos/ruby +9 -0
- data/lib/rouge/demos/rust +12 -0
- data/lib/rouge/demos/sass +3 -0
- data/lib/rouge/demos/scala +3 -0
- data/lib/rouge/demos/scheme +4 -0
- data/lib/rouge/demos/scss +5 -0
- data/lib/rouge/demos/sed +4 -0
- data/lib/rouge/demos/shell +2 -0
- data/lib/rouge/demos/slim +17 -0
- data/lib/rouge/demos/smalltalk +6 -0
- data/lib/rouge/demos/sml +4 -0
- data/lib/rouge/demos/sql +1 -0
- data/lib/rouge/demos/swift +5 -0
- data/lib/rouge/demos/tcl +1 -0
- data/lib/rouge/demos/tex +1 -0
- data/lib/rouge/demos/toml +9 -0
- data/lib/rouge/demos/tulip +14 -0
- data/lib/rouge/demos/vb +4 -0
- data/lib/rouge/demos/viml +5 -0
- data/lib/rouge/demos/xml +2 -0
- data/lib/rouge/demos/yaml +4 -0
- data/lib/rouge/formatter.rb +50 -0
- data/lib/rouge/formatters/html.rb +117 -0
- data/lib/rouge/formatters/null.rb +19 -0
- data/lib/rouge/formatters/terminal256.rb +176 -0
- data/lib/rouge/lexer.rb +443 -0
- data/lib/rouge/lexers/apache.rb +68 -0
- data/lib/rouge/lexers/apache/keywords.yml +453 -0
- data/lib/rouge/lexers/apple_script.rb +367 -0
- data/lib/rouge/lexers/c.rb +212 -0
- data/lib/rouge/lexers/clojure.rb +112 -0
- data/lib/rouge/lexers/coffeescript.rb +174 -0
- data/lib/rouge/lexers/common_lisp.rb +345 -0
- data/lib/rouge/lexers/conf.rb +24 -0
- data/lib/rouge/lexers/cpp.rb +66 -0
- data/lib/rouge/lexers/csharp.rb +88 -0
- data/lib/rouge/lexers/css.rb +271 -0
- data/lib/rouge/lexers/dart.rb +104 -0
- data/lib/rouge/lexers/diff.rb +31 -0
- data/lib/rouge/lexers/elixir.rb +108 -0
- data/lib/rouge/lexers/erb.rb +56 -0
- data/lib/rouge/lexers/erlang.rb +118 -0
- data/lib/rouge/lexers/factor.rb +302 -0
- data/lib/rouge/lexers/gherkin.rb +137 -0
- data/lib/rouge/lexers/gherkin/keywords.rb +14 -0
- data/lib/rouge/lexers/glsl.rb +135 -0
- data/lib/rouge/lexers/go.rb +178 -0
- data/lib/rouge/lexers/groovy.rb +104 -0
- data/lib/rouge/lexers/haml.rb +228 -0
- data/lib/rouge/lexers/handlebars.rb +79 -0
- data/lib/rouge/lexers/haskell.rb +183 -0
- data/lib/rouge/lexers/html.rb +94 -0
- data/lib/rouge/lexers/http.rb +80 -0
- data/lib/rouge/lexers/ini.rb +57 -0
- data/lib/rouge/lexers/io.rb +68 -0
- data/lib/rouge/lexers/java.rb +76 -0
- data/lib/rouge/lexers/javascript.rb +297 -0
- data/lib/rouge/lexers/liquid.rb +287 -0
- data/lib/rouge/lexers/literate_coffeescript.rb +33 -0
- data/lib/rouge/lexers/literate_haskell.rb +36 -0
- data/lib/rouge/lexers/llvm.rb +84 -0
- data/lib/rouge/lexers/lua.rb +122 -0
- data/lib/rouge/lexers/lua/builtins.rb +22 -0
- data/lib/rouge/lexers/make.rb +116 -0
- data/lib/rouge/lexers/markdown.rb +154 -0
- data/lib/rouge/lexers/matlab.rb +74 -0
- data/lib/rouge/lexers/matlab/builtins.rb +11 -0
- data/lib/rouge/lexers/moonscript.rb +110 -0
- data/lib/rouge/lexers/nginx.rb +71 -0
- data/lib/rouge/lexers/nim.rb +152 -0
- data/lib/rouge/lexers/objective_c.rb +197 -0
- data/lib/rouge/lexers/ocaml.rb +111 -0
- data/lib/rouge/lexers/perl.rb +197 -0
- data/lib/rouge/lexers/php.rb +173 -0
- data/lib/rouge/lexers/php/builtins.rb +204 -0
- data/lib/rouge/lexers/plain_text.rb +25 -0
- data/lib/rouge/lexers/powershell.rb +96 -0
- data/lib/rouge/lexers/prolog.rb +64 -0
- data/lib/rouge/lexers/properties.rb +55 -0
- data/lib/rouge/lexers/puppet.rb +128 -0
- data/lib/rouge/lexers/python.rb +228 -0
- data/lib/rouge/lexers/qml.rb +72 -0
- data/lib/rouge/lexers/r.rb +56 -0
- data/lib/rouge/lexers/racket.rb +542 -0
- data/lib/rouge/lexers/ruby.rb +415 -0
- data/lib/rouge/lexers/rust.rb +191 -0
- data/lib/rouge/lexers/sass.rb +74 -0
- data/lib/rouge/lexers/sass/common.rb +180 -0
- data/lib/rouge/lexers/scala.rb +142 -0
- data/lib/rouge/lexers/scheme.rb +112 -0
- data/lib/rouge/lexers/scss.rb +34 -0
- data/lib/rouge/lexers/sed.rb +170 -0
- data/lib/rouge/lexers/shell.rb +152 -0
- data/lib/rouge/lexers/slim.rb +228 -0
- data/lib/rouge/lexers/smalltalk.rb +116 -0
- data/lib/rouge/lexers/sml.rb +347 -0
- data/lib/rouge/lexers/sql.rb +140 -0
- data/lib/rouge/lexers/swift.rb +144 -0
- data/lib/rouge/lexers/tcl.rb +192 -0
- data/lib/rouge/lexers/tex.rb +72 -0
- data/lib/rouge/lexers/toml.rb +71 -0
- data/lib/rouge/lexers/tulip.rb +75 -0
- data/lib/rouge/lexers/vb.rb +164 -0
- data/lib/rouge/lexers/viml.rb +101 -0
- data/lib/rouge/lexers/viml/keywords.rb +12 -0
- data/lib/rouge/lexers/xml.rb +59 -0
- data/lib/rouge/lexers/yaml.rb +364 -0
- data/lib/rouge/plugins/redcarpet.rb +30 -0
- data/lib/rouge/regex_lexer.rb +439 -0
- data/lib/rouge/template_lexer.rb +22 -0
- data/lib/rouge/text_analyzer.rb +48 -0
- data/lib/rouge/theme.rb +195 -0
- data/lib/rouge/themes/base16.rb +130 -0
- data/lib/rouge/themes/colorful.rb +67 -0
- data/lib/rouge/themes/github.rb +71 -0
- data/lib/rouge/themes/molokai.rb +82 -0
- data/lib/rouge/themes/monokai.rb +92 -0
- data/lib/rouge/themes/monokai_sublime.rb +90 -0
- data/lib/rouge/themes/thankful_eyes.rb +71 -0
- data/lib/rouge/token.rb +182 -0
- data/lib/rouge/util.rb +101 -0
- data/lib/rouge/version.rb +7 -0
- metadata +231 -0
@@ -0,0 +1,112 @@
|
|
1
|
+
# -*- coding: utf-8 -*- #
|
2
|
+
|
3
|
+
module Rouge
|
4
|
+
module Lexers
|
5
|
+
class Clojure < RegexLexer
|
6
|
+
title "Clojure"
|
7
|
+
desc "The Clojure programming language (clojure.org)"
|
8
|
+
|
9
|
+
tag 'clojure'
|
10
|
+
aliases 'clj', 'cljs'
|
11
|
+
|
12
|
+
filenames '*.clj', '*.cljs'
|
13
|
+
|
14
|
+
mimetypes 'text/x-clojure', 'application/x-clojure'
|
15
|
+
|
16
|
+
def self.keywords
|
17
|
+
@keywords ||= Set.new %w(
|
18
|
+
fn def defn defmacro defmethod defmulti defn- defstruct if
|
19
|
+
cond let for
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.builtins
|
24
|
+
@builtins ||= Set.new %w(
|
25
|
+
. .. * + - -> / < <= = == > >= accessor agent agent-errors
|
26
|
+
aget alength all-ns alter and append-child apply array-map
|
27
|
+
aset aset-boolean aset-byte aset-char aset-double aset-float
|
28
|
+
aset-int aset-long aset-short assert assoc await await-for bean
|
29
|
+
binding bit-and bit-not bit-or bit-shift-left bit-shift-right
|
30
|
+
bit-xor boolean branch? butlast byte cast char children
|
31
|
+
class clear-agent-errors comment commute comp comparator
|
32
|
+
complement concat conj cons constantly construct-proxy
|
33
|
+
contains? count create-ns create-struct cycle dec deref
|
34
|
+
difference disj dissoc distinct doall doc dorun doseq dosync
|
35
|
+
dotimes doto double down drop drop-while edit end? ensure eval
|
36
|
+
every? false? ffirst file-seq filter find find-doc find-ns
|
37
|
+
find-var first float flush fnseq frest gensym get-proxy-class
|
38
|
+
get hash-map hash-set identical? identity if-let import in-ns
|
39
|
+
inc index insert-child insert-left insert-right inspect-table
|
40
|
+
inspect-tree instance? int interleave intersection into
|
41
|
+
into-array iterate join key keys keyword keyword? last lazy-cat
|
42
|
+
lazy-cons left lefts line-seq list* list load load-file locking
|
43
|
+
long loop macroexpand macroexpand-1 make-array make-node map
|
44
|
+
map-invert map? mapcat max max-key memfn merge merge-with meta
|
45
|
+
min min-key name namespace neg? new newline next nil? node not
|
46
|
+
not-any? not-every? not= ns-imports ns-interns ns-map ns-name
|
47
|
+
ns-publics ns-refers ns-resolve ns-unmap nth nthrest or parse
|
48
|
+
partial path peek pop pos? pr pr-str print print-str println
|
49
|
+
println-str prn prn-str project proxy proxy-mappings quot
|
50
|
+
rand rand-int range re-find re-groups re-matcher re-matches
|
51
|
+
re-pattern re-seq read read-line reduce ref ref-set refer rem
|
52
|
+
remove remove-method remove-ns rename rename-keys repeat replace
|
53
|
+
replicate resolve rest resultset-seq reverse rfirst right
|
54
|
+
rights root rrest rseq second select select-keys send send-off
|
55
|
+
seq seq-zip seq? set short slurp some sort sort-by sorted-map
|
56
|
+
sorted-map-by sorted-set special-symbol? split-at split-with
|
57
|
+
str string? struct struct-map subs subvec symbol symbol?
|
58
|
+
sync take take-nth take-while test time to-array to-array-2d
|
59
|
+
tree-seq true? union up update-proxy val vals var-get var-set
|
60
|
+
var? vector vector-zip vector? when when-first when-let
|
61
|
+
when-not with-local-vars with-meta with-open with-out-str
|
62
|
+
xml-seq xml-zip zero? zipmap zipper'
|
63
|
+
)
|
64
|
+
end
|
65
|
+
|
66
|
+
identifier = %r([\w!$%*+,<=>?/.-]+)
|
67
|
+
keyword = %r([\w!\#$%*+,<=>?/.-]+)
|
68
|
+
|
69
|
+
def name_token(name)
|
70
|
+
return Keyword if self.class.keywords.include?(name)
|
71
|
+
return Name::Builtin if self.class.builtins.include?(name)
|
72
|
+
nil
|
73
|
+
end
|
74
|
+
|
75
|
+
state :root do
|
76
|
+
rule /;.*?\n/, Comment::Single
|
77
|
+
rule /\s+/m, Text::Whitespace
|
78
|
+
|
79
|
+
rule /-?\d+\.\d+/, Num::Float
|
80
|
+
rule /-?\d+/, Num::Integer
|
81
|
+
rule /0x-?[0-9a-fA-F]+/, Num::Hex
|
82
|
+
|
83
|
+
rule /"(\\.|[^"])*"/, Str
|
84
|
+
rule /'#{keyword}/, Str::Symbol
|
85
|
+
rule /::?#{keyword}/, Name::Constant
|
86
|
+
rule /\\(.|[a-z]+)/i, Str::Char
|
87
|
+
|
88
|
+
|
89
|
+
rule /~@|[`\'#^~&]/, Operator
|
90
|
+
|
91
|
+
rule /(\()(\s*)(#{identifier})/m do |m|
|
92
|
+
token Punctuation, m[1]
|
93
|
+
token Text::Whitespace, m[2]
|
94
|
+
token(name_token(m[3]) || Name::Function, m[3])
|
95
|
+
end
|
96
|
+
|
97
|
+
rule identifier do |m|
|
98
|
+
token name_token(m[0]) || Name
|
99
|
+
end
|
100
|
+
|
101
|
+
# vectors
|
102
|
+
rule /[\[\]]/, Punctuation
|
103
|
+
|
104
|
+
# maps
|
105
|
+
rule /[{}]/, Punctuation
|
106
|
+
|
107
|
+
# parentheses
|
108
|
+
rule /[()]/, Punctuation
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
@@ -0,0 +1,174 @@
|
|
1
|
+
# -*- coding: utf-8 -*- #
|
2
|
+
|
3
|
+
module Rouge
|
4
|
+
module Lexers
|
5
|
+
class Coffeescript < RegexLexer
|
6
|
+
tag 'coffeescript'
|
7
|
+
aliases 'coffee', 'coffee-script'
|
8
|
+
filenames '*.coffee', 'Cakefile'
|
9
|
+
mimetypes 'text/coffeescript'
|
10
|
+
|
11
|
+
title "CoffeeScript"
|
12
|
+
desc 'The Coffeescript programming language (coffeescript.org)'
|
13
|
+
|
14
|
+
def self.analyze_text(text)
|
15
|
+
return 1 if text.shebang? 'coffee'
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.keywords
|
19
|
+
@keywords ||= Set.new %w(
|
20
|
+
for in of while break return continue switch when then if else
|
21
|
+
throw try catch finally new delete typeof instanceof super
|
22
|
+
extends this class by
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.constants
|
27
|
+
@constants ||= Set.new %w(
|
28
|
+
true false yes no on off null NaN Infinity undefined
|
29
|
+
)
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.builtins
|
33
|
+
@builtins ||= Set.new %w(
|
34
|
+
Array Boolean Date Error Function Math netscape Number Object
|
35
|
+
Packages RegExp String sun decodeURI decodeURIComponent
|
36
|
+
encodeURI encodeURIComponent eval isFinite isNaN parseFloat
|
37
|
+
parseInt document window
|
38
|
+
)
|
39
|
+
end
|
40
|
+
|
41
|
+
id = /[$a-zA-Z_][a-zA-Z0-9_]*/
|
42
|
+
|
43
|
+
state :comments_and_whitespace do
|
44
|
+
rule /\s+/m, Text
|
45
|
+
rule /###.*?###/m, Comment::Multiline
|
46
|
+
rule /#.*?\n/, Comment::Single
|
47
|
+
end
|
48
|
+
|
49
|
+
state :multiline_regex do
|
50
|
+
# this order is important, so that #{ isn't interpreted
|
51
|
+
# as a comment
|
52
|
+
mixin :has_interpolation
|
53
|
+
mixin :comments_and_whitespace
|
54
|
+
|
55
|
+
rule %r(///([gim]+\b|\B)), Str::Regex, :pop!
|
56
|
+
rule %r(/), Str::Regex
|
57
|
+
rule %r([^/#]+), Str::Regex
|
58
|
+
end
|
59
|
+
|
60
|
+
state :slash_starts_regex do
|
61
|
+
mixin :comments_and_whitespace
|
62
|
+
rule %r(///) do
|
63
|
+
token Str::Regex
|
64
|
+
goto :multiline_regex
|
65
|
+
end
|
66
|
+
|
67
|
+
rule %r(
|
68
|
+
/(\\.|[^\[/\\\n]|\[(\\.|[^\]\\\n])*\])+/ # a regex
|
69
|
+
([gim]+\b|\B)
|
70
|
+
)x, Str::Regex, :pop!
|
71
|
+
|
72
|
+
rule(//) { pop! }
|
73
|
+
end
|
74
|
+
|
75
|
+
state :root do
|
76
|
+
rule(%r(^(?=\s|/|<!--))) { push :slash_starts_regex }
|
77
|
+
mixin :comments_and_whitespace
|
78
|
+
rule %r(
|
79
|
+
[+][+]|--|~|&&|\band\b|\bor\b|\bis\b|\bisnt\b|\bnot\b|[?]|:|=|
|
80
|
+
[|][|]|\\(?=\n)|(<<|>>>?|==?|!=?|[-<>+*`%&|^/])=?
|
81
|
+
)x, Operator, :slash_starts_regex
|
82
|
+
|
83
|
+
rule /[-=]>/, Name::Function
|
84
|
+
|
85
|
+
rule /(@)([ \t]*)(#{id})/ do
|
86
|
+
groups Name::Variable::Instance, Text, Name::Attribute
|
87
|
+
push :slash_starts_regex
|
88
|
+
end
|
89
|
+
|
90
|
+
rule /([.])([ \t]*)(#{id})/ do
|
91
|
+
groups Punctuation, Text, Name::Attribute
|
92
|
+
push :slash_starts_regex
|
93
|
+
end
|
94
|
+
|
95
|
+
rule /#{id}(?=\s*:)/, Name::Attribute, :slash_starts_regex
|
96
|
+
|
97
|
+
rule /#{id}/ do |m|
|
98
|
+
if self.class.keywords.include? m[0]
|
99
|
+
token Keyword
|
100
|
+
elsif self.class.constants.include? m[0]
|
101
|
+
token Name::Constant
|
102
|
+
elsif self.class.builtins.include? m[0]
|
103
|
+
token Name::Builtin
|
104
|
+
else
|
105
|
+
token Name::Other
|
106
|
+
end
|
107
|
+
|
108
|
+
push :slash_starts_regex
|
109
|
+
end
|
110
|
+
|
111
|
+
rule /[{(\[;,]/, Punctuation, :slash_starts_regex
|
112
|
+
rule /[})\].]/, Punctuation
|
113
|
+
|
114
|
+
rule /\d+[.]\d+([eE]\d+)?[fd]?/, Num::Float
|
115
|
+
rule /0x[0-9a-fA-F]+/, Num::Hex
|
116
|
+
rule /\d+/, Num::Integer
|
117
|
+
rule /"""/, Str, :tdqs
|
118
|
+
rule /'''/, Str, :tsqs
|
119
|
+
rule /"/, Str, :dqs
|
120
|
+
rule /'/, Str, :sqs
|
121
|
+
end
|
122
|
+
|
123
|
+
state :strings do
|
124
|
+
# all coffeescript strings are multi-line
|
125
|
+
rule /[^#\\'"]+/m, Str
|
126
|
+
|
127
|
+
rule /\\./, Str::Escape
|
128
|
+
rule /#/, Str
|
129
|
+
end
|
130
|
+
|
131
|
+
state :double_strings do
|
132
|
+
rule /'/, Str
|
133
|
+
mixin :has_interpolation
|
134
|
+
mixin :strings
|
135
|
+
end
|
136
|
+
|
137
|
+
state :single_strings do
|
138
|
+
rule /"/, Str
|
139
|
+
mixin :strings
|
140
|
+
end
|
141
|
+
|
142
|
+
state :interpolation do
|
143
|
+
rule /}/, Str::Interpol, :pop!
|
144
|
+
mixin :root
|
145
|
+
end
|
146
|
+
|
147
|
+
state :has_interpolation do
|
148
|
+
rule /[#][{]/, Str::Interpol, :interpolation
|
149
|
+
end
|
150
|
+
|
151
|
+
state :dqs do
|
152
|
+
rule /"/, Str, :pop!
|
153
|
+
mixin :double_strings
|
154
|
+
end
|
155
|
+
|
156
|
+
state :tdqs do
|
157
|
+
rule /"""/, Str, :pop!
|
158
|
+
rule /"/, Str
|
159
|
+
mixin :double_strings
|
160
|
+
end
|
161
|
+
|
162
|
+
state :sqs do
|
163
|
+
rule /'/, Str, :pop!
|
164
|
+
mixin :single_strings
|
165
|
+
end
|
166
|
+
|
167
|
+
state :tsqs do
|
168
|
+
rule /'''/, Str, :pop!
|
169
|
+
rule /'/, Str
|
170
|
+
mixin :single_strings
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
@@ -0,0 +1,345 @@
|
|
1
|
+
# -*- coding: utf-8 -*- #
|
2
|
+
|
3
|
+
module Rouge
|
4
|
+
module Lexers
|
5
|
+
class CommonLisp < RegexLexer
|
6
|
+
title "Common Lisp"
|
7
|
+
desc "The Common Lisp variant of Lisp (common-lisp.net)"
|
8
|
+
tag 'common_lisp'
|
9
|
+
aliases 'cl', 'common-lisp'
|
10
|
+
|
11
|
+
filenames '*.cl', '*.lisp', '*.el' # used for Elisp too
|
12
|
+
mimetypes 'text/x-common-lisp'
|
13
|
+
|
14
|
+
# 638 functions
|
15
|
+
BUILTIN_FUNCTIONS = Set.new %w(
|
16
|
+
< <= = > >= - / /= * + 1- 1+ abort abs acons acos acosh add-method
|
17
|
+
adjoin adjustable-array-p adjust-array allocate-instance
|
18
|
+
alpha-char-p alphanumericp append apply apropos apropos-list
|
19
|
+
aref arithmetic-error-operands arithmetic-error-operation
|
20
|
+
array-dimension array-dimensions array-displacement
|
21
|
+
array-element-type array-has-fill-pointer-p array-in-bounds-p
|
22
|
+
arrayp array-rank array-row-major-index array-total-size
|
23
|
+
ash asin asinh assoc assoc-if assoc-if-not atan atanh atom
|
24
|
+
bit bit-and bit-andc1 bit-andc2 bit-eqv bit-ior bit-nand
|
25
|
+
bit-nor bit-not bit-orc1 bit-orc2 bit-vector-p bit-xor boole
|
26
|
+
both-case-p boundp break broadcast-stream-streams butlast
|
27
|
+
byte byte-position byte-size caaaar caaadr caaar caadar
|
28
|
+
caaddr caadr caar cadaar cadadr cadar caddar cadddr caddr
|
29
|
+
cadr call-next-method car cdaaar cdaadr cdaar cdadar cdaddr
|
30
|
+
cdadr cdar cddaar cddadr cddar cdddar cddddr cdddr cddr cdr
|
31
|
+
ceiling cell-error-name cerror change-class char char< char<=
|
32
|
+
char= char> char>= char/= character characterp char-code
|
33
|
+
char-downcase char-equal char-greaterp char-int char-lessp
|
34
|
+
char-name char-not-equal char-not-greaterp char-not-lessp
|
35
|
+
char-upcase cis class-name class-of clear-input clear-output
|
36
|
+
close clrhash code-char coerce compile compiled-function-p
|
37
|
+
compile-file compile-file-pathname compiler-macro-function
|
38
|
+
complement complex complexp compute-applicable-methods
|
39
|
+
compute-restarts concatenate concatenated-stream-streams conjugate
|
40
|
+
cons consp constantly constantp continue copy-alist copy-list
|
41
|
+
copy-pprint-dispatch copy-readtable copy-seq copy-structure
|
42
|
+
copy-symbol copy-tree cos cosh count count-if count-if-not
|
43
|
+
decode-float decode-universal-time delete delete-duplicates
|
44
|
+
delete-file delete-if delete-if-not delete-package denominator
|
45
|
+
deposit-field describe describe-object digit-char digit-char-p
|
46
|
+
directory directory-namestring disassemble documentation dpb
|
47
|
+
dribble echo-stream-input-stream echo-stream-output-stream
|
48
|
+
ed eighth elt encode-universal-time endp enough-namestring
|
49
|
+
ensure-directories-exist ensure-generic-function eq
|
50
|
+
eql equal equalp error eval evenp every exp export expt
|
51
|
+
fboundp fceiling fdefinition ffloor fifth file-author
|
52
|
+
file-error-pathname file-length file-namestring file-position
|
53
|
+
file-string-length file-write-date fill fill-pointer find
|
54
|
+
find-all-symbols find-class find-if find-if-not find-method
|
55
|
+
find-package find-restart find-symbol finish-output first
|
56
|
+
float float-digits floatp float-precision float-radix
|
57
|
+
float-sign floor fmakunbound force-output format fourth
|
58
|
+
fresh-line fround ftruncate funcall function-keywords
|
59
|
+
function-lambda-expression functionp gcd gensym gentemp get
|
60
|
+
get-decoded-time get-dispatch-macro-character getf gethash
|
61
|
+
get-internal-real-time get-internal-run-time get-macro-character
|
62
|
+
get-output-stream-string get-properties get-setf-expansion
|
63
|
+
get-universal-time graphic-char-p hash-table-count hash-table-p
|
64
|
+
hash-table-rehash-size hash-table-rehash-threshold
|
65
|
+
hash-table-size hash-table-test host-namestring identity
|
66
|
+
imagpart import initialize-instance input-stream-p inspect
|
67
|
+
integer-decode-float integer-length integerp interactive-stream-p
|
68
|
+
intern intersection invalid-method-error invoke-debugger
|
69
|
+
invoke-restart invoke-restart-interactively isqrt keywordp
|
70
|
+
last lcm ldb ldb-test ldiff length lisp-implementation-type
|
71
|
+
lisp-implementation-version list list* list-all-packages listen
|
72
|
+
list-length listp load load-logical-pathname-translations
|
73
|
+
log logand logandc1 logandc2 logbitp logcount logeqv
|
74
|
+
logical-pathname logical-pathname-translations logior
|
75
|
+
lognand lognor lognot logorc1 logorc2 logtest logxor
|
76
|
+
long-site-name lower-case-p machine-instance machine-type
|
77
|
+
machine-version macroexpand macroexpand-1 macro-function
|
78
|
+
make-array make-broadcast-stream make-concatenated-stream
|
79
|
+
make-condition make-dispatch-macro-character make-echo-stream
|
80
|
+
make-hash-table make-instance make-instances-obsolete make-list
|
81
|
+
make-load-form make-load-form-saving-slots make-package
|
82
|
+
make-pathname make-random-state make-sequence make-string
|
83
|
+
make-string-input-stream make-string-output-stream make-symbol
|
84
|
+
make-synonym-stream make-two-way-stream makunbound map mapc
|
85
|
+
mapcan mapcar mapcon maphash map-into mapl maplist mask-field
|
86
|
+
max member member-if member-if-not merge merge-pathnames
|
87
|
+
method-combination-error method-qualifiers min minusp mismatch mod
|
88
|
+
muffle-warning name-char namestring nbutlast nconc next-method-p
|
89
|
+
nintersection ninth no-applicable-method no-next-method not notany
|
90
|
+
notevery nreconc nreverse nset-difference nset-exclusive-or
|
91
|
+
nstring-capitalize nstring-downcase nstring-upcase nsublis
|
92
|
+
nsubst nsubst-if nsubst-if-not nsubstitute nsubstitute-if
|
93
|
+
nsubstitute-if-not nth nthcdr null numberp numerator nunion
|
94
|
+
oddp open open-stream-p output-stream-p package-error-package
|
95
|
+
package-name package-nicknames packagep package-shadowing-symbols
|
96
|
+
package-used-by-list package-use-list pairlis parse-integer
|
97
|
+
parse-namestring pathname pathname-device pathname-directory
|
98
|
+
pathname-host pathname-match-p pathname-name pathnamep
|
99
|
+
pathname-type pathname-version peek-char phase plusp
|
100
|
+
position position-if position-if-not pprint pprint-dispatch
|
101
|
+
pprint-fill pprint-indent pprint-linear pprint-newline pprint-tab
|
102
|
+
pprint-tabular prin1 prin1-to-string princ princ-to-string print
|
103
|
+
print-object probe-file proclaim provide random random-state-p
|
104
|
+
rassoc rassoc-if rassoc-if-not rational rationalize rationalp
|
105
|
+
read read-byte read-char read-char-no-hang read-delimited-list
|
106
|
+
read-from-string read-line read-preserving-whitespace
|
107
|
+
read-sequence readtable-case readtablep realp realpart
|
108
|
+
reduce reinitialize-instance rem remhash remove
|
109
|
+
remove-duplicates remove-if remove-if-not remove-method
|
110
|
+
remprop rename-file rename-package replace require rest
|
111
|
+
restart-name revappend reverse room round row-major-aref
|
112
|
+
rplaca rplacd sbit scale-float schar search second set
|
113
|
+
set-difference set-dispatch-macro-character set-exclusive-or
|
114
|
+
set-macro-character set-pprint-dispatch set-syntax-from-char
|
115
|
+
seventh shadow shadowing-import shared-initialize
|
116
|
+
short-site-name signal signum simple-bit-vector-p
|
117
|
+
simple-condition-format-arguments simple-condition-format-control
|
118
|
+
simple-string-p simple-vector-p sin sinh sixth sleep slot-boundp
|
119
|
+
slot-exists-p slot-makunbound slot-missing slot-unbound slot-value
|
120
|
+
software-type software-version some sort special-operator-p
|
121
|
+
sqrt stable-sort standard-char-p store-value stream-element-type
|
122
|
+
stream-error-stream stream-external-format streamp string string<
|
123
|
+
string<= string= string> string>= string/= string-capitalize
|
124
|
+
string-downcase string-equal string-greaterp string-left-trim
|
125
|
+
string-lessp string-not-equal string-not-greaterp string-not-lessp
|
126
|
+
stringp string-right-trim string-trim string-upcase sublis subseq
|
127
|
+
subsetp subst subst-if subst-if-not substitute substitute-if
|
128
|
+
substitute-if-not subtypepsvref sxhash symbol-function
|
129
|
+
symbol-name symbolp symbol-package symbol-plist symbol-value
|
130
|
+
synonym-stream-symbol syntax: tailp tan tanh tenth terpri third
|
131
|
+
translate-logical-pathname translate-pathname tree-equal truename
|
132
|
+
truncate two-way-stream-input-stream two-way-stream-output-stream
|
133
|
+
type-error-datum type-error-expected-type type-of
|
134
|
+
typep unbound-slot-instance unexport unintern union
|
135
|
+
unread-char unuse-package update-instance-for-different-class
|
136
|
+
update-instance-for-redefined-class upgraded-array-element-type
|
137
|
+
upgraded-complex-part-type upper-case-p use-package
|
138
|
+
user-homedir-pathname use-value values values-list vector vectorp
|
139
|
+
vector-pop vector-push vector-push-extend warn wild-pathname-p
|
140
|
+
write write-byte write-char write-line write-sequence write-string
|
141
|
+
write-to-string yes-or-no-p y-or-n-p zerop
|
142
|
+
).freeze
|
143
|
+
|
144
|
+
SPECIAL_FORMS = Set.new %w(
|
145
|
+
block catch declare eval-when flet function go if labels lambda
|
146
|
+
let let* load-time-value locally macrolet multiple-value-call
|
147
|
+
multiple-value-prog1 progn progv quote return-from setq
|
148
|
+
symbol-macrolet tagbody the throw unwind-protect
|
149
|
+
)
|
150
|
+
|
151
|
+
MACROS = Set.new %w(
|
152
|
+
and assert call-method case ccase check-type cond ctypecase decf
|
153
|
+
declaim defclass defconstant defgeneric define-compiler-macro
|
154
|
+
define-condition define-method-combination define-modify-macro
|
155
|
+
define-setf-expander define-symbol-macro defmacro defmethod
|
156
|
+
defpackage defparameter defsetf defstruct deftype defun defvar
|
157
|
+
destructuring-bind do do* do-all-symbols do-external-symbols
|
158
|
+
dolist do-symbols dotimes ecase etypecase formatter
|
159
|
+
handler-bind handler-case ignore-errors incf in-package
|
160
|
+
lambda loop loop-finish make-method multiple-value-bind
|
161
|
+
multiple-value-list multiple-value-setq nth-value or pop
|
162
|
+
pprint-exit-if-list-exhausted pprint-logical-block pprint-pop
|
163
|
+
print-unreadable-object prog prog* prog1 prog2 psetf psetq
|
164
|
+
push pushnew remf restart-bind restart-case return rotatef
|
165
|
+
setf shiftf step time trace typecase unless untrace when
|
166
|
+
with-accessors with-compilation-unit with-condition-restarts
|
167
|
+
with-hash-table-iterator with-input-from-string with-open-file
|
168
|
+
with-open-stream with-output-to-string with-package-iterator
|
169
|
+
with-simple-restart with-slots with-standard-io-syntax
|
170
|
+
)
|
171
|
+
|
172
|
+
LAMBDA_LIST_KEYWORDS = Set.new %w(
|
173
|
+
&allow-other-keys &aux &body &environment &key &optional &rest
|
174
|
+
&whole
|
175
|
+
)
|
176
|
+
|
177
|
+
DECLARATIONS = Set.new %w(
|
178
|
+
dynamic-extent ignore optimize ftype inline special ignorable
|
179
|
+
notinline type
|
180
|
+
)
|
181
|
+
|
182
|
+
BUILTIN_TYPES = Set.new %w(
|
183
|
+
atom boolean base-char base-string bignum bit compiled-function
|
184
|
+
extended-char fixnum keyword nil signed-byte short-float
|
185
|
+
single-float double-float long-float simple-array
|
186
|
+
simple-base-string simple-bit-vector simple-string simple-vector
|
187
|
+
standard-char unsigned-byte
|
188
|
+
|
189
|
+
arithmetic-error cell-error condition control-error
|
190
|
+
division-by-zero end-of-file error file-error
|
191
|
+
floating-point-inexact floating-point-overflow
|
192
|
+
floating-point-underflow floating-point-invalid-operation
|
193
|
+
parse-error package-error print-not-readable program-error
|
194
|
+
reader-error serious-condition simple-condition simple-error
|
195
|
+
simple-type-error simple-warning stream-error storage-condition
|
196
|
+
style-warning type-error unbound-variable unbound-slot
|
197
|
+
undefined-function warning
|
198
|
+
)
|
199
|
+
|
200
|
+
BUILTIN_CLASSES = Set.new %w(
|
201
|
+
array broadcast-stream bit-vector built-in-class character
|
202
|
+
class complex concatenated-stream cons echo-stream file-stream
|
203
|
+
float function generic-function hash-table integer list
|
204
|
+
logical-pathname method-combination method null number package
|
205
|
+
pathname ratio rational readtable real random-state restart
|
206
|
+
sequence standard-class standard-generic-function standard-method
|
207
|
+
standard-object string-stream stream string structure-class
|
208
|
+
structure-object symbol synonym-stream t two-way-stream vector
|
209
|
+
)
|
210
|
+
|
211
|
+
nonmacro = /\\.|[a-zA-Z0-9!$%&*+-\/<=>?@\[\]^_{}~]/
|
212
|
+
constituent = /#{nonmacro}|[#.:]/
|
213
|
+
terminated = /(?=[ "'()\n,;`])/ # whitespace or terminating macro chars
|
214
|
+
symbol = /(\|[^\|]+\||#{nonmacro}#{constituent}*)/
|
215
|
+
|
216
|
+
state :root do
|
217
|
+
rule /\s+/m, Text
|
218
|
+
rule /;.*$/, Comment::Single
|
219
|
+
rule /#\|/, Comment::Multiline, :multiline_comment
|
220
|
+
|
221
|
+
# encoding comment
|
222
|
+
rule /#\d*Y.*$/, Comment::Special
|
223
|
+
rule /"(\\.|[^"\\])*"/, Str
|
224
|
+
|
225
|
+
rule /[:']#{symbol}/, Str::Symbol
|
226
|
+
rule /['`]/, Operator
|
227
|
+
|
228
|
+
# numbers
|
229
|
+
rule /[-+]?\d+\.?#{terminated}/, Num::Integer
|
230
|
+
rule %r([-+]?\d+/\d+#{terminated}), Num::Integer
|
231
|
+
rule %r(
|
232
|
+
[-+]?
|
233
|
+
(\d*\.\d+([defls][-+]?\d+)?
|
234
|
+
|\d+(\.\d*)?[defls][-+]?\d+)
|
235
|
+
#{terminated}
|
236
|
+
)x, Num::Float
|
237
|
+
|
238
|
+
# sharpsign strings and characters
|
239
|
+
rule /#\\.#{terminated}/, Str::Char
|
240
|
+
rule /#\\#{symbol}/, Str::Char
|
241
|
+
|
242
|
+
rule /#\(/, Operator, :root
|
243
|
+
|
244
|
+
# bitstring
|
245
|
+
rule /#\d*\*[01]*/, Other
|
246
|
+
|
247
|
+
# uninterned symbol
|
248
|
+
rule /#:#{symbol}/, Str::Symbol
|
249
|
+
|
250
|
+
# read-time and load-time evaluation
|
251
|
+
rule /#[.,]/, Operator
|
252
|
+
|
253
|
+
# function shorthand
|
254
|
+
rule /#'/, Name::Function
|
255
|
+
|
256
|
+
# binary rational
|
257
|
+
rule /#b[+-]?[01]+(\/[01]+)?/i, Num
|
258
|
+
|
259
|
+
# octal rational
|
260
|
+
rule /#o[+-]?[0-7]+(\/[0-7]+)?/i, Num::Oct
|
261
|
+
|
262
|
+
# hex rational
|
263
|
+
rule /#x[+-]?[0-9a-f]+(\/[0-9a-f]+)?/i, Num
|
264
|
+
|
265
|
+
# complex
|
266
|
+
rule /(#c)(\()/i do
|
267
|
+
groups Num, Punctuation
|
268
|
+
push :root
|
269
|
+
end
|
270
|
+
|
271
|
+
# arrays and structures
|
272
|
+
rule /(#(?:\d+a|s))(\()/i do
|
273
|
+
groups Literal::Other, Punctuation
|
274
|
+
push :root
|
275
|
+
end
|
276
|
+
|
277
|
+
# path
|
278
|
+
rule /#p?"(\\.|[^"])*"/i, Str::Symbol
|
279
|
+
|
280
|
+
# reference
|
281
|
+
rule /#\d+[=#]/, Operator
|
282
|
+
|
283
|
+
# read-time comment
|
284
|
+
rule /#+nil#{terminated}\s*\(/, Comment, :commented_form
|
285
|
+
|
286
|
+
# read-time conditional
|
287
|
+
rule /#[+-]/, Operator
|
288
|
+
|
289
|
+
# special operators that should have been parsed already
|
290
|
+
rule /(,@|,|\.)/, Operator
|
291
|
+
|
292
|
+
# special constants
|
293
|
+
rule /(t|nil)#{terminated}/, Name::Constant
|
294
|
+
|
295
|
+
# functions and variables
|
296
|
+
# note that these get filtered through in stream_tokens
|
297
|
+
rule /\*#{symbol}\*/, Name::Variable::Global
|
298
|
+
rule symbol do |m|
|
299
|
+
sym = m[0]
|
300
|
+
|
301
|
+
if BUILTIN_FUNCTIONS.include? sym
|
302
|
+
token Name::Builtin
|
303
|
+
elsif SPECIAL_FORMS.include? sym
|
304
|
+
token Keyword
|
305
|
+
elsif MACROS.include? sym
|
306
|
+
token Name::Builtin
|
307
|
+
elsif LAMBDA_LIST_KEYWORDS.include? sym
|
308
|
+
token Keyword
|
309
|
+
elsif DECLARATIONS.include? sym
|
310
|
+
token Keyword
|
311
|
+
elsif BUILTIN_TYPES.include? sym
|
312
|
+
token Keyword::Type
|
313
|
+
elsif BUILTIN_CLASSES.include? sym
|
314
|
+
token Name::Class
|
315
|
+
else
|
316
|
+
token Name::Variable
|
317
|
+
end
|
318
|
+
end
|
319
|
+
|
320
|
+
rule /\(/, Punctuation, :root
|
321
|
+
rule /\)/, Punctuation do
|
322
|
+
if stack.empty?
|
323
|
+
token Error
|
324
|
+
else
|
325
|
+
token Punctuation
|
326
|
+
pop!
|
327
|
+
end
|
328
|
+
end
|
329
|
+
end
|
330
|
+
|
331
|
+
state :multiline_comment do
|
332
|
+
rule /#\|/, Comment::Multiline, :multiline_comment
|
333
|
+
rule /\|#/, Comment::Multiline, :pop!
|
334
|
+
rule /[^\|#]+/, Comment::Multiline
|
335
|
+
rule /[\|#]/, Comment::Multiline
|
336
|
+
end
|
337
|
+
|
338
|
+
state :commented_form do
|
339
|
+
rule /\(/, Comment, :commented_form
|
340
|
+
rule /\)/, Comment, :pop!
|
341
|
+
rule /[^()]+/, Comment
|
342
|
+
end
|
343
|
+
end
|
344
|
+
end
|
345
|
+
end
|