Skip to content

Commit b979b7e

Browse files
committed
ooops. a future improvements stuck in there. this is just a regeneration of everything to get a clean 1.4.17 output with all files.
1 parent 0eecdb7 commit b979b7e

623 files changed

Lines changed: 172951 additions & 2 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

output/antlr/1.4.17/C.g4

Lines changed: 834 additions & 0 deletions
Large diffs are not rendered by default.

output/antlr/1.4.17/Clojure.g4

Lines changed: 313 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,313 @@
1+
/* Reworked for grammar specificity by Reid Mckenzie. Did a bunch of
2+
work so that rather than reading "a bunch of crap in parens" some
3+
syntactic information is preserved and recovered. Dec. 14 2014.
4+
5+
Converted to ANTLR 4 by Terence Parr. Unsure of provence. I see
6+
it commited by matthias.koester for clojure-eclipse project on
7+
Oct 5, 2009:
8+
9+
https://code.google.com/p/clojure-eclipse/
10+
11+
Seems to me Laurent Petit had a version of this. I also see
12+
Jingguo Yao submitting a link to a now-dead github project on
13+
Jan 1, 2011.
14+
15+
https://github.com/laurentpetit/ccw/tree/master/clojure-antlr-grammar
16+
17+
Regardless, there are some issues perhaps related to "sugar";
18+
I've tried to fix them.
19+
20+
This parses https://github.com/weavejester/compojure project.
21+
22+
I also note this is hardly a grammar; more like "match a bunch of
23+
crap in parens" but I guess that is LISP for you ;)
24+
*/
25+
26+
grammar Clojure;
27+
28+
file
29+
: form*
30+
;
31+
32+
form
33+
: literal
34+
| list
35+
| vector
36+
| map
37+
| reader_macro
38+
;
39+
40+
forms
41+
: form*
42+
;
43+
44+
list
45+
: '(' forms ')'
46+
;
47+
48+
vector
49+
: '[' forms ']'
50+
;
51+
52+
map
53+
: '{' (form form)* '}'
54+
;
55+
56+
set
57+
: '#{' forms '}'
58+
;
59+
60+
reader_macro
61+
: lambda
62+
| meta_data
63+
| regex
64+
| var_quote
65+
| host_expr
66+
| set
67+
| tag
68+
| discard
69+
| dispatch
70+
| deref
71+
| quote
72+
| backtick
73+
| unquote
74+
| unquote_splicing
75+
| gensym
76+
;
77+
78+
// TJP added '&' (gather a variable number of arguments)
79+
80+
quote
81+
: '\'' form
82+
;
83+
84+
backtick
85+
: '`' form
86+
;
87+
88+
unquote
89+
: '~' form
90+
;
91+
92+
unquote_splicing
93+
: '~@' form
94+
;
95+
96+
tag
97+
: '^' form form
98+
;
99+
100+
deref
101+
: '@' form
102+
;
103+
104+
gensym
105+
: SYMBOL '#'
106+
;
107+
108+
lambda
109+
: '#(' form* ')'
110+
;
111+
112+
meta_data
113+
: '#^' (map form | form)
114+
;
115+
116+
var_quote
117+
: '#\'' symbol
118+
;
119+
120+
host_expr
121+
: '#+' form form
122+
;
123+
124+
discard
125+
: '#_' form
126+
;
127+
128+
dispatch
129+
: '#' symbol form
130+
;
131+
132+
regex
133+
: '#' string
134+
;
135+
136+
literal
137+
: string
138+
| number
139+
| character
140+
| nil
141+
| BOOLEAN
142+
| keyword
143+
| symbol
144+
| param_name
145+
;
146+
147+
string
148+
: STRING
149+
;
150+
151+
hex
152+
: HEX
153+
;
154+
155+
bin
156+
: BIN
157+
;
158+
159+
bign
160+
: BIGN
161+
;
162+
163+
number
164+
: FLOAT
165+
| hex
166+
| bin
167+
| bign
168+
| LONG
169+
;
170+
171+
character
172+
: named_char
173+
| u_hex_quad
174+
| any_char
175+
;
176+
177+
named_char
178+
: CHAR_NAMED
179+
;
180+
181+
any_char
182+
: CHAR_ANY
183+
;
184+
185+
u_hex_quad
186+
: CHAR_U
187+
;
188+
189+
nil
190+
: NIL
191+
;
192+
193+
keyword
194+
: macro_keyword
195+
| simple_keyword
196+
;
197+
198+
simple_keyword
199+
: ':' symbol
200+
;
201+
202+
macro_keyword
203+
: ':' ':' symbol
204+
;
205+
206+
symbol
207+
: ns_symbol
208+
| simple_sym
209+
;
210+
211+
simple_sym
212+
: SYMBOL
213+
;
214+
215+
ns_symbol
216+
: NS_SYMBOL
217+
;
218+
219+
param_name
220+
: PARAM_NAME
221+
;
222+
223+
// Lexers
224+
//--------------------------------------------------------------------
225+
226+
STRING : '"' (~'"'| '\\' '"')* '"' ;
227+
228+
// FIXME: Doesn't deal with arbitrary read radixes, BigNums
229+
FLOAT
230+
: '-'? [0-9]+ FLOAT_TAIL
231+
| '-'? 'Infinity'
232+
| '-'? 'NaN'
233+
;
234+
235+
fragment
236+
FLOAT_TAIL
237+
: FLOAT_DECIMAL FLOAT_EXP
238+
| FLOAT_DECIMAL
239+
| FLOAT_EXP
240+
;
241+
242+
fragment
243+
FLOAT_DECIMAL
244+
: '.' [0-9]+
245+
;
246+
247+
fragment
248+
FLOAT_EXP
249+
: [eE] '-'? [0-9]+
250+
;
251+
252+
fragment
253+
HEXD
254+
: [0-9a-fA-F]
255+
;
256+
257+
HEX : '0' [xX] HEXD+ ;
258+
BIN : '0' [bB] [10]+ ;
259+
LONG : '-'? [0-9]+ [lL]? ;
260+
BIGN : '-'? [0-9]+ [nN] ;
261+
CHAR_U : '\\' 'u' [0-9D-Fd-f] HEXD HEXD HEXD ;
262+
CHAR_NAMED : '\\'
263+
( 'newline'
264+
| 'return'
265+
| 'space'
266+
| 'tab'
267+
| 'formfeed'
268+
| 'backspace'
269+
) ;
270+
CHAR_ANY : '\\' . ;
271+
NIL : 'nil' ;
272+
BOOLEAN
273+
: 'true' | 'false'
274+
;
275+
276+
SYMBOL
277+
: '.' | '/' | NAME
278+
;
279+
280+
NS_SYMBOL : NAME '/' SYMBOL ;
281+
PARAM_NAME : '%' ([1-9] [0-9]*| '&')? ;
282+
283+
// Fragments
284+
//--------------------------------------------------------------------
285+
fragment
286+
NAME
287+
: SYMBOL_HEAD SYMBOL_REST* (':' SYMBOL_REST+)*
288+
;
289+
290+
fragment
291+
SYMBOL_HEAD
292+
: ~[0-9^`;"#~@:/%(){} \n\r\t\\,\[\]] // FIXME: could be WS
293+
;
294+
295+
fragment
296+
SYMBOL_REST
297+
: SYMBOL_HEAD | [0-9.]
298+
;
299+
300+
// Discard
301+
//--------------------------------------------------------------------
302+
303+
fragment
304+
WS
305+
: [ \n\r\t\,]
306+
;
307+
308+
fragment
309+
COMMENT
310+
: ';' ~[\r\n]*
311+
;
312+
313+
TRASH : (WS | COMMENT) -> channel(HIDDEN) ;

output/antlr/1.4.17/JSON.g4

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/** Taken from "The Definitive ANTLR 4 Reference" by Terence Parr */
2+
grammar JSON; // Derived from http://json.org
3+
4+
json
5+
: object
6+
| array
7+
;
8+
9+
object
10+
: '{' pair (',' pair)* '}'
11+
| '{' '}'
12+
;
13+
14+
pair
15+
: STRING ':' value
16+
;
17+
18+
array
19+
: '[' value (',' value)* ']'
20+
| '[' ']'
21+
;
22+
23+
value : STRING | NUMBER | object | array | 'true' | 'false' | 'null' ;
24+
STRING : '"' (ESC | ~["\\])* '"' ;
25+
fragment
26+
ESC
27+
: '\\' (["\\/bfnrt]| UNICODE)
28+
;
29+
30+
fragment
31+
UNICODE
32+
: 'u' HEX HEX HEX HEX
33+
;
34+
35+
fragment
36+
HEX
37+
: [0-9a-fA-F]
38+
;
39+
40+
NUMBER
41+
: '-'? INT '.' [0-9]+ EXP?
42+
| '-'? INT EXP
43+
| '-'? INT
44+
;
45+
46+
fragment
47+
INT
48+
: '0' | [1-9] [0-9]*
49+
;
50+
51+
// no leading zeros
52+
53+
fragment
54+
EXP
55+
: [Ee] [+\-]? INT
56+
;
57+
58+
// \- since - means "range" inside [...]
59+
60+
WS : [ \t\n\r]+ -> skip ;

0 commit comments

Comments
 (0)