haml-more 0.4.0.a
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +79 -0
- data/lib/haml/more/coffee_script.rb +137 -0
- data/lib/haml/more/content_for.rb +25 -0
- data/lib/haml/more.rb +45 -0
- data/lib/haml-more.rb +1 -0
- data/lib/sass/more.rb +16 -0
- data/lib/sass-more.rb +1 -0
- data/spec/sass/more_spec.rb +21 -0
- data/vendor/coffee-script/Cakefile +57 -0
- data/vendor/coffee-script/LICENSE +22 -0
- data/vendor/coffee-script/README +41 -0
- data/vendor/coffee-script/Rakefile +20 -0
- data/vendor/coffee-script/bin/cake +7 -0
- data/vendor/coffee-script/bin/coffee +7 -0
- data/vendor/coffee-script/documentation/coffee/aliases.coffee +9 -0
- data/vendor/coffee-script/documentation/coffee/arguments.coffee +4 -0
- data/vendor/coffee-script/documentation/coffee/array_comprehensions.coffee +7 -0
- data/vendor/coffee-script/documentation/coffee/assignment.coffee +2 -0
- data/vendor/coffee-script/documentation/coffee/cake_tasks.coffee +5 -0
- data/vendor/coffee-script/documentation/coffee/comparisons.coffee +5 -0
- data/vendor/coffee-script/documentation/coffee/conditionals.coffee +9 -0
- data/vendor/coffee-script/documentation/coffee/embedded.coffee +5 -0
- data/vendor/coffee-script/documentation/coffee/existence.coffee +8 -0
- data/vendor/coffee-script/documentation/coffee/expressions.coffee +9 -0
- data/vendor/coffee-script/documentation/coffee/expressions_assignment.coffee +1 -0
- data/vendor/coffee-script/documentation/coffee/expressions_comprehension.coffee +3 -0
- data/vendor/coffee-script/documentation/coffee/expressions_try.coffee +6 -0
- data/vendor/coffee-script/documentation/coffee/fat_arrow.coffee +6 -0
- data/vendor/coffee-script/documentation/coffee/functions.coffee +2 -0
- data/vendor/coffee-script/documentation/coffee/heredocs.coffee +5 -0
- data/vendor/coffee-script/documentation/coffee/multiple_return_values.coffee +5 -0
- data/vendor/coffee-script/documentation/coffee/object_comprehensions.coffee +4 -0
- data/vendor/coffee-script/documentation/coffee/object_extraction.coffee +13 -0
- data/vendor/coffee-script/documentation/coffee/objects_and_arrays.coffee +13 -0
- data/vendor/coffee-script/documentation/coffee/overview.coffee +29 -0
- data/vendor/coffee-script/documentation/coffee/parallel_assignment.coffee +4 -0
- data/vendor/coffee-script/documentation/coffee/range_comprehensions.coffee +6 -0
- data/vendor/coffee-script/documentation/coffee/scope.coffee +5 -0
- data/vendor/coffee-script/documentation/coffee/slices.coffee +6 -0
- data/vendor/coffee-script/documentation/coffee/soaks.coffee +1 -0
- data/vendor/coffee-script/documentation/coffee/splats.coffee +25 -0
- data/vendor/coffee-script/documentation/coffee/splices.coffee +5 -0
- data/vendor/coffee-script/documentation/coffee/strings.coffee +8 -0
- data/vendor/coffee-script/documentation/coffee/super.coffee +34 -0
- data/vendor/coffee-script/documentation/coffee/switch.coffee +10 -0
- data/vendor/coffee-script/documentation/coffee/try.coffee +7 -0
- data/vendor/coffee-script/documentation/coffee/while.coffee +10 -0
- data/vendor/coffee-script/documentation/css/docs.css +213 -0
- data/vendor/coffee-script/documentation/css/idle.css +63 -0
- data/vendor/coffee-script/documentation/css/logo.png +0 -0
- data/vendor/coffee-script/documentation/index.html.erb +967 -0
- data/vendor/coffee-script/documentation/js/aliases.js +14 -0
- data/vendor/coffee-script/documentation/js/arguments.js +8 -0
- data/vendor/coffee-script/documentation/js/array_comprehensions.js +26 -0
- data/vendor/coffee-script/documentation/js/assignment.js +5 -0
- data/vendor/coffee-script/documentation/js/cake_tasks.js +14 -0
- data/vendor/coffee-script/documentation/js/comparisons.js +5 -0
- data/vendor/coffee-script/documentation/js/conditionals.js +12 -0
- data/vendor/coffee-script/documentation/js/embedded.js +6 -0
- data/vendor/coffee-script/documentation/js/existence.js +7 -0
- data/vendor/coffee-script/documentation/js/expressions.js +13 -0
- data/vendor/coffee-script/documentation/js/expressions_assignment.js +4 -0
- data/vendor/coffee-script/documentation/js/expressions_comprehension.js +12 -0
- data/vendor/coffee-script/documentation/js/expressions_try.js +9 -0
- data/vendor/coffee-script/documentation/js/fat_arrow.js +15 -0
- data/vendor/coffee-script/documentation/js/functions.js +9 -0
- data/vendor/coffee-script/documentation/js/heredocs.js +4 -0
- data/vendor/coffee-script/documentation/js/intro.js +7 -0
- data/vendor/coffee-script/documentation/js/multiple_return_values.js +11 -0
- data/vendor/coffee-script/documentation/js/object_comprehensions.js +17 -0
- data/vendor/coffee-script/documentation/js/object_extraction.js +17 -0
- data/vendor/coffee-script/documentation/js/objects_and_arrays.js +10 -0
- data/vendor/coffee-script/documentation/js/overview.js +43 -0
- data/vendor/coffee-script/documentation/js/parallel_assignment.js +8 -0
- data/vendor/coffee-script/documentation/js/punctuation.js +8 -0
- data/vendor/coffee-script/documentation/js/range_comprehensions.js +21 -0
- data/vendor/coffee-script/documentation/js/scope.js +10 -0
- data/vendor/coffee-script/documentation/js/slices.js +6 -0
- data/vendor/coffee-script/documentation/js/soaks.js +4 -0
- data/vendor/coffee-script/documentation/js/splats.js +16 -0
- data/vendor/coffee-script/documentation/js/splices.js +5 -0
- data/vendor/coffee-script/documentation/js/strings.js +9 -0
- data/vendor/coffee-script/documentation/js/super.js +37 -0
- data/vendor/coffee-script/documentation/js/switch.js +18 -0
- data/vendor/coffee-script/documentation/js/try.js +10 -0
- data/vendor/coffee-script/documentation/js/while.js +22 -0
- data/vendor/coffee-script/documentation/underscore.html +627 -0
- data/vendor/coffee-script/examples/beautiful_code/binary_search.coffee +16 -0
- data/vendor/coffee-script/examples/beautiful_code/quicksort_runtime.coffee +13 -0
- data/vendor/coffee-script/examples/beautiful_code/regular_expression_matcher.coffee +34 -0
- data/vendor/coffee-script/examples/blocks.coffee +57 -0
- data/vendor/coffee-script/examples/code.coffee +173 -0
- data/vendor/coffee-script/examples/computer_science/README +4 -0
- data/vendor/coffee-script/examples/computer_science/binary_search.coffee +25 -0
- data/vendor/coffee-script/examples/computer_science/bubble_sort.coffee +11 -0
- data/vendor/coffee-script/examples/computer_science/linked_list.coffee +106 -0
- data/vendor/coffee-script/examples/computer_science/luhn_algorithm.coffee +36 -0
- data/vendor/coffee-script/examples/computer_science/merge_sort.coffee +19 -0
- data/vendor/coffee-script/examples/computer_science/selection_sort.coffee +23 -0
- data/vendor/coffee-script/examples/poignant.coffee +186 -0
- data/vendor/coffee-script/examples/potion.coffee +205 -0
- data/vendor/coffee-script/examples/underscore.coffee +603 -0
- data/vendor/coffee-script/examples/web_server.coffee +12 -0
- data/vendor/coffee-script/extras/CoffeeScript.tmbundle/Preferences/CoffeeScript.tmPreferences +24 -0
- data/vendor/coffee-script/extras/CoffeeScript.tmbundle/Syntaxes/CoffeeScript.tmLanguage +361 -0
- data/vendor/coffee-script/extras/CoffeeScript.tmbundle/info.plist +10 -0
- data/vendor/coffee-script/extras/EXTRAS +20 -0
- data/vendor/coffee-script/extras/coffee.vim +117 -0
- data/vendor/coffee-script/index.html +1847 -0
- data/vendor/coffee-script/lib/bin/cake +7 -0
- data/vendor/coffee-script/lib/bin/coffee +7 -0
- data/vendor/coffee-script/lib/cake.js +80 -0
- data/vendor/coffee-script/lib/coffee-script.js +61 -0
- data/vendor/coffee-script/lib/command_line.js +201 -0
- data/vendor/coffee-script/lib/grammar.js +564 -0
- data/vendor/coffee-script/lib/lexer.js +405 -0
- data/vendor/coffee-script/lib/narwhal.js +44 -0
- data/vendor/coffee-script/lib/nodes.js +1328 -0
- data/vendor/coffee-script/lib/optparse.js +117 -0
- data/vendor/coffee-script/lib/parser.js +536 -0
- data/vendor/coffee-script/lib/repl.js +32 -0
- data/vendor/coffee-script/lib/rewriter.js +383 -0
- data/vendor/coffee-script/lib/scope.js +114 -0
- data/vendor/coffee-script/package.json +7 -0
- data/vendor/coffee-script/src/cake.coffee +45 -0
- data/vendor/coffee-script/src/coffee-script.coffee +45 -0
- data/vendor/coffee-script/src/command_line.coffee +130 -0
- data/vendor/coffee-script/src/grammar.coffee +456 -0
- data/vendor/coffee-script/src/lexer.coffee +327 -0
- data/vendor/coffee-script/src/narwhal.coffee +42 -0
- data/vendor/coffee-script/src/nodes.coffee +1045 -0
- data/vendor/coffee-script/src/optparse.coffee +79 -0
- data/vendor/coffee-script/src/repl.coffee +23 -0
- data/vendor/coffee-script/src/rewriter.coffee +253 -0
- data/vendor/coffee-script/src/scope.coffee +75 -0
- data/vendor/coffee-script/test/test_arguments.coffee +34 -0
- data/vendor/coffee-script/test/test_array_comprehension.coffee +42 -0
- data/vendor/coffee-script/test/test_assignment.coffee +26 -0
- data/vendor/coffee-script/test/test_blocks.coffee +4 -0
- data/vendor/coffee-script/test/test_calling_super.coffee +42 -0
- data/vendor/coffee-script/test/test_chained_calls.coffee +25 -0
- data/vendor/coffee-script/test/test_destructuring_assignment.coffee +62 -0
- data/vendor/coffee-script/test/test_everything.coffee +29 -0
- data/vendor/coffee-script/test/test_exceptions.coffee +2 -0
- data/vendor/coffee-script/test/test_existence.coffee +81 -0
- data/vendor/coffee-script/test/test_expressions.coffee +30 -0
- data/vendor/coffee-script/test/test_fancy_if_statement.coffee +26 -0
- data/vendor/coffee-script/test/test_functions.coffee +80 -0
- data/vendor/coffee-script/test/test_funky_comments.coffee +25 -0
- data/vendor/coffee-script/test/test_heredocs.coffee +46 -0
- data/vendor/coffee-script/test/test_lexical_scope.coffee +10 -0
- data/vendor/coffee-script/test/test_literals.coffee +56 -0
- data/vendor/coffee-script/test/test_nested_comprehensions.coffee +11 -0
- data/vendor/coffee-script/test/test_newline_escaping.coffee +6 -0
- data/vendor/coffee-script/test/test_operations.coffee +18 -0
- data/vendor/coffee-script/test/test_range_comprehension.coffee +20 -0
- data/vendor/coffee-script/test/test_ranges_and_slices.coffee +16 -0
- data/vendor/coffee-script/test/test_splats.coffee +47 -0
- data/vendor/coffee-script/test/test_splices.coffee +5 -0
- data/vendor/coffee-script/test/test_switch.coffee +64 -0
- data/vendor/coffee-script/test/test_while.coffee +30 -0
- data/vendor/coffee-script/vendor/jison/Jakefile +31 -0
- data/vendor/coffee-script/vendor/jison/README.md +347 -0
- data/vendor/coffee-script/vendor/jison/bin/jison +3 -0
- data/vendor/coffee-script/vendor/jison/bin/json2jison +3 -0
- data/vendor/coffee-script/vendor/jison/examples/ansic.jison +415 -0
- data/vendor/coffee-script/vendor/jison/examples/basic.json +8 -0
- data/vendor/coffee-script/vendor/jison/examples/basic2.json +9 -0
- data/vendor/coffee-script/vendor/jison/examples/basic2_lex.json +16 -0
- data/vendor/coffee-script/vendor/jison/examples/basic_lex.json +15 -0
- data/vendor/coffee-script/vendor/jison/examples/calculator.jison +38 -0
- data/vendor/coffee-script/vendor/jison/examples/calculator.jisonlex +14 -0
- data/vendor/coffee-script/vendor/jison/examples/calculator.json +42 -0
- data/vendor/coffee-script/vendor/jison/examples/classy.json +105 -0
- data/vendor/coffee-script/vendor/jison/examples/classy_ast.json +126 -0
- data/vendor/coffee-script/vendor/jison/examples/dism.json +25 -0
- data/vendor/coffee-script/vendor/jison/examples/dism_lr0.json +26 -0
- data/vendor/coffee-script/vendor/jison/examples/json.js +80 -0
- data/vendor/coffee-script/vendor/jison/examples/json_ast.js +83 -0
- data/vendor/coffee-script/vendor/jison/examples/precedence.json +26 -0
- data/vendor/coffee-script/vendor/jison/examples/reduce_conflict.json +13 -0
- data/vendor/coffee-script/vendor/jison/lib/jison/bnf.js +43 -0
- data/vendor/coffee-script/vendor/jison/lib/jison/jisonlex.js +18 -0
- data/vendor/coffee-script/vendor/jison/lib/jison/json2jison.js +146 -0
- data/vendor/coffee-script/vendor/jison/lib/jison/lexer.js +224 -0
- data/vendor/coffee-script/vendor/jison/lib/jison/util/bnf-parser.js +383 -0
- data/vendor/coffee-script/vendor/jison/lib/jison/util/lex-parser.js +407 -0
- data/vendor/coffee-script/vendor/jison/lib/jison/util/set.js +94 -0
- data/vendor/coffee-script/vendor/jison/lib/jison/util/typal.js +90 -0
- data/vendor/coffee-script/vendor/jison/lib/jison.js +1414 -0
- data/vendor/coffee-script/vendor/jison/package.json +14 -0
- data/vendor/coffee-script/vendor/jison/src/bnf.jison +110 -0
- data/vendor/coffee-script/vendor/jison/src/bnf.jisonlex +25 -0
- data/vendor/coffee-script/vendor/jison/src/bnf.lex.json +24 -0
- data/vendor/coffee-script/vendor/jison/src/jisonlex.jison +129 -0
- data/vendor/coffee-script/vendor/jison/src/jisonlex.jisonlex +31 -0
- data/vendor/coffee-script/vendor/jison/src/jisonlex.lex.json +30 -0
- data/vendor/coffee-script/vendor/jison/tests/all-tests.js +8 -0
- data/vendor/coffee-script/vendor/jison/tests/grammar/bnf.js +91 -0
- data/vendor/coffee-script/vendor/jison/tests/grammar/bnf_parse.js +65 -0
- data/vendor/coffee-script/vendor/jison/tests/grammar/grammar-tests.js +10 -0
- data/vendor/coffee-script/vendor/jison/tests/grammar/json2jison.js +24 -0
- data/vendor/coffee-script/vendor/jison/tests/grammar/lex/ansic.jisonlex +115 -0
- data/vendor/coffee-script/vendor/jison/tests/grammar/lex/bnf.jisonlex +25 -0
- data/vendor/coffee-script/vendor/jison/tests/grammar/lex/bnf.lex.json +24 -0
- data/vendor/coffee-script/vendor/jison/tests/grammar/lex/lex_grammar.jisonlex +31 -0
- data/vendor/coffee-script/vendor/jison/tests/grammar/lex/lex_grammar.lex.json +30 -0
- data/vendor/coffee-script/vendor/jison/tests/grammar/lex.jison +119 -0
- data/vendor/coffee-script/vendor/jison/tests/grammar/lex.js +58 -0
- data/vendor/coffee-script/vendor/jison/tests/grammar/lex_parse.js +117 -0
- data/vendor/coffee-script/vendor/jison/tests/lexer/lexer-tests.js +6 -0
- data/vendor/coffee-script/vendor/jison/tests/lexer/regexplexer.js +417 -0
- data/vendor/coffee-script/vendor/jison/tests/parser/actions.js +311 -0
- data/vendor/coffee-script/vendor/jison/tests/parser/api.js +236 -0
- data/vendor/coffee-script/vendor/jison/tests/parser/generator.js +196 -0
- data/vendor/coffee-script/vendor/jison/tests/parser/lalr.js +183 -0
- data/vendor/coffee-script/vendor/jison/tests/parser/lr0.js +72 -0
- data/vendor/coffee-script/vendor/jison/tests/parser/lr1.js +119 -0
- data/vendor/coffee-script/vendor/jison/tests/parser/parser-tests.js +14 -0
- data/vendor/coffee-script/vendor/jison/tests/parser/precedence.js +237 -0
- data/vendor/coffee-script/vendor/jison/tests/parser/slr.js +52 -0
- data/vendor/coffee-script/vendor/jison/tests/parser/tables.js +126 -0
- data/vendor/coffee-script/vendor/jison/tests/performance.js +110 -0
- data/vendor/coffee-script/vendor/jison/tests/setup.js +3 -0
- metadata +324 -0
@@ -0,0 +1,415 @@
|
|
1
|
+
%token IDENTIFIER CONSTANT STRING_LITERAL SIZEOF
|
2
|
+
%token PTR_OP INC_OP DEC_OP LEFT_OP RIGHT_OP LE_OP GE_OP EQ_OP NE_OP
|
3
|
+
%token AND_OP OR_OP MUL_ASSIGN DIV_ASSIGN MOD_ASSIGN ADD_ASSIGN
|
4
|
+
%token SUB_ASSIGN LEFT_ASSIGN RIGHT_ASSIGN AND_ASSIGN
|
5
|
+
%token XOR_ASSIGN OR_ASSIGN TYPE_NAME
|
6
|
+
|
7
|
+
%token TYPEDEF EXTERN STATIC AUTO REGISTER
|
8
|
+
%token CHAR SHORT INT LONG SIGNED UNSIGNED FLOAT DOUBLE CONST VOLATILE VOID
|
9
|
+
%token STRUCT UNION ENUM ELLIPSIS
|
10
|
+
|
11
|
+
%token CASE DEFAULT IF ELSE SWITCH WHILE DO FOR GOTO CONTINUE BREAK RETURN
|
12
|
+
|
13
|
+
%start translation_unit
|
14
|
+
%%
|
15
|
+
|
16
|
+
primary_expression
|
17
|
+
: IDENTIFIER
|
18
|
+
| CONSTANT
|
19
|
+
| STRING_LITERAL
|
20
|
+
| '(' expression ')'
|
21
|
+
;
|
22
|
+
|
23
|
+
postfix_expression
|
24
|
+
: primary_expression
|
25
|
+
| postfix_expression '[' expression ']'
|
26
|
+
| postfix_expression '(' ')'
|
27
|
+
| postfix_expression '(' argument_expression_list ')'
|
28
|
+
| postfix_expression '.' IDENTIFIER
|
29
|
+
| postfix_expression PTR_OP IDENTIFIER
|
30
|
+
| postfix_expression INC_OP
|
31
|
+
| postfix_expression DEC_OP
|
32
|
+
;
|
33
|
+
|
34
|
+
argument_expression_list
|
35
|
+
: assignment_expression
|
36
|
+
| argument_expression_list ',' assignment_expression
|
37
|
+
;
|
38
|
+
|
39
|
+
unary_expression
|
40
|
+
: postfix_expression
|
41
|
+
| INC_OP unary_expression
|
42
|
+
| DEC_OP unary_expression
|
43
|
+
| unary_operator cast_expression
|
44
|
+
| SIZEOF unary_expression
|
45
|
+
| SIZEOF '(' type_name ')'
|
46
|
+
;
|
47
|
+
|
48
|
+
unary_operator
|
49
|
+
: '&'
|
50
|
+
| '*'
|
51
|
+
| '+'
|
52
|
+
| '-'
|
53
|
+
| '~'
|
54
|
+
| '!'
|
55
|
+
;
|
56
|
+
|
57
|
+
cast_expression
|
58
|
+
: unary_expression
|
59
|
+
| '(' type_name ')' cast_expression
|
60
|
+
;
|
61
|
+
|
62
|
+
multiplicative_expression
|
63
|
+
: cast_expression
|
64
|
+
| multiplicative_expression '*' cast_expression
|
65
|
+
| multiplicative_expression '/' cast_expression
|
66
|
+
| multiplicative_expression '%' cast_expression
|
67
|
+
;
|
68
|
+
|
69
|
+
additive_expression
|
70
|
+
: multiplicative_expression
|
71
|
+
| additive_expression '+' multiplicative_expression
|
72
|
+
| additive_expression '-' multiplicative_expression
|
73
|
+
;
|
74
|
+
|
75
|
+
shift_expression
|
76
|
+
: additive_expression
|
77
|
+
| shift_expression LEFT_OP additive_expression
|
78
|
+
| shift_expression RIGHT_OP additive_expression
|
79
|
+
;
|
80
|
+
|
81
|
+
relational_expression
|
82
|
+
: shift_expression
|
83
|
+
| relational_expression '<' shift_expression
|
84
|
+
| relational_expression '>' shift_expression
|
85
|
+
| relational_expression LE_OP shift_expression
|
86
|
+
| relational_expression GE_OP shift_expression
|
87
|
+
;
|
88
|
+
|
89
|
+
equality_expression
|
90
|
+
: relational_expression
|
91
|
+
| equality_expression EQ_OP relational_expression
|
92
|
+
| equality_expression NE_OP relational_expression
|
93
|
+
;
|
94
|
+
|
95
|
+
and_expression
|
96
|
+
: equality_expression
|
97
|
+
| and_expression '&' equality_expression
|
98
|
+
;
|
99
|
+
|
100
|
+
exclusive_or_expression
|
101
|
+
: and_expression
|
102
|
+
| exclusive_or_expression '^' and_expression
|
103
|
+
;
|
104
|
+
|
105
|
+
inclusive_or_expression
|
106
|
+
: exclusive_or_expression
|
107
|
+
| inclusive_or_expression '|' exclusive_or_expression
|
108
|
+
;
|
109
|
+
|
110
|
+
logical_and_expression
|
111
|
+
: inclusive_or_expression
|
112
|
+
| logical_and_expression AND_OP inclusive_or_expression
|
113
|
+
;
|
114
|
+
|
115
|
+
logical_or_expression
|
116
|
+
: logical_and_expression
|
117
|
+
| logical_or_expression OR_OP logical_and_expression
|
118
|
+
;
|
119
|
+
|
120
|
+
conditional_expression
|
121
|
+
: logical_or_expression
|
122
|
+
| logical_or_expression '?' expression ':' conditional_expression
|
123
|
+
;
|
124
|
+
|
125
|
+
assignment_expression
|
126
|
+
: conditional_expression
|
127
|
+
| unary_expression assignment_operator assignment_expression
|
128
|
+
;
|
129
|
+
|
130
|
+
assignment_operator
|
131
|
+
: '='
|
132
|
+
| MUL_ASSIGN
|
133
|
+
| DIV_ASSIGN
|
134
|
+
| MOD_ASSIGN
|
135
|
+
| ADD_ASSIGN
|
136
|
+
| SUB_ASSIGN
|
137
|
+
| LEFT_ASSIGN
|
138
|
+
| RIGHT_ASSIGN
|
139
|
+
| AND_ASSIGN
|
140
|
+
| XOR_ASSIGN
|
141
|
+
| OR_ASSIGN
|
142
|
+
;
|
143
|
+
|
144
|
+
expression
|
145
|
+
: assignment_expression
|
146
|
+
| expression ',' assignment_expression
|
147
|
+
;
|
148
|
+
|
149
|
+
constant_expression
|
150
|
+
: conditional_expression
|
151
|
+
;
|
152
|
+
|
153
|
+
declaration
|
154
|
+
: declaration_specifiers ';'
|
155
|
+
| declaration_specifiers init_declarator_list ';'
|
156
|
+
;
|
157
|
+
|
158
|
+
declaration_specifiers
|
159
|
+
: storage_class_specifier
|
160
|
+
| storage_class_specifier declaration_specifiers
|
161
|
+
| type_specifier
|
162
|
+
| type_specifier declaration_specifiers
|
163
|
+
| type_qualifier
|
164
|
+
| type_qualifier declaration_specifiers
|
165
|
+
;
|
166
|
+
|
167
|
+
init_declarator_list
|
168
|
+
: init_declarator
|
169
|
+
| init_declarator_list ',' init_declarator
|
170
|
+
;
|
171
|
+
|
172
|
+
init_declarator
|
173
|
+
: declarator
|
174
|
+
| declarator '=' initializer
|
175
|
+
;
|
176
|
+
|
177
|
+
storage_class_specifier
|
178
|
+
: TYPEDEF
|
179
|
+
| EXTERN
|
180
|
+
| STATIC
|
181
|
+
| AUTO
|
182
|
+
| REGISTER
|
183
|
+
;
|
184
|
+
|
185
|
+
type_specifier
|
186
|
+
: VOID
|
187
|
+
| CHAR
|
188
|
+
| SHORT
|
189
|
+
| INT
|
190
|
+
| LONG
|
191
|
+
| FLOAT
|
192
|
+
| DOUBLE
|
193
|
+
| SIGNED
|
194
|
+
| UNSIGNED
|
195
|
+
| struct_or_union_specifier
|
196
|
+
| enum_specifier
|
197
|
+
| TYPE_NAME
|
198
|
+
;
|
199
|
+
|
200
|
+
struct_or_union_specifier
|
201
|
+
: struct_or_union IDENTIFIER '{' struct_declaration_list '}'
|
202
|
+
| struct_or_union '{' struct_declaration_list '}'
|
203
|
+
| struct_or_union IDENTIFIER
|
204
|
+
;
|
205
|
+
|
206
|
+
struct_or_union
|
207
|
+
: STRUCT
|
208
|
+
| UNION
|
209
|
+
;
|
210
|
+
|
211
|
+
struct_declaration_list
|
212
|
+
: struct_declaration
|
213
|
+
| struct_declaration_list struct_declaration
|
214
|
+
;
|
215
|
+
|
216
|
+
struct_declaration
|
217
|
+
: specifier_qualifier_list struct_declarator_list ';'
|
218
|
+
;
|
219
|
+
|
220
|
+
specifier_qualifier_list
|
221
|
+
: type_specifier specifier_qualifier_list
|
222
|
+
| type_specifier
|
223
|
+
| type_qualifier specifier_qualifier_list
|
224
|
+
| type_qualifier
|
225
|
+
;
|
226
|
+
|
227
|
+
struct_declarator_list
|
228
|
+
: struct_declarator
|
229
|
+
| struct_declarator_list ',' struct_declarator
|
230
|
+
;
|
231
|
+
|
232
|
+
struct_declarator
|
233
|
+
: declarator
|
234
|
+
| ':' constant_expression
|
235
|
+
| declarator ':' constant_expression
|
236
|
+
;
|
237
|
+
|
238
|
+
enum_specifier
|
239
|
+
: ENUM '{' enumerator_list '}'
|
240
|
+
| ENUM IDENTIFIER '{' enumerator_list '}'
|
241
|
+
| ENUM IDENTIFIER
|
242
|
+
;
|
243
|
+
|
244
|
+
enumerator_list
|
245
|
+
: enumerator
|
246
|
+
| enumerator_list ',' enumerator
|
247
|
+
;
|
248
|
+
|
249
|
+
enumerator
|
250
|
+
: IDENTIFIER
|
251
|
+
| IDENTIFIER '=' constant_expression
|
252
|
+
;
|
253
|
+
|
254
|
+
type_qualifier
|
255
|
+
: CONST
|
256
|
+
| VOLATILE
|
257
|
+
;
|
258
|
+
|
259
|
+
declarator
|
260
|
+
: pointer direct_declarator
|
261
|
+
| direct_declarator
|
262
|
+
;
|
263
|
+
|
264
|
+
direct_declarator
|
265
|
+
: IDENTIFIER
|
266
|
+
| '(' declarator ')'
|
267
|
+
| direct_declarator '[' constant_expression ']'
|
268
|
+
| direct_declarator '[' ']'
|
269
|
+
| direct_declarator '(' parameter_type_list ')'
|
270
|
+
| direct_declarator '(' identifier_list ')'
|
271
|
+
| direct_declarator '(' ')'
|
272
|
+
;
|
273
|
+
|
274
|
+
pointer
|
275
|
+
: '*'
|
276
|
+
| '*' type_qualifier_list
|
277
|
+
| '*' pointer
|
278
|
+
| '*' type_qualifier_list pointer
|
279
|
+
;
|
280
|
+
|
281
|
+
type_qualifier_list
|
282
|
+
: type_qualifier
|
283
|
+
| type_qualifier_list type_qualifier
|
284
|
+
;
|
285
|
+
|
286
|
+
|
287
|
+
parameter_type_list
|
288
|
+
: parameter_list
|
289
|
+
| parameter_list ',' ELLIPSIS
|
290
|
+
;
|
291
|
+
|
292
|
+
parameter_list
|
293
|
+
: parameter_declaration
|
294
|
+
| parameter_list ',' parameter_declaration
|
295
|
+
;
|
296
|
+
|
297
|
+
parameter_declaration
|
298
|
+
: declaration_specifiers declarator
|
299
|
+
| declaration_specifiers abstract_declarator
|
300
|
+
| declaration_specifiers
|
301
|
+
;
|
302
|
+
|
303
|
+
identifier_list
|
304
|
+
: IDENTIFIER
|
305
|
+
| identifier_list ',' IDENTIFIER
|
306
|
+
;
|
307
|
+
|
308
|
+
type_name
|
309
|
+
: specifier_qualifier_list
|
310
|
+
| specifier_qualifier_list abstract_declarator
|
311
|
+
;
|
312
|
+
|
313
|
+
abstract_declarator
|
314
|
+
: pointer
|
315
|
+
| direct_abstract_declarator
|
316
|
+
| pointer direct_abstract_declarator
|
317
|
+
;
|
318
|
+
|
319
|
+
direct_abstract_declarator
|
320
|
+
: '(' abstract_declarator ')'
|
321
|
+
| '[' ']'
|
322
|
+
| '[' constant_expression ']'
|
323
|
+
| direct_abstract_declarator '[' ']'
|
324
|
+
| direct_abstract_declarator '[' constant_expression ']'
|
325
|
+
| '(' ')'
|
326
|
+
| '(' parameter_type_list ')'
|
327
|
+
| direct_abstract_declarator '(' ')'
|
328
|
+
| direct_abstract_declarator '(' parameter_type_list ')'
|
329
|
+
;
|
330
|
+
|
331
|
+
initializer
|
332
|
+
: assignment_expression
|
333
|
+
| '{' initializer_list '}'
|
334
|
+
| '{' initializer_list ',' '}'
|
335
|
+
;
|
336
|
+
|
337
|
+
initializer_list
|
338
|
+
: initializer
|
339
|
+
| initializer_list ',' initializer
|
340
|
+
;
|
341
|
+
|
342
|
+
statement
|
343
|
+
: labeled_statement
|
344
|
+
| compound_statement
|
345
|
+
| expression_statement
|
346
|
+
| selection_statement
|
347
|
+
| iteration_statement
|
348
|
+
| jump_statement
|
349
|
+
;
|
350
|
+
|
351
|
+
labeled_statement
|
352
|
+
: IDENTIFIER ':' statement
|
353
|
+
| CASE constant_expression ':' statement
|
354
|
+
| DEFAULT ':' statement
|
355
|
+
;
|
356
|
+
|
357
|
+
compound_statement
|
358
|
+
: '{' '}'
|
359
|
+
| '{' statement_list '}'
|
360
|
+
| '{' declaration_list '}'
|
361
|
+
| '{' declaration_list statement_list '}'
|
362
|
+
;
|
363
|
+
|
364
|
+
declaration_list
|
365
|
+
: declaration
|
366
|
+
| declaration_list declaration
|
367
|
+
;
|
368
|
+
|
369
|
+
statement_list
|
370
|
+
: statement
|
371
|
+
| statement_list statement
|
372
|
+
;
|
373
|
+
|
374
|
+
expression_statement
|
375
|
+
: ';'
|
376
|
+
| expression ';'
|
377
|
+
;
|
378
|
+
|
379
|
+
selection_statement
|
380
|
+
: IF '(' expression ')' statement
|
381
|
+
| IF '(' expression ')' statement ELSE statement
|
382
|
+
| SWITCH '(' expression ')' statement
|
383
|
+
;
|
384
|
+
|
385
|
+
iteration_statement
|
386
|
+
: WHILE '(' expression ')' statement
|
387
|
+
| DO statement WHILE '(' expression ')' ';'
|
388
|
+
| FOR '(' expression_statement expression_statement ')' statement
|
389
|
+
| FOR '(' expression_statement expression_statement expression ')' statement
|
390
|
+
;
|
391
|
+
|
392
|
+
jump_statement
|
393
|
+
: GOTO IDENTIFIER ';'
|
394
|
+
| CONTINUE ';'
|
395
|
+
| BREAK ';'
|
396
|
+
| RETURN ';'
|
397
|
+
| RETURN expression ';'
|
398
|
+
;
|
399
|
+
|
400
|
+
translation_unit
|
401
|
+
: external_declaration
|
402
|
+
| translation_unit external_declaration
|
403
|
+
;
|
404
|
+
|
405
|
+
external_declaration
|
406
|
+
: function_definition
|
407
|
+
| declaration
|
408
|
+
;
|
409
|
+
|
410
|
+
function_definition
|
411
|
+
: declaration_specifiers declarator declaration_list compound_statement
|
412
|
+
| declaration_specifiers declarator compound_statement
|
413
|
+
| declarator declaration_list compound_statement
|
414
|
+
| declarator compound_statement
|
415
|
+
;
|
@@ -0,0 +1,38 @@
|
|
1
|
+
|
2
|
+
/* description: Parses end executes mathematical expressions. */
|
3
|
+
|
4
|
+
%left '+' '-'
|
5
|
+
%left '*' '/'
|
6
|
+
%left '^'
|
7
|
+
%left UMINUS
|
8
|
+
|
9
|
+
%%
|
10
|
+
|
11
|
+
S
|
12
|
+
: e EOF
|
13
|
+
{print($1); return $1;}
|
14
|
+
;
|
15
|
+
|
16
|
+
e
|
17
|
+
: e '+' e
|
18
|
+
{$$ = $1+$3;}
|
19
|
+
| e '-' e
|
20
|
+
{$$ = $1-$3;}
|
21
|
+
| e '*' e
|
22
|
+
{$$ = $1*$3;}
|
23
|
+
| e '/' e
|
24
|
+
{$$ = $1/$3;}
|
25
|
+
| e '^' e
|
26
|
+
{$$ = Math.pow($1, $3);}
|
27
|
+
| '-' e
|
28
|
+
{$$ = -$2;} %prec UMINUS
|
29
|
+
| '(' e ')'
|
30
|
+
{$$ = $2;}
|
31
|
+
| NUMBER
|
32
|
+
{$$ = Number(yytext);}
|
33
|
+
| E
|
34
|
+
{$$ = Math.E;}
|
35
|
+
| PI
|
36
|
+
{$$ = Math.PI;}
|
37
|
+
;
|
38
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
%%
|
2
|
+
\s+ {/* skip whitespace */}
|
3
|
+
[0-9]+("."[0-9]+)?\b {return 'NUMBER';}
|
4
|
+
"*" {return '*';}
|
5
|
+
"/" {return '/';}
|
6
|
+
"-" {return '-';}
|
7
|
+
"+" {return '+';}
|
8
|
+
"^" {return '^';}
|
9
|
+
"(" {return '(';}
|
10
|
+
")" {return ')';}
|
11
|
+
"PI" {return 'PI';}
|
12
|
+
"E" {return 'E';}
|
13
|
+
<<EOF>> {return 'EOF';}
|
14
|
+
|
@@ -0,0 +1,42 @@
|
|
1
|
+
{
|
2
|
+
"comment": "Parses end executes mathematical expressions.",
|
3
|
+
|
4
|
+
"lex": {
|
5
|
+
"rules": [
|
6
|
+
["\\s+", "/* skip whitespace */"],
|
7
|
+
["[0-9]+(?:\\.[0-9]+)?\\b", "return 'NUMBER';"],
|
8
|
+
["\\*", "return '*';"],
|
9
|
+
["\\/", "return '/';"],
|
10
|
+
["-", "return '-';"],
|
11
|
+
["\\+", "return '+';"],
|
12
|
+
["\\^", "return '^';"],
|
13
|
+
["\\(", "return '(';"],
|
14
|
+
["\\)", "return ')';"],
|
15
|
+
["PI\\b", "return 'PI';"],
|
16
|
+
["E\\b", "return 'E';"],
|
17
|
+
["$", "return 'EOF';"]
|
18
|
+
]
|
19
|
+
},
|
20
|
+
|
21
|
+
"operators": [
|
22
|
+
["left", "+", "-"],
|
23
|
+
["left", "*", "/"],
|
24
|
+
["left", "^"],
|
25
|
+
["left", "UMINUS"]
|
26
|
+
],
|
27
|
+
|
28
|
+
"bnf": {
|
29
|
+
"S" :[[ "e EOF", "print($1); return $1;" ]],
|
30
|
+
|
31
|
+
"e" :[[ "e + e", "$$ = $1+$3;" ],
|
32
|
+
[ "e - e", "$$ = $1-$3;" ],
|
33
|
+
[ "e * e", "$$ = $1*$3;" ],
|
34
|
+
[ "e / e", "$$ = $1/$3;" ],
|
35
|
+
[ "e ^ e", "$$ = Math.pow($1, $3);" ],
|
36
|
+
[ "- e", "$$ = -$2;", {"prec": "UMINUS"} ],
|
37
|
+
[ "( e )", "$$ = $2;" ],
|
38
|
+
[ "NUMBER", "$$ = Number(yytext);" ],
|
39
|
+
[ "E", "$$ = Math.E;" ],
|
40
|
+
[ "PI", "$$ = Math.PI;" ]]
|
41
|
+
}
|
42
|
+
}
|
@@ -0,0 +1,105 @@
|
|
1
|
+
{
|
2
|
+
"comment": "ClassyLang grammar. Very classy.",
|
3
|
+
"author": "Zach Carter",
|
4
|
+
|
5
|
+
"lex": {
|
6
|
+
"macros": {
|
7
|
+
"digit": "[0-9]",
|
8
|
+
"id": "[a-zA-Z][a-zA-Z0-9]*"
|
9
|
+
},
|
10
|
+
|
11
|
+
"rules": [
|
12
|
+
["//.*", "/* ignore comment */"],
|
13
|
+
["main\\b", "return 'MAIN';"],
|
14
|
+
["class\\b", "return 'CLASS';"],
|
15
|
+
["extends\\b", "return 'EXTENDS';"],
|
16
|
+
["nat\\b", "return 'NATTYPE';"],
|
17
|
+
["if\\b", "return 'IF';"],
|
18
|
+
["else\\b", "return 'ELSE';"],
|
19
|
+
["for\\b", "return 'FOR';"],
|
20
|
+
["printNat\\b", "return 'PRINTNAT';"],
|
21
|
+
["readNat\\b", "return 'READNAT';"],
|
22
|
+
["this\\b", "return 'THIS';"],
|
23
|
+
["new\\b", "return 'NEW';"],
|
24
|
+
["var\\b", "return 'VAR';"],
|
25
|
+
["null\\b", "return 'NUL';"],
|
26
|
+
["{digit}+", "return 'NATLITERAL';"],
|
27
|
+
["{id}", "return 'ID';"],
|
28
|
+
["==", "return 'EQUALITY';"],
|
29
|
+
["=", "return 'ASSIGN';"],
|
30
|
+
["\\+", "return 'PLUS';"],
|
31
|
+
["-", "return 'MINUS';"],
|
32
|
+
["\\*", "return 'TIMES';"],
|
33
|
+
[">", "return 'GREATER';"],
|
34
|
+
["\\|\\|", "return 'OR';"],
|
35
|
+
["!", "return 'NOT';"],
|
36
|
+
["\\.", "return 'DOT';"],
|
37
|
+
["\\{", "return 'LBRACE';"],
|
38
|
+
["\\}", "return 'RBRACE';"],
|
39
|
+
["\\(", "return 'LPAREN';"],
|
40
|
+
["\\)", "return 'RPAREN';"],
|
41
|
+
[";", "return 'SEMICOLON';"],
|
42
|
+
["\\s+", "/* skip whitespace */"],
|
43
|
+
[".", "throw 'Illegal character: '+yytext;"],
|
44
|
+
["$", "return 'ENDOFFILE';"]
|
45
|
+
]
|
46
|
+
},
|
47
|
+
|
48
|
+
"tokens": "MAIN CLASS EXTENDS NATTYPE IF ELSE FOR PRINTNAT READNAT THIS NEW VAR NUL NATLITERAL ID ASSIGN PLUS MINUS TIMES EQUALITY GREATER OR NOT DOT SEMICOLON LBRACE RBRACE LPAREN RPAREN ENDOFFILE",
|
49
|
+
"operators": [
|
50
|
+
["right", "ASSIGN"],
|
51
|
+
["left", "OR"],
|
52
|
+
["nonassoc", "EQUALITY", "GREATER"],
|
53
|
+
["left", "PLUS", "MINUS"],
|
54
|
+
["left", "TIMES"],
|
55
|
+
["right", "NOT"],
|
56
|
+
["left", "DOT"]
|
57
|
+
],
|
58
|
+
|
59
|
+
"bnf": {
|
60
|
+
"pgm": ["cdl MAIN LBRACE vdl el RBRACE ENDOFFILE"],
|
61
|
+
|
62
|
+
"cdl": ["c cdl",
|
63
|
+
""],
|
64
|
+
|
65
|
+
"c": ["CLASS id EXTENDS id LBRACE vdl mdl RBRACE"],
|
66
|
+
|
67
|
+
"vdl": ["VAR t id SEMICOLON vdl",
|
68
|
+
""],
|
69
|
+
|
70
|
+
"mdl": ["t id LPAREN t id RPAREN LBRACE vdl el RBRACE mdl",
|
71
|
+
""],
|
72
|
+
|
73
|
+
"t": ["NATTYPE",
|
74
|
+
"id"],
|
75
|
+
|
76
|
+
"id": ["ID"],
|
77
|
+
|
78
|
+
"el": ["e SEMICOLON el",
|
79
|
+
"e SEMICOLON"],
|
80
|
+
|
81
|
+
"e": ["NATLITERAL",
|
82
|
+
"NUL",
|
83
|
+
"id",
|
84
|
+
"NEW id",
|
85
|
+
"THIS",
|
86
|
+
"IF LPAREN e RPAREN LBRACE el RBRACE ELSE LBRACE el RBRACE",
|
87
|
+
"FOR LPAREN e SEMICOLON e SEMICOLON e RPAREN LBRACE el RBRACE",
|
88
|
+
"READNAT LPAREN RPAREN",
|
89
|
+
"PRINTNAT LPAREN e RPAREN",
|
90
|
+
"e PLUS e",
|
91
|
+
"e MINUS e",
|
92
|
+
"e TIMES e",
|
93
|
+
"e EQUALITY e",
|
94
|
+
"e GREATER e",
|
95
|
+
"NOT e",
|
96
|
+
"e OR e",
|
97
|
+
"e DOT id",
|
98
|
+
"id ASSIGN e",
|
99
|
+
"e DOT id ASSIGN e",
|
100
|
+
"id LPAREN e RPAREN",
|
101
|
+
"e DOT id LPAREN e RPAREN",
|
102
|
+
"LPAREN e RPAREN"]
|
103
|
+
}
|
104
|
+
}
|
105
|
+
|