rugments 1.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +52 -0
- data/README.md +195 -0
- data/bin/rugmentize +6 -0
- data/lib/rugments/cli.rb +357 -0
- data/lib/rugments/formatter.rb +29 -0
- data/lib/rugments/formatters/html.rb +142 -0
- data/lib/rugments/formatters/null.rb +17 -0
- data/lib/rugments/formatters/terminal256.rb +174 -0
- data/lib/rugments/lexer.rb +431 -0
- data/lib/rugments/lexers/apache/keywords.yml +453 -0
- data/lib/rugments/lexers/apache.rb +67 -0
- data/lib/rugments/lexers/apple_script.rb +366 -0
- data/lib/rugments/lexers/c.rb +210 -0
- data/lib/rugments/lexers/clojure.rb +109 -0
- data/lib/rugments/lexers/coffeescript.rb +172 -0
- data/lib/rugments/lexers/common_lisp.rb +343 -0
- data/lib/rugments/lexers/conf.rb +22 -0
- data/lib/rugments/lexers/cpp.rb +63 -0
- data/lib/rugments/lexers/csharp.rb +85 -0
- data/lib/rugments/lexers/css.rb +269 -0
- data/lib/rugments/lexers/dart.rb +102 -0
- data/lib/rugments/lexers/diff.rb +39 -0
- data/lib/rugments/lexers/elixir.rb +105 -0
- data/lib/rugments/lexers/erb.rb +54 -0
- data/lib/rugments/lexers/erlang.rb +116 -0
- data/lib/rugments/lexers/factor.rb +300 -0
- data/lib/rugments/lexers/gherkin/keywords.rb +13 -0
- data/lib/rugments/lexers/gherkin.rb +135 -0
- data/lib/rugments/lexers/go.rb +176 -0
- data/lib/rugments/lexers/groovy.rb +102 -0
- data/lib/rugments/lexers/haml.rb +226 -0
- data/lib/rugments/lexers/handlebars.rb +77 -0
- data/lib/rugments/lexers/haskell.rb +181 -0
- data/lib/rugments/lexers/html.rb +92 -0
- data/lib/rugments/lexers/http.rb +78 -0
- data/lib/rugments/lexers/ini.rb +55 -0
- data/lib/rugments/lexers/io.rb +66 -0
- data/lib/rugments/lexers/java.rb +74 -0
- data/lib/rugments/lexers/javascript.rb +258 -0
- data/lib/rugments/lexers/literate_coffeescript.rb +31 -0
- data/lib/rugments/lexers/literate_haskell.rb +34 -0
- data/lib/rugments/lexers/llvm.rb +82 -0
- data/lib/rugments/lexers/lua/builtins.rb +21 -0
- data/lib/rugments/lexers/lua.rb +120 -0
- data/lib/rugments/lexers/make.rb +114 -0
- data/lib/rugments/lexers/markdown.rb +151 -0
- data/lib/rugments/lexers/matlab/builtins.rb +10 -0
- data/lib/rugments/lexers/matlab.rb +70 -0
- data/lib/rugments/lexers/moonscript.rb +108 -0
- data/lib/rugments/lexers/nginx.rb +69 -0
- data/lib/rugments/lexers/nim.rb +149 -0
- data/lib/rugments/lexers/objective_c.rb +188 -0
- data/lib/rugments/lexers/ocaml.rb +109 -0
- data/lib/rugments/lexers/perl.rb +195 -0
- data/lib/rugments/lexers/php/builtins.rb +192 -0
- data/lib/rugments/lexers/php.rb +162 -0
- data/lib/rugments/lexers/plain_text.rb +23 -0
- data/lib/rugments/lexers/prolog.rb +62 -0
- data/lib/rugments/lexers/properties.rb +53 -0
- data/lib/rugments/lexers/puppet.rb +126 -0
- data/lib/rugments/lexers/python.rb +225 -0
- data/lib/rugments/lexers/qml.rb +70 -0
- data/lib/rugments/lexers/r.rb +55 -0
- data/lib/rugments/lexers/racket.rb +540 -0
- data/lib/rugments/lexers/ruby.rb +413 -0
- data/lib/rugments/lexers/rust.rb +188 -0
- data/lib/rugments/lexers/sass/common.rb +172 -0
- data/lib/rugments/lexers/sass.rb +72 -0
- data/lib/rugments/lexers/scala.rb +140 -0
- data/lib/rugments/lexers/scheme.rb +109 -0
- data/lib/rugments/lexers/scss.rb +32 -0
- data/lib/rugments/lexers/sed.rb +167 -0
- data/lib/rugments/lexers/shell.rb +150 -0
- data/lib/rugments/lexers/slim.rb +222 -0
- data/lib/rugments/lexers/smalltalk.rb +114 -0
- data/lib/rugments/lexers/sml.rb +345 -0
- data/lib/rugments/lexers/sql.rb +138 -0
- data/lib/rugments/lexers/swift.rb +153 -0
- data/lib/rugments/lexers/tcl.rb +189 -0
- data/lib/rugments/lexers/tex.rb +70 -0
- data/lib/rugments/lexers/toml.rb +68 -0
- data/lib/rugments/lexers/vb.rb +162 -0
- data/lib/rugments/lexers/viml/keywords.rb +11 -0
- data/lib/rugments/lexers/viml.rb +99 -0
- data/lib/rugments/lexers/xml.rb +57 -0
- data/lib/rugments/lexers/yaml.rb +362 -0
- data/lib/rugments/plugins/redcarpet.rb +28 -0
- data/lib/rugments/regex_lexer.rb +432 -0
- data/lib/rugments/template_lexer.rb +23 -0
- data/lib/rugments/text_analyzer.rb +46 -0
- data/lib/rugments/theme.rb +202 -0
- data/lib/rugments/themes/base16.rb +128 -0
- data/lib/rugments/themes/colorful.rb +65 -0
- data/lib/rugments/themes/github.rb +69 -0
- data/lib/rugments/themes/monokai.rb +88 -0
- data/lib/rugments/themes/monokai_sublime.rb +89 -0
- data/lib/rugments/themes/thankful_eyes.rb +69 -0
- data/lib/rugments/token.rb +180 -0
- data/lib/rugments/util.rb +99 -0
- data/lib/rugments/version.rb +3 -0
- data/lib/rugments.rb +33 -0
- metadata +149 -0
@@ -0,0 +1,366 @@
|
|
1
|
+
module Rugments
|
2
|
+
module Lexers
|
3
|
+
class AppleScript < RegexLexer
|
4
|
+
title 'AppleScript'
|
5
|
+
desc 'The AppleScript scripting language by Apple Inc. (http://developer.apple.com/applescript/)'
|
6
|
+
|
7
|
+
tag 'applescript'
|
8
|
+
aliases 'applescript'
|
9
|
+
|
10
|
+
filenames '*.applescript', '*.scpt'
|
11
|
+
|
12
|
+
mimetypes 'application/x-applescript'
|
13
|
+
|
14
|
+
def self.literals
|
15
|
+
@literals ||= ['AppleScript', 'current application', 'false', 'linefeed',
|
16
|
+
'missing value', 'pi', 'quote', 'result', 'return', 'space',
|
17
|
+
'tab', 'text item delimiters', 'true', 'version']
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.classes
|
21
|
+
@classes ||= ['alias ', 'application ', 'boolean ', 'class ', 'constant ',
|
22
|
+
'date ', 'file ', 'integer ', 'list ', 'number ', 'POSIX file ',
|
23
|
+
'real ', 'record ', 'reference ', 'RGB color ', 'script ',
|
24
|
+
'text ', 'unit types', '(?:Unicode )?text', 'string']
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.builtins
|
28
|
+
@builtins ||= ['attachment', 'attribute run', 'character', 'day', 'month',
|
29
|
+
'paragraph', 'word', 'year']
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.handler_params
|
33
|
+
@handler_params ||= ['about', 'above', 'against', 'apart from', 'around',
|
34
|
+
'aside from', 'at', 'below', 'beneath', 'beside',
|
35
|
+
'between', 'for', 'given', 'instead of', 'on', 'onto',
|
36
|
+
'out of', 'over', 'since']
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.commands
|
40
|
+
@commands ||= ['ASCII (character|number)', 'activate', 'beep', 'choose URL',
|
41
|
+
'choose application', 'choose color', 'choose file( name)?',
|
42
|
+
'choose folder', 'choose from list',
|
43
|
+
'choose remote application', 'clipboard info',
|
44
|
+
'close( access)?', 'copy', 'count', 'current date', 'delay',
|
45
|
+
'delete', 'display (alert|dialog)', 'do shell script',
|
46
|
+
'duplicate', 'exists', 'get eof', 'get volume settings',
|
47
|
+
'info for', 'launch', 'list (disks|folder)', 'load script',
|
48
|
+
'log', 'make', 'mount volume', 'new', 'offset',
|
49
|
+
'open( (for access|location))?', 'path to', 'print', 'quit',
|
50
|
+
'random number', 'read', 'round', 'run( script)?',
|
51
|
+
'say', 'scripting components',
|
52
|
+
'set (eof|the clipboard to|volume)', 'store script',
|
53
|
+
'summarize', 'system attribute', 'system info',
|
54
|
+
'the clipboard', 'time to GMT', 'write', 'quoted form']
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.references
|
58
|
+
@references ||= ['(in )?back of', '(in )?front of', '[0-9]+(st|nd|rd|th)',
|
59
|
+
'first', 'second', 'third', 'fourth', 'fifth', 'sixth',
|
60
|
+
'seventh', 'eighth', 'ninth', 'tenth', 'after', 'back',
|
61
|
+
'before', 'behind', 'every', 'front', 'index', 'last',
|
62
|
+
'middle', 'some', 'that', 'through', 'thru', 'where', 'whose']
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.operators
|
66
|
+
@operators ||= ['and', 'or', 'is equal', 'equals', '(is )?equal to', 'is not',
|
67
|
+
"isn't", "isn't equal( to)?", 'is not equal( to)?',
|
68
|
+
"doesn't equal", 'does not equal', '(is )?greater than',
|
69
|
+
'comes after', 'is not less than or equal( to)?',
|
70
|
+
"isn't less than or equal( to)?", '(is )?less than',
|
71
|
+
'comes before', 'is not greater than or equal( to)?',
|
72
|
+
"isn't greater than or equal( to)?",
|
73
|
+
'(is )?greater than or equal( to)?', 'is not less than',
|
74
|
+
"isn't less than", 'does not come before',
|
75
|
+
"doesn't come before", '(is )?less than or equal( to)?',
|
76
|
+
'is not greater than', "isn't greater than",
|
77
|
+
'does not come after', "doesn't come after", 'starts? with',
|
78
|
+
'begins? with', 'ends? with', 'contains?', 'does not contain',
|
79
|
+
"doesn't contain", 'is in', 'is contained by', 'is not in',
|
80
|
+
'is not contained by', "isn't contained by", 'div', 'mod',
|
81
|
+
'not', '(a )?(ref( to)?|reference to)', 'is', 'does']
|
82
|
+
end
|
83
|
+
|
84
|
+
def self.controls
|
85
|
+
@controls ||= ['considering', 'else', 'error', 'exit', 'from', 'if',
|
86
|
+
'ignoring', 'in', 'repeat', 'tell', 'then', 'times', 'to',
|
87
|
+
'try', 'until', 'using terms from', 'while', 'whith',
|
88
|
+
'with timeout( of)?', 'with transaction', 'by', 'continue',
|
89
|
+
'end', 'its?', 'me', 'my', 'return', 'of', 'as']
|
90
|
+
end
|
91
|
+
|
92
|
+
def self.declarations
|
93
|
+
@declarations ||= ['global', 'local', 'prop(erty)?', 'set', 'get']
|
94
|
+
end
|
95
|
+
|
96
|
+
def self.reserved
|
97
|
+
@reserved ||= %w(but put returning the)
|
98
|
+
end
|
99
|
+
|
100
|
+
def self.studio_classes
|
101
|
+
@studio_classes ||= ['action cell', 'alert reply', 'application', 'box',
|
102
|
+
'browser( cell)?', 'bundle', 'button( cell)?', 'cell',
|
103
|
+
'clip view', 'color well', 'color-panel',
|
104
|
+
'combo box( item)?', 'control',
|
105
|
+
'data( (cell|column|item|row|source))?', 'default entry',
|
106
|
+
'dialog reply', 'document', 'drag info', 'drawer',
|
107
|
+
'event', 'font(-panel)?', 'formatter',
|
108
|
+
'image( (cell|view))?', 'matrix', 'menu( item)?', 'item',
|
109
|
+
'movie( view)?', 'open-panel', 'outline view', 'panel',
|
110
|
+
'pasteboard', 'plugin', 'popup button',
|
111
|
+
'progress indicator', 'responder', 'save-panel',
|
112
|
+
'scroll view', 'secure text field( cell)?', 'slider',
|
113
|
+
'sound', 'split view', 'stepper', 'tab view( item)?',
|
114
|
+
'table( (column|header cell|header view|view))',
|
115
|
+
'text( (field( cell)?|view))?', 'toolbar( item)?',
|
116
|
+
'user-defaults', 'view', 'window']
|
117
|
+
end
|
118
|
+
|
119
|
+
def self.studio_events
|
120
|
+
@studio_events ||= ['accept outline drop', 'accept table drop', 'action',
|
121
|
+
'activated', 'alert ended', 'awake from nib', 'became key',
|
122
|
+
'became main', 'begin editing', 'bounds changed',
|
123
|
+
'cell value', 'cell value changed', 'change cell value',
|
124
|
+
'change item value', 'changed', 'child of item',
|
125
|
+
'choose menu item', 'clicked', 'clicked toolbar item',
|
126
|
+
'closed', 'column clicked', 'column moved',
|
127
|
+
'column resized', 'conclude drop', 'data representation',
|
128
|
+
'deminiaturized', 'dialog ended', 'document nib name',
|
129
|
+
'double clicked', 'drag( (entered|exited|updated))?',
|
130
|
+
'drop', 'end editing', 'exposed', 'idle', 'item expandable',
|
131
|
+
'item value', 'item value changed', 'items changed',
|
132
|
+
'keyboard down', 'keyboard up', 'launched',
|
133
|
+
'load data representation', 'miniaturized', 'mouse down',
|
134
|
+
'mouse dragged', 'mouse entered', 'mouse exited',
|
135
|
+
'mouse moved', 'mouse up', 'moved',
|
136
|
+
'number of browser rows', 'number of items',
|
137
|
+
'number of rows', 'open untitled', 'opened', 'panel ended',
|
138
|
+
'parameters updated', 'plugin loaded', 'prepare drop',
|
139
|
+
'prepare outline drag', 'prepare outline drop',
|
140
|
+
'prepare table drag', 'prepare table drop',
|
141
|
+
'read from file', 'resigned active', 'resigned key',
|
142
|
+
'resigned main', 'resized( sub views)?',
|
143
|
+
'right mouse down', 'right mouse dragged',
|
144
|
+
'right mouse up', 'rows changed', 'scroll wheel',
|
145
|
+
'selected tab view item', 'selection changed',
|
146
|
+
'selection changing', 'should begin editing',
|
147
|
+
'should close', 'should collapse item',
|
148
|
+
'should end editing', 'should expand item',
|
149
|
+
'should open( untitled)?',
|
150
|
+
'should quit( after last window closed)?',
|
151
|
+
'should select column', 'should select item',
|
152
|
+
'should select row', 'should select tab view item',
|
153
|
+
'should selection change', 'should zoom', 'shown',
|
154
|
+
'update menu item', 'update parameters',
|
155
|
+
'update toolbar item', 'was hidden', 'was miniaturized',
|
156
|
+
'will become active', 'will close', 'will dismiss',
|
157
|
+
'will display browser cell', 'will display cell',
|
158
|
+
'will display item cell', 'will display outline cell',
|
159
|
+
'will finish launching', 'will hide', 'will miniaturize',
|
160
|
+
'will move', 'will open', 'will pop up', 'will quit',
|
161
|
+
'will resign active', 'will resize( sub views)?',
|
162
|
+
'will select tab view item', 'will show', 'will zoom',
|
163
|
+
'write to file', 'zoomed']
|
164
|
+
end
|
165
|
+
|
166
|
+
def self.studio_commands
|
167
|
+
@studio_commands ||= ['animate', 'append', 'call method', 'center',
|
168
|
+
'close drawer', 'close panel', 'display',
|
169
|
+
'display alert', 'display dialog', 'display panel', 'go',
|
170
|
+
'hide', 'highlight', 'increment', 'item for',
|
171
|
+
'load image', 'load movie', 'load nib', 'load panel',
|
172
|
+
'load sound', 'localized string', 'lock focus', 'log',
|
173
|
+
'open drawer', 'path for', 'pause', 'perform action',
|
174
|
+
'play', 'register', 'resume', 'scroll', 'select( all)?',
|
175
|
+
'show', 'size to fit', 'start', 'step back',
|
176
|
+
'step forward', 'stop', 'synchronize', 'unlock focus',
|
177
|
+
'update']
|
178
|
+
end
|
179
|
+
|
180
|
+
def self.studio_properties
|
181
|
+
@studio_properties ||= ['accepts arrow key', 'action method', 'active',
|
182
|
+
'alignment', 'allowed identifiers',
|
183
|
+
'allows branch selection', 'allows column reordering',
|
184
|
+
'allows column resizing', 'allows column selection',
|
185
|
+
'allows customization', 'allows editing text attributes',
|
186
|
+
'allows empty selection', 'allows mixed state',
|
187
|
+
'allows multiple selection', 'allows reordering',
|
188
|
+
'allows undo', 'alpha( value)?', 'alternate image',
|
189
|
+
'alternate increment value', 'alternate title',
|
190
|
+
'animation delay', 'associated file name',
|
191
|
+
'associated object', 'auto completes', 'auto display',
|
192
|
+
'auto enables items', 'auto repeat', 'auto resizes( outline column)?',
|
193
|
+
'auto save expanded items', 'auto save name',
|
194
|
+
'auto save table columns', 'auto saves configuration',
|
195
|
+
'auto scroll', 'auto sizes all columns to fit',
|
196
|
+
'auto sizes cells', 'background color', 'bezel state',
|
197
|
+
'bezel style', 'bezeled', 'border rect', 'border type',
|
198
|
+
'bordered', 'bounds( rotation)?', 'box type',
|
199
|
+
'button returned', 'button type',
|
200
|
+
'can choose directories', 'can choose files', 'can draw', 'can hide',
|
201
|
+
'cell( (background color|size|type))?', 'characters',
|
202
|
+
'class', 'click count', 'clicked( data)? column',
|
203
|
+
'clicked data item', 'clicked( data)? row',
|
204
|
+
'closeable', 'collating', 'color( (mode|panel))',
|
205
|
+
'command key down', 'configuration',
|
206
|
+
'content(s| (size|view( margins)?))?', 'context',
|
207
|
+
'continuous', 'control key down', 'control size',
|
208
|
+
'control tint', 'control view',
|
209
|
+
'controller visible', 'coordinate system',
|
210
|
+
'copies( on scroll)?', 'corner view', 'current cell',
|
211
|
+
'current column', 'current( field)? editor',
|
212
|
+
'current( menu)? item', 'current row',
|
213
|
+
'current tab view item', 'data source',
|
214
|
+
'default identifiers', 'delta (x|y|z)',
|
215
|
+
'destination window', 'directory', 'display mode',
|
216
|
+
'displayed cell', 'document( (edited|rect|view))?',
|
217
|
+
'double value', 'dragged column', 'dragged distance',
|
218
|
+
'dragged items', 'draws( cell)? background',
|
219
|
+
'draws grid', 'dynamically scrolls', 'echos bullets',
|
220
|
+
'edge', 'editable', 'edited( data)? column',
|
221
|
+
'edited data item', 'edited( data)? row', 'enabled',
|
222
|
+
'enclosing scroll view', 'ending page',
|
223
|
+
'error handling', 'event number', 'event type',
|
224
|
+
'excluded from windows menu', 'executable path',
|
225
|
+
'expanded', 'fax number', 'field editor', 'file kind',
|
226
|
+
'file name', 'file type', 'first responder',
|
227
|
+
'first visible column', 'flipped', 'floating',
|
228
|
+
'font( panel)?', 'formatter', 'frameworks path',
|
229
|
+
'frontmost', 'gave up', 'grid color', 'has data items',
|
230
|
+
'has horizontal ruler', 'has horizontal scroller',
|
231
|
+
'has parent data item', 'has resize indicator',
|
232
|
+
'has shadow', 'has sub menu', 'has vertical ruler',
|
233
|
+
'has vertical scroller', 'header cell', 'header view',
|
234
|
+
'hidden', 'hides when deactivated', 'highlights by',
|
235
|
+
'horizontal line scroll', 'horizontal page scroll',
|
236
|
+
'horizontal ruler view', 'horizontally resizable',
|
237
|
+
'icon image', 'id', 'identifier',
|
238
|
+
'ignores multiple clicks',
|
239
|
+
'image( (alignment|dims when disabled|frame style|scaling))?',
|
240
|
+
'imports graphics', 'increment value',
|
241
|
+
'indentation per level', 'indeterminate', 'index',
|
242
|
+
'integer value', 'intercell spacing', 'item height',
|
243
|
+
'key( (code|equivalent( modifier)?|window))?',
|
244
|
+
'knob thickness', 'label', 'last( visible)? column',
|
245
|
+
'leading offset', 'leaf', 'level', 'line scroll',
|
246
|
+
'loaded', 'localized sort', 'location', 'loop mode',
|
247
|
+
'main( (bunde|menu|window))?', 'marker follows cell',
|
248
|
+
'matrix mode', 'maximum( content)? size',
|
249
|
+
'maximum visible columns',
|
250
|
+
'menu( form representation)?', 'miniaturizable',
|
251
|
+
'miniaturized', 'minimized image', 'minimized title',
|
252
|
+
'minimum column width', 'minimum( content)? size',
|
253
|
+
'modal', 'modified', 'mouse down state',
|
254
|
+
'movie( (controller|file|rect))?', 'muted', 'name',
|
255
|
+
'needs display', 'next state', 'next text',
|
256
|
+
'number of tick marks', 'only tick mark values',
|
257
|
+
'opaque', 'open panel', 'option key down',
|
258
|
+
'outline table column', 'page scroll', 'pages across',
|
259
|
+
'pages down', 'palette label', 'pane splitter',
|
260
|
+
'parent data item', 'parent window', 'pasteboard',
|
261
|
+
'path( (names|separator))?', 'playing',
|
262
|
+
'plays every frame', 'plays selection only', 'position',
|
263
|
+
'preferred edge', 'preferred type', 'pressure',
|
264
|
+
'previous text', 'prompt', 'properties',
|
265
|
+
'prototype cell', 'pulls down', 'rate',
|
266
|
+
'released when closed', 'repeated',
|
267
|
+
'requested print time', 'required file type',
|
268
|
+
'resizable', 'resized column', 'resource path',
|
269
|
+
'returns records', 'reuses columns', 'rich text',
|
270
|
+
'roll over', 'row height', 'rulers visible',
|
271
|
+
'save panel', 'scripts path', 'scrollable',
|
272
|
+
'selectable( identifiers)?', 'selected cell',
|
273
|
+
'selected( data)? columns?', 'selected data items?',
|
274
|
+
'selected( data)? rows?', 'selected item identifier',
|
275
|
+
'selection by rect', 'send action on arrow key',
|
276
|
+
'sends action when done editing', 'separates columns',
|
277
|
+
'separator item', 'sequence number', 'services menu',
|
278
|
+
'shared frameworks path', 'shared support path',
|
279
|
+
'sheet', 'shift key down', 'shows alpha',
|
280
|
+
'shows state by', 'size( mode)?',
|
281
|
+
'smart insert delete enabled', 'sort case sensitivity',
|
282
|
+
'sort column', 'sort order', 'sort type',
|
283
|
+
'sorted( data rows)?', 'sound', 'source( mask)?',
|
284
|
+
'spell checking enabled', 'starting page', 'state',
|
285
|
+
'string value', 'sub menu', 'super menu', 'super view',
|
286
|
+
'tab key traverses cells', 'tab state', 'tab type',
|
287
|
+
'tab view', 'table view', 'tag', 'target( printer)?',
|
288
|
+
'text color', 'text container insert',
|
289
|
+
'text container origin', 'text returned',
|
290
|
+
'tick mark position', 'time stamp',
|
291
|
+
'title(d| (cell|font|height|position|rect))?',
|
292
|
+
'tool tip', 'toolbar', 'trailing offset', 'transparent',
|
293
|
+
'treat packages as directories', 'truncated labels',
|
294
|
+
'types', 'unmodified characters', 'update views',
|
295
|
+
'use sort indicator', 'user defaults',
|
296
|
+
'uses data source', 'uses ruler', 'uses threaded animation',
|
297
|
+
'uses title from previous column', 'value wraps', 'version',
|
298
|
+
'vertical( (line scroll|page scroll|ruler view))?', 'vertically resizable', 'view',
|
299
|
+
'visible( document rect)?', 'volume', 'width', 'window',
|
300
|
+
'windows menu', 'wraps', 'zoomable', 'zoomed']
|
301
|
+
end
|
302
|
+
|
303
|
+
operators = %r{\b(#{self.operators.to_a.join('|')})\b}
|
304
|
+
classes = %r{\b(as )(#{self.classes.to_a.join('|')})\b}
|
305
|
+
literals = %r{\b(#{self.literals.to_a.join('|')})\b}
|
306
|
+
commands = %r{\b(#{self.commands.to_a.join('|')})\b}
|
307
|
+
controls = %r{\b(#{self.controls.to_a.join('|')})\b}
|
308
|
+
declarations = %r{\b(#{self.declarations.to_a.join('|')})\b}
|
309
|
+
reserved = %r{\b(#{self.reserved.to_a.join('|')})\b}
|
310
|
+
builtins = %r{\b(#{self.builtins.to_a.join('|')})s?\b}
|
311
|
+
handler_params = %r{\b(#{self.handler_params.to_a.join('|')})\b}
|
312
|
+
references = %r{\b(#{self.references.to_a.join('|')})\b}
|
313
|
+
studio_properties = %r{\b(#{self.studio_properties.to_a.join('|')})\b}
|
314
|
+
studio_classes = %r{\b(#{self.studio_classes.to_a.join('|')})s?\b}
|
315
|
+
studio_commands = %r{\b(#{self.studio_commands.to_a.join('|')})\b}
|
316
|
+
identifiers = %r{\b([a-zA-Z]\w*)\b}
|
317
|
+
|
318
|
+
state :root do
|
319
|
+
rule /\s+/, Text::Whitespace
|
320
|
+
rule /¬\n/, Literal::String::Escape
|
321
|
+
rule /'s\s+/, Text
|
322
|
+
rule /(--|#).*?$/, Comment::Single
|
323
|
+
rule /\(\*/, Comment::Multiline
|
324
|
+
rule /[\(\){}!,.:]/, Punctuation
|
325
|
+
rule /(«)([^»]+)(»)/ do |match|
|
326
|
+
token Text, match[1]
|
327
|
+
token Name::Builtin, match[2]
|
328
|
+
token Text, match[3]
|
329
|
+
end
|
330
|
+
rule /\b((?:considering|ignoring)\s*)(application responses|case|diacriticals|hyphens|numeric strings|punctuation|white space)/ do |match|
|
331
|
+
token Keyword, match[1]
|
332
|
+
token Name::Builtin, match[2]
|
333
|
+
end
|
334
|
+
rule /(-|\*|\+|&|≠|>=?|<=?|=|≥|≤|\/|÷|\^)/, Operator
|
335
|
+
rule operators, Operator::Word
|
336
|
+
rule /^(\s*(?:on|end)\s+)'r'(%s)/ do |match|
|
337
|
+
token Keyword, match[1]
|
338
|
+
token Name::Function, match[2]
|
339
|
+
end
|
340
|
+
rule /^(\s*)(in|on|script|to)(\s+)/ do |match|
|
341
|
+
token Text, match[1]
|
342
|
+
token Keyword, match[2]
|
343
|
+
token Text, match[3]
|
344
|
+
end
|
345
|
+
rule classes do |match|
|
346
|
+
token Keyword, match[1]
|
347
|
+
token Name::Class, match[2]
|
348
|
+
end
|
349
|
+
rule commands, Name::Builtin
|
350
|
+
rule controls, Keyword
|
351
|
+
rule declarations, Keyword
|
352
|
+
rule reserved, Name::Builtin
|
353
|
+
rule builtins, Name::Builtin
|
354
|
+
rule handler_params, Name::Builtin
|
355
|
+
rule studio_properties, Name::Attribute
|
356
|
+
rule studio_classes, Name::Builtin
|
357
|
+
rule studio_commands, Name::Builtin
|
358
|
+
rule references, Name::Builtin
|
359
|
+
rule /"(\\\\|\\"|[^"])*"/, Literal::String::Double
|
360
|
+
rule identifiers, Name::Variable
|
361
|
+
rule /[-+]?(\d+\.\d*|\d*\.\d+)(E[-+][0-9]+)?/, Literal::Number::Float
|
362
|
+
rule /[-+]?\d+/, Literal::Number::Integer
|
363
|
+
end
|
364
|
+
end
|
365
|
+
end
|
366
|
+
end
|
@@ -0,0 +1,210 @@
|
|
1
|
+
module Rugments
|
2
|
+
module Lexers
|
3
|
+
class C < RegexLexer
|
4
|
+
tag 'c'
|
5
|
+
filenames '*.c', '*.h', '*.idc'
|
6
|
+
mimetypes 'text/x-chdr', 'text/x-csrc'
|
7
|
+
|
8
|
+
title 'C'
|
9
|
+
desc 'The C programming language'
|
10
|
+
|
11
|
+
# optional comment or whitespace
|
12
|
+
ws = %r{(?:\s|//.*?\n|/[*].*?[*]/)+}
|
13
|
+
id = /[a-zA-Z_][a-zA-Z0-9_]*/
|
14
|
+
|
15
|
+
def self.keywords
|
16
|
+
@keywords ||= Set.new %w(
|
17
|
+
auto break case const continue default do else enum extern
|
18
|
+
for goto if register restricted return sizeof static struct
|
19
|
+
switch typedef union volatile virtual while
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.keywords_type
|
24
|
+
@keywords_type ||= Set.new %w(
|
25
|
+
int long float short double char unsigned signed void
|
26
|
+
|
27
|
+
jmp_buf FILE DIR div_t ldiv_t mbstate_t sig_atomic_t fpos_t
|
28
|
+
clock_t time_t va_list size_t ssize_t off_t wchar_t ptrdiff_t
|
29
|
+
wctrans_t wint_t wctype_t
|
30
|
+
|
31
|
+
_Bool _Complex int8_t int16_t int32_t int64_t
|
32
|
+
uint8_t uint16_t uint32_t uint64_t int_least8_t
|
33
|
+
int_least16_t int_least32_t int_least64_t
|
34
|
+
uint_least8_t uint_least16_t uint_least32_t
|
35
|
+
uint_least64_t int_fast8_t int_fast16_t int_fast32_t
|
36
|
+
int_fast64_t uint_fast8_t uint_fast16_t uint_fast32_t
|
37
|
+
uint_fast64_t intptr_t uintptr_t intmax_t
|
38
|
+
uintmax_t
|
39
|
+
)
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.reserved
|
43
|
+
@reserved ||= Set.new %w(
|
44
|
+
__asm __int8 __based __except __int16 __stdcall __cdecl
|
45
|
+
__fastcall __int32 __declspec __finally __int61 __try __leave
|
46
|
+
inline _inline __inline naked _naked __naked restrict _restrict
|
47
|
+
__restrict thread _thread __thread typename _typename __typename
|
48
|
+
)
|
49
|
+
end
|
50
|
+
|
51
|
+
# high priority for filename matches
|
52
|
+
def self.analyze_text(*)
|
53
|
+
0.3
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.builtins
|
57
|
+
@builtins ||= []
|
58
|
+
end
|
59
|
+
|
60
|
+
start { push :bol }
|
61
|
+
|
62
|
+
state :expr_bol do
|
63
|
+
mixin :inline_whitespace
|
64
|
+
|
65
|
+
rule /#if\s0/, Comment, :if_0
|
66
|
+
rule /#/, Comment::Preproc, :macro
|
67
|
+
|
68
|
+
rule(//) { pop! }
|
69
|
+
end
|
70
|
+
|
71
|
+
# :expr_bol is the same as :bol but without labels, since
|
72
|
+
# labels can only appear at the beginning of a statement.
|
73
|
+
state :bol do
|
74
|
+
rule /#{id}:(?!:)/, Name::Label
|
75
|
+
mixin :expr_bol
|
76
|
+
end
|
77
|
+
|
78
|
+
state :inline_whitespace do
|
79
|
+
rule /[ \t\r]+/, Text
|
80
|
+
rule /\\\n/, Text # line continuation
|
81
|
+
rule %r{/(\\\n)?[*].*?[*](\\\n)?/}m, Comment::Multiline
|
82
|
+
end
|
83
|
+
|
84
|
+
state :whitespace do
|
85
|
+
rule /\n+/m, Text, :bol
|
86
|
+
rule %r{//(\\.|.)*?\n}, Comment::Single, :bol
|
87
|
+
mixin :inline_whitespace
|
88
|
+
end
|
89
|
+
|
90
|
+
state :expr_whitespace do
|
91
|
+
rule /\n+/m, Text, :expr_bol
|
92
|
+
mixin :whitespace
|
93
|
+
end
|
94
|
+
|
95
|
+
state :statements do
|
96
|
+
mixin :whitespace
|
97
|
+
rule /L?"/, Str, :string
|
98
|
+
rule %r(L?'(\\.|\\[0-7]{1,3}|\\x[a-f0-9]{1,2}|[^\\'\n])')i, Str::Char
|
99
|
+
rule %r{(\d+[.]\d*|[.]?\d+)e[+-]?\d+[lu]*}i, Num::Float
|
100
|
+
rule %r{\d+e[+-]?\d+[lu]*}i, Num::Float
|
101
|
+
rule /0x[0-9a-f]+[lu]*/i, Num::Hex
|
102
|
+
rule /0[0-7]+[lu]*/i, Num::Oct
|
103
|
+
rule /\d+[lu]*/i, Num::Integer
|
104
|
+
rule %r{\*/}, Error
|
105
|
+
rule %r{[~!%^&*+=\|?:<>/-]}, Operator
|
106
|
+
rule /[()\[\],.]/, Punctuation
|
107
|
+
rule /\bcase\b/, Keyword, :case
|
108
|
+
rule /(?:true|false|NULL)\b/, Name::Builtin
|
109
|
+
rule id do |m|
|
110
|
+
name = m[0]
|
111
|
+
|
112
|
+
if self.class.keywords.include? name
|
113
|
+
token Keyword
|
114
|
+
elsif self.class.keywords_type.include? name
|
115
|
+
token Keyword::Type
|
116
|
+
elsif self.class.reserved.include? name
|
117
|
+
token Keyword::Reserved
|
118
|
+
elsif self.class.builtins.include? name
|
119
|
+
token Name::Builtin
|
120
|
+
else
|
121
|
+
token Name
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
state :case do
|
127
|
+
rule /:/, Punctuation, :pop!
|
128
|
+
mixin :statements
|
129
|
+
end
|
130
|
+
|
131
|
+
state :root do
|
132
|
+
mixin :expr_whitespace
|
133
|
+
|
134
|
+
# functions
|
135
|
+
rule %r(
|
136
|
+
([\w*\s]+?[\s*]) # return arguments
|
137
|
+
(#{id}) # function name
|
138
|
+
(\s*\([^;]*?\)) # signature
|
139
|
+
(#{ws})({) # open brace
|
140
|
+
)mx do |m|
|
141
|
+
# TODO: do this better.
|
142
|
+
recurse m[1]
|
143
|
+
token Name::Function, m[2]
|
144
|
+
recurse m[3]
|
145
|
+
recurse m[4]
|
146
|
+
token Punctuation, m[5]
|
147
|
+
push :function
|
148
|
+
end
|
149
|
+
|
150
|
+
# function declarations
|
151
|
+
rule %r{
|
152
|
+
([\w*\s]+?[\s*]) # return arguments
|
153
|
+
(#{id}) # function name
|
154
|
+
(\s*\([^;]*?\)) # signature
|
155
|
+
(#{ws})(;) # semicolon
|
156
|
+
}mx do |m|
|
157
|
+
# TODO: do this better.
|
158
|
+
recurse m[1]
|
159
|
+
token Name::Function
|
160
|
+
recurse m[3]
|
161
|
+
recurse m[4]
|
162
|
+
token Punctuation
|
163
|
+
push :statement
|
164
|
+
end
|
165
|
+
|
166
|
+
rule(//) { push :statement }
|
167
|
+
end
|
168
|
+
|
169
|
+
state :statement do
|
170
|
+
rule /;/, Punctuation, :pop!
|
171
|
+
mixin :expr_whitespace
|
172
|
+
mixin :statements
|
173
|
+
rule /[{}]/, Punctuation
|
174
|
+
end
|
175
|
+
|
176
|
+
state :function do
|
177
|
+
mixin :whitespace
|
178
|
+
mixin :statements
|
179
|
+
rule /;/, Punctuation
|
180
|
+
rule /{/, Punctuation, :function
|
181
|
+
rule /}/, Punctuation, :pop!
|
182
|
+
end
|
183
|
+
|
184
|
+
state :string do
|
185
|
+
rule /"/, Str, :pop!
|
186
|
+
rule /\\([\\abfnrtv"']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})/, Str::Escape
|
187
|
+
rule /[^\\"\n]+/, Str
|
188
|
+
rule /\\\n/, Str
|
189
|
+
rule /\\/, Str # stray backslash
|
190
|
+
end
|
191
|
+
|
192
|
+
state :macro do
|
193
|
+
# NB: pop! goes back to :bol
|
194
|
+
rule /\n/, Comment::Preproc, :pop!
|
195
|
+
rule %r{[^/\n\\]+}, Comment::Preproc
|
196
|
+
rule /\\./m, Comment::Preproc
|
197
|
+
mixin :inline_whitespace
|
198
|
+
rule %r{/}, Comment::Preproc
|
199
|
+
end
|
200
|
+
|
201
|
+
state :if_0 do
|
202
|
+
# NB: no \b here, to cover #ifdef and #ifndef
|
203
|
+
rule /^\s*#if/, Comment, :if_0
|
204
|
+
rule /^\s*#\s*el(?:se|if)/, Comment, :pop!
|
205
|
+
rule /^\s*#\s*endif\b.*?(?<!\\)\n/m, Comment, :pop!
|
206
|
+
rule /.*?\n/, Comment
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|