haml-more 0.4.0.a

Sign up to get free protection for your applications and to get access to all the features.
Files changed (225) hide show
  1. data/README.md +79 -0
  2. data/lib/haml/more/coffee_script.rb +137 -0
  3. data/lib/haml/more/content_for.rb +25 -0
  4. data/lib/haml/more.rb +45 -0
  5. data/lib/haml-more.rb +1 -0
  6. data/lib/sass/more.rb +16 -0
  7. data/lib/sass-more.rb +1 -0
  8. data/spec/sass/more_spec.rb +21 -0
  9. data/vendor/coffee-script/Cakefile +57 -0
  10. data/vendor/coffee-script/LICENSE +22 -0
  11. data/vendor/coffee-script/README +41 -0
  12. data/vendor/coffee-script/Rakefile +20 -0
  13. data/vendor/coffee-script/bin/cake +7 -0
  14. data/vendor/coffee-script/bin/coffee +7 -0
  15. data/vendor/coffee-script/documentation/coffee/aliases.coffee +9 -0
  16. data/vendor/coffee-script/documentation/coffee/arguments.coffee +4 -0
  17. data/vendor/coffee-script/documentation/coffee/array_comprehensions.coffee +7 -0
  18. data/vendor/coffee-script/documentation/coffee/assignment.coffee +2 -0
  19. data/vendor/coffee-script/documentation/coffee/cake_tasks.coffee +5 -0
  20. data/vendor/coffee-script/documentation/coffee/comparisons.coffee +5 -0
  21. data/vendor/coffee-script/documentation/coffee/conditionals.coffee +9 -0
  22. data/vendor/coffee-script/documentation/coffee/embedded.coffee +5 -0
  23. data/vendor/coffee-script/documentation/coffee/existence.coffee +8 -0
  24. data/vendor/coffee-script/documentation/coffee/expressions.coffee +9 -0
  25. data/vendor/coffee-script/documentation/coffee/expressions_assignment.coffee +1 -0
  26. data/vendor/coffee-script/documentation/coffee/expressions_comprehension.coffee +3 -0
  27. data/vendor/coffee-script/documentation/coffee/expressions_try.coffee +6 -0
  28. data/vendor/coffee-script/documentation/coffee/fat_arrow.coffee +6 -0
  29. data/vendor/coffee-script/documentation/coffee/functions.coffee +2 -0
  30. data/vendor/coffee-script/documentation/coffee/heredocs.coffee +5 -0
  31. data/vendor/coffee-script/documentation/coffee/multiple_return_values.coffee +5 -0
  32. data/vendor/coffee-script/documentation/coffee/object_comprehensions.coffee +4 -0
  33. data/vendor/coffee-script/documentation/coffee/object_extraction.coffee +13 -0
  34. data/vendor/coffee-script/documentation/coffee/objects_and_arrays.coffee +13 -0
  35. data/vendor/coffee-script/documentation/coffee/overview.coffee +29 -0
  36. data/vendor/coffee-script/documentation/coffee/parallel_assignment.coffee +4 -0
  37. data/vendor/coffee-script/documentation/coffee/range_comprehensions.coffee +6 -0
  38. data/vendor/coffee-script/documentation/coffee/scope.coffee +5 -0
  39. data/vendor/coffee-script/documentation/coffee/slices.coffee +6 -0
  40. data/vendor/coffee-script/documentation/coffee/soaks.coffee +1 -0
  41. data/vendor/coffee-script/documentation/coffee/splats.coffee +25 -0
  42. data/vendor/coffee-script/documentation/coffee/splices.coffee +5 -0
  43. data/vendor/coffee-script/documentation/coffee/strings.coffee +8 -0
  44. data/vendor/coffee-script/documentation/coffee/super.coffee +34 -0
  45. data/vendor/coffee-script/documentation/coffee/switch.coffee +10 -0
  46. data/vendor/coffee-script/documentation/coffee/try.coffee +7 -0
  47. data/vendor/coffee-script/documentation/coffee/while.coffee +10 -0
  48. data/vendor/coffee-script/documentation/css/docs.css +213 -0
  49. data/vendor/coffee-script/documentation/css/idle.css +63 -0
  50. data/vendor/coffee-script/documentation/css/logo.png +0 -0
  51. data/vendor/coffee-script/documentation/index.html.erb +967 -0
  52. data/vendor/coffee-script/documentation/js/aliases.js +14 -0
  53. data/vendor/coffee-script/documentation/js/arguments.js +8 -0
  54. data/vendor/coffee-script/documentation/js/array_comprehensions.js +26 -0
  55. data/vendor/coffee-script/documentation/js/assignment.js +5 -0
  56. data/vendor/coffee-script/documentation/js/cake_tasks.js +14 -0
  57. data/vendor/coffee-script/documentation/js/comparisons.js +5 -0
  58. data/vendor/coffee-script/documentation/js/conditionals.js +12 -0
  59. data/vendor/coffee-script/documentation/js/embedded.js +6 -0
  60. data/vendor/coffee-script/documentation/js/existence.js +7 -0
  61. data/vendor/coffee-script/documentation/js/expressions.js +13 -0
  62. data/vendor/coffee-script/documentation/js/expressions_assignment.js +4 -0
  63. data/vendor/coffee-script/documentation/js/expressions_comprehension.js +12 -0
  64. data/vendor/coffee-script/documentation/js/expressions_try.js +9 -0
  65. data/vendor/coffee-script/documentation/js/fat_arrow.js +15 -0
  66. data/vendor/coffee-script/documentation/js/functions.js +9 -0
  67. data/vendor/coffee-script/documentation/js/heredocs.js +4 -0
  68. data/vendor/coffee-script/documentation/js/intro.js +7 -0
  69. data/vendor/coffee-script/documentation/js/multiple_return_values.js +11 -0
  70. data/vendor/coffee-script/documentation/js/object_comprehensions.js +17 -0
  71. data/vendor/coffee-script/documentation/js/object_extraction.js +17 -0
  72. data/vendor/coffee-script/documentation/js/objects_and_arrays.js +10 -0
  73. data/vendor/coffee-script/documentation/js/overview.js +43 -0
  74. data/vendor/coffee-script/documentation/js/parallel_assignment.js +8 -0
  75. data/vendor/coffee-script/documentation/js/punctuation.js +8 -0
  76. data/vendor/coffee-script/documentation/js/range_comprehensions.js +21 -0
  77. data/vendor/coffee-script/documentation/js/scope.js +10 -0
  78. data/vendor/coffee-script/documentation/js/slices.js +6 -0
  79. data/vendor/coffee-script/documentation/js/soaks.js +4 -0
  80. data/vendor/coffee-script/documentation/js/splats.js +16 -0
  81. data/vendor/coffee-script/documentation/js/splices.js +5 -0
  82. data/vendor/coffee-script/documentation/js/strings.js +9 -0
  83. data/vendor/coffee-script/documentation/js/super.js +37 -0
  84. data/vendor/coffee-script/documentation/js/switch.js +18 -0
  85. data/vendor/coffee-script/documentation/js/try.js +10 -0
  86. data/vendor/coffee-script/documentation/js/while.js +22 -0
  87. data/vendor/coffee-script/documentation/underscore.html +627 -0
  88. data/vendor/coffee-script/examples/beautiful_code/binary_search.coffee +16 -0
  89. data/vendor/coffee-script/examples/beautiful_code/quicksort_runtime.coffee +13 -0
  90. data/vendor/coffee-script/examples/beautiful_code/regular_expression_matcher.coffee +34 -0
  91. data/vendor/coffee-script/examples/blocks.coffee +57 -0
  92. data/vendor/coffee-script/examples/code.coffee +173 -0
  93. data/vendor/coffee-script/examples/computer_science/README +4 -0
  94. data/vendor/coffee-script/examples/computer_science/binary_search.coffee +25 -0
  95. data/vendor/coffee-script/examples/computer_science/bubble_sort.coffee +11 -0
  96. data/vendor/coffee-script/examples/computer_science/linked_list.coffee +106 -0
  97. data/vendor/coffee-script/examples/computer_science/luhn_algorithm.coffee +36 -0
  98. data/vendor/coffee-script/examples/computer_science/merge_sort.coffee +19 -0
  99. data/vendor/coffee-script/examples/computer_science/selection_sort.coffee +23 -0
  100. data/vendor/coffee-script/examples/poignant.coffee +186 -0
  101. data/vendor/coffee-script/examples/potion.coffee +205 -0
  102. data/vendor/coffee-script/examples/underscore.coffee +603 -0
  103. data/vendor/coffee-script/examples/web_server.coffee +12 -0
  104. data/vendor/coffee-script/extras/CoffeeScript.tmbundle/Preferences/CoffeeScript.tmPreferences +24 -0
  105. data/vendor/coffee-script/extras/CoffeeScript.tmbundle/Syntaxes/CoffeeScript.tmLanguage +361 -0
  106. data/vendor/coffee-script/extras/CoffeeScript.tmbundle/info.plist +10 -0
  107. data/vendor/coffee-script/extras/EXTRAS +20 -0
  108. data/vendor/coffee-script/extras/coffee.vim +117 -0
  109. data/vendor/coffee-script/index.html +1847 -0
  110. data/vendor/coffee-script/lib/bin/cake +7 -0
  111. data/vendor/coffee-script/lib/bin/coffee +7 -0
  112. data/vendor/coffee-script/lib/cake.js +80 -0
  113. data/vendor/coffee-script/lib/coffee-script.js +61 -0
  114. data/vendor/coffee-script/lib/command_line.js +201 -0
  115. data/vendor/coffee-script/lib/grammar.js +564 -0
  116. data/vendor/coffee-script/lib/lexer.js +405 -0
  117. data/vendor/coffee-script/lib/narwhal.js +44 -0
  118. data/vendor/coffee-script/lib/nodes.js +1328 -0
  119. data/vendor/coffee-script/lib/optparse.js +117 -0
  120. data/vendor/coffee-script/lib/parser.js +536 -0
  121. data/vendor/coffee-script/lib/repl.js +32 -0
  122. data/vendor/coffee-script/lib/rewriter.js +383 -0
  123. data/vendor/coffee-script/lib/scope.js +114 -0
  124. data/vendor/coffee-script/package.json +7 -0
  125. data/vendor/coffee-script/src/cake.coffee +45 -0
  126. data/vendor/coffee-script/src/coffee-script.coffee +45 -0
  127. data/vendor/coffee-script/src/command_line.coffee +130 -0
  128. data/vendor/coffee-script/src/grammar.coffee +456 -0
  129. data/vendor/coffee-script/src/lexer.coffee +327 -0
  130. data/vendor/coffee-script/src/narwhal.coffee +42 -0
  131. data/vendor/coffee-script/src/nodes.coffee +1045 -0
  132. data/vendor/coffee-script/src/optparse.coffee +79 -0
  133. data/vendor/coffee-script/src/repl.coffee +23 -0
  134. data/vendor/coffee-script/src/rewriter.coffee +253 -0
  135. data/vendor/coffee-script/src/scope.coffee +75 -0
  136. data/vendor/coffee-script/test/test_arguments.coffee +34 -0
  137. data/vendor/coffee-script/test/test_array_comprehension.coffee +42 -0
  138. data/vendor/coffee-script/test/test_assignment.coffee +26 -0
  139. data/vendor/coffee-script/test/test_blocks.coffee +4 -0
  140. data/vendor/coffee-script/test/test_calling_super.coffee +42 -0
  141. data/vendor/coffee-script/test/test_chained_calls.coffee +25 -0
  142. data/vendor/coffee-script/test/test_destructuring_assignment.coffee +62 -0
  143. data/vendor/coffee-script/test/test_everything.coffee +29 -0
  144. data/vendor/coffee-script/test/test_exceptions.coffee +2 -0
  145. data/vendor/coffee-script/test/test_existence.coffee +81 -0
  146. data/vendor/coffee-script/test/test_expressions.coffee +30 -0
  147. data/vendor/coffee-script/test/test_fancy_if_statement.coffee +26 -0
  148. data/vendor/coffee-script/test/test_functions.coffee +80 -0
  149. data/vendor/coffee-script/test/test_funky_comments.coffee +25 -0
  150. data/vendor/coffee-script/test/test_heredocs.coffee +46 -0
  151. data/vendor/coffee-script/test/test_lexical_scope.coffee +10 -0
  152. data/vendor/coffee-script/test/test_literals.coffee +56 -0
  153. data/vendor/coffee-script/test/test_nested_comprehensions.coffee +11 -0
  154. data/vendor/coffee-script/test/test_newline_escaping.coffee +6 -0
  155. data/vendor/coffee-script/test/test_operations.coffee +18 -0
  156. data/vendor/coffee-script/test/test_range_comprehension.coffee +20 -0
  157. data/vendor/coffee-script/test/test_ranges_and_slices.coffee +16 -0
  158. data/vendor/coffee-script/test/test_splats.coffee +47 -0
  159. data/vendor/coffee-script/test/test_splices.coffee +5 -0
  160. data/vendor/coffee-script/test/test_switch.coffee +64 -0
  161. data/vendor/coffee-script/test/test_while.coffee +30 -0
  162. data/vendor/coffee-script/vendor/jison/Jakefile +31 -0
  163. data/vendor/coffee-script/vendor/jison/README.md +347 -0
  164. data/vendor/coffee-script/vendor/jison/bin/jison +3 -0
  165. data/vendor/coffee-script/vendor/jison/bin/json2jison +3 -0
  166. data/vendor/coffee-script/vendor/jison/examples/ansic.jison +415 -0
  167. data/vendor/coffee-script/vendor/jison/examples/basic.json +8 -0
  168. data/vendor/coffee-script/vendor/jison/examples/basic2.json +9 -0
  169. data/vendor/coffee-script/vendor/jison/examples/basic2_lex.json +16 -0
  170. data/vendor/coffee-script/vendor/jison/examples/basic_lex.json +15 -0
  171. data/vendor/coffee-script/vendor/jison/examples/calculator.jison +38 -0
  172. data/vendor/coffee-script/vendor/jison/examples/calculator.jisonlex +14 -0
  173. data/vendor/coffee-script/vendor/jison/examples/calculator.json +42 -0
  174. data/vendor/coffee-script/vendor/jison/examples/classy.json +105 -0
  175. data/vendor/coffee-script/vendor/jison/examples/classy_ast.json +126 -0
  176. data/vendor/coffee-script/vendor/jison/examples/dism.json +25 -0
  177. data/vendor/coffee-script/vendor/jison/examples/dism_lr0.json +26 -0
  178. data/vendor/coffee-script/vendor/jison/examples/json.js +80 -0
  179. data/vendor/coffee-script/vendor/jison/examples/json_ast.js +83 -0
  180. data/vendor/coffee-script/vendor/jison/examples/precedence.json +26 -0
  181. data/vendor/coffee-script/vendor/jison/examples/reduce_conflict.json +13 -0
  182. data/vendor/coffee-script/vendor/jison/lib/jison/bnf.js +43 -0
  183. data/vendor/coffee-script/vendor/jison/lib/jison/jisonlex.js +18 -0
  184. data/vendor/coffee-script/vendor/jison/lib/jison/json2jison.js +146 -0
  185. data/vendor/coffee-script/vendor/jison/lib/jison/lexer.js +224 -0
  186. data/vendor/coffee-script/vendor/jison/lib/jison/util/bnf-parser.js +383 -0
  187. data/vendor/coffee-script/vendor/jison/lib/jison/util/lex-parser.js +407 -0
  188. data/vendor/coffee-script/vendor/jison/lib/jison/util/set.js +94 -0
  189. data/vendor/coffee-script/vendor/jison/lib/jison/util/typal.js +90 -0
  190. data/vendor/coffee-script/vendor/jison/lib/jison.js +1414 -0
  191. data/vendor/coffee-script/vendor/jison/package.json +14 -0
  192. data/vendor/coffee-script/vendor/jison/src/bnf.jison +110 -0
  193. data/vendor/coffee-script/vendor/jison/src/bnf.jisonlex +25 -0
  194. data/vendor/coffee-script/vendor/jison/src/bnf.lex.json +24 -0
  195. data/vendor/coffee-script/vendor/jison/src/jisonlex.jison +129 -0
  196. data/vendor/coffee-script/vendor/jison/src/jisonlex.jisonlex +31 -0
  197. data/vendor/coffee-script/vendor/jison/src/jisonlex.lex.json +30 -0
  198. data/vendor/coffee-script/vendor/jison/tests/all-tests.js +8 -0
  199. data/vendor/coffee-script/vendor/jison/tests/grammar/bnf.js +91 -0
  200. data/vendor/coffee-script/vendor/jison/tests/grammar/bnf_parse.js +65 -0
  201. data/vendor/coffee-script/vendor/jison/tests/grammar/grammar-tests.js +10 -0
  202. data/vendor/coffee-script/vendor/jison/tests/grammar/json2jison.js +24 -0
  203. data/vendor/coffee-script/vendor/jison/tests/grammar/lex/ansic.jisonlex +115 -0
  204. data/vendor/coffee-script/vendor/jison/tests/grammar/lex/bnf.jisonlex +25 -0
  205. data/vendor/coffee-script/vendor/jison/tests/grammar/lex/bnf.lex.json +24 -0
  206. data/vendor/coffee-script/vendor/jison/tests/grammar/lex/lex_grammar.jisonlex +31 -0
  207. data/vendor/coffee-script/vendor/jison/tests/grammar/lex/lex_grammar.lex.json +30 -0
  208. data/vendor/coffee-script/vendor/jison/tests/grammar/lex.jison +119 -0
  209. data/vendor/coffee-script/vendor/jison/tests/grammar/lex.js +58 -0
  210. data/vendor/coffee-script/vendor/jison/tests/grammar/lex_parse.js +117 -0
  211. data/vendor/coffee-script/vendor/jison/tests/lexer/lexer-tests.js +6 -0
  212. data/vendor/coffee-script/vendor/jison/tests/lexer/regexplexer.js +417 -0
  213. data/vendor/coffee-script/vendor/jison/tests/parser/actions.js +311 -0
  214. data/vendor/coffee-script/vendor/jison/tests/parser/api.js +236 -0
  215. data/vendor/coffee-script/vendor/jison/tests/parser/generator.js +196 -0
  216. data/vendor/coffee-script/vendor/jison/tests/parser/lalr.js +183 -0
  217. data/vendor/coffee-script/vendor/jison/tests/parser/lr0.js +72 -0
  218. data/vendor/coffee-script/vendor/jison/tests/parser/lr1.js +119 -0
  219. data/vendor/coffee-script/vendor/jison/tests/parser/parser-tests.js +14 -0
  220. data/vendor/coffee-script/vendor/jison/tests/parser/precedence.js +237 -0
  221. data/vendor/coffee-script/vendor/jison/tests/parser/slr.js +52 -0
  222. data/vendor/coffee-script/vendor/jison/tests/parser/tables.js +126 -0
  223. data/vendor/coffee-script/vendor/jison/tests/performance.js +110 -0
  224. data/vendor/coffee-script/vendor/jison/tests/setup.js +3 -0
  225. metadata +324 -0
@@ -0,0 +1,564 @@
1
+ (function(){
2
+ var Parser, _a, _b, _c, _d, _e, _f, bnf, grammar, name, non_terminal, o, operators, option, part, tokens, unwrap;
3
+ var __hasProp = Object.prototype.hasOwnProperty;
4
+ Parser = require('jison').Parser;
5
+ // DSL ===================================================================
6
+ // Detect functions: [
7
+ unwrap = /function\s*\(\)\s*\{\s*return\s*([\s\S]*);\s*\}/;
8
+ // Quickie DSL for Jison access.
9
+ o = function o(pattern_string, func, options) {
10
+ var match;
11
+ if (func) {
12
+ func = (match = (func + "").match(unwrap)) ? match[1] : '(' + func + '())';
13
+ return [pattern_string, '$$ = ' + func + ';', options];
14
+ } else {
15
+ return [pattern_string, '$$ = $1;', options];
16
+ }
17
+ };
18
+ // Precedence ===========================================================
19
+ operators = [["left", '?'], ["nonassoc", 'UMINUS', 'UPLUS', 'NOT', '!', '!!', '~', '++', '--'], ["left", '*', '/', '%'], ["left", '+', '-'], ["left", '<<', '>>', '>>>'], ["left", '&', '|', '^'], ["left", '<=', '<', '>', '>='], ["right", 'DELETE', 'INSTANCEOF', 'TYPEOF'], ["right", '==', '!=', 'IS', 'ISNT'], ["left", '&&', '||', 'AND', 'OR'], ["right", '-=', '+=', '/=', '*=', '%=', '||=', '&&=', '?='], ["left", '.'], ["right", 'INDENT'], ["left", 'OUTDENT'], ["right", 'WHEN', 'LEADING_WHEN', 'IN', 'OF', 'BY', 'THROW'], ["right", 'FOR', 'NEW', 'SUPER'], ["left", 'EXTENDS'], ["right", 'ASSIGN', 'RETURN'], ["right", '->', '=>', 'UNLESS', 'IF', 'ELSE', 'WHILE']];
20
+ // Grammar ==============================================================
21
+ grammar = {
22
+ // All parsing will end in this rule, being the trunk of the AST.
23
+ Root: [o("", function() {
24
+ return new Expressions();
25
+ }), o("TERMINATOR", function() {
26
+ return new Expressions();
27
+ }), o("Expressions", function() {
28
+ return $1;
29
+ }), o("Block TERMINATOR", function() {
30
+ return $1;
31
+ })
32
+ ],
33
+ // Any list of expressions or method body, seperated by line breaks or semis.
34
+ Expressions: [o("Expression", function() {
35
+ return Expressions.wrap([$1]);
36
+ }), o("Expressions TERMINATOR Expression", function() {
37
+ return $1.push($3);
38
+ }), o("Expressions TERMINATOR", function() {
39
+ return $1;
40
+ })
41
+ ],
42
+ // All types of expressions in our language. The basic unit of CoffeeScript
43
+ // is the expression.
44
+ Expression: [o("Value"), o("Call"), o("Code"), o("Operation"), o("Assign"), o("If"), o("Try"), o("Throw"), o("Return"), o("While"), o("For"), o("Switch"), o("Extends"), o("Splat"), o("Existence"), o("Comment")],
45
+ // A block of expressions. Note that the Rewriter will convert some postfix
46
+ // forms into blocks for us, by altering the token stream.
47
+ Block: [o("INDENT Expressions OUTDENT", function() {
48
+ return $2;
49
+ }), o("INDENT OUTDENT", function() {
50
+ return new Expressions();
51
+ })
52
+ ],
53
+ Identifier: [o("IDENTIFIER", function() {
54
+ return new LiteralNode(yytext);
55
+ })
56
+ ],
57
+ AlphaNumeric: [o("NUMBER", function() {
58
+ return new LiteralNode(yytext);
59
+ }), o("STRING", function() {
60
+ return new LiteralNode(yytext);
61
+ })
62
+ ],
63
+ // All hard-coded values. These can be printed straight to JavaScript.
64
+ Literal: [o("AlphaNumeric", function() {
65
+ return $1;
66
+ }), o("JS", function() {
67
+ return new LiteralNode(yytext);
68
+ }), o("REGEX", function() {
69
+ return new LiteralNode(yytext);
70
+ }), o("BREAK", function() {
71
+ return new LiteralNode(yytext);
72
+ }), o("CONTINUE", function() {
73
+ return new LiteralNode(yytext);
74
+ }), o("TRUE", function() {
75
+ return new LiteralNode(true);
76
+ }), o("FALSE", function() {
77
+ return new LiteralNode(false);
78
+ }), o("YES", function() {
79
+ return new LiteralNode(true);
80
+ }), o("NO", function() {
81
+ return new LiteralNode(false);
82
+ }), o("ON", function() {
83
+ return new LiteralNode(true);
84
+ }), o("OFF", function() {
85
+ return new LiteralNode(false);
86
+ })
87
+ ],
88
+ // Assignment to a variable (or index).
89
+ Assign: [o("Value ASSIGN Expression", function() {
90
+ return new AssignNode($1, $3);
91
+ })
92
+ ],
93
+ // Assignment within an object literal (can be quoted).
94
+ AssignObj: [o("Identifier ASSIGN Expression", function() {
95
+ return new AssignNode(new ValueNode($1), $3, 'object');
96
+ }), o("AlphaNumeric ASSIGN Expression", function() {
97
+ return new AssignNode(new ValueNode($1), $3, 'object');
98
+ }), o("Comment")
99
+ ],
100
+ // A return statement.
101
+ Return: [o("RETURN Expression", function() {
102
+ return new ReturnNode($2);
103
+ }), o("RETURN", function() {
104
+ return new ReturnNode(new ValueNode(new LiteralNode('null')));
105
+ })
106
+ ],
107
+ // A comment.
108
+ Comment: [o("COMMENT", function() {
109
+ return new CommentNode(yytext);
110
+ })
111
+ ],
112
+ // Arithmetic and logical operators
113
+ // For Ruby's Operator precedence, see: [
114
+ // https://www.cs.auckland.ac.nz/references/ruby/ProgrammingRuby/language.html
115
+ Operation: [o("! Expression", function() {
116
+ return new OpNode('!', $2);
117
+ }), o("!! Expression", function() {
118
+ return new OpNode('!!', $2);
119
+ }), o("- Expression", (function() {
120
+ return new OpNode('-', $2);
121
+ }), {
122
+ prec: 'UMINUS'
123
+ }), o("+ Expression", (function() {
124
+ return new OpNode('+', $2);
125
+ }), {
126
+ prec: 'UPLUS'
127
+ }), o("NOT Expression", function() {
128
+ return new OpNode('not', $2);
129
+ }), o("~ Expression", function() {
130
+ return new OpNode('~', $2);
131
+ }), o("-- Expression", function() {
132
+ return new OpNode('--', $2);
133
+ }), o("++ Expression", function() {
134
+ return new OpNode('++', $2);
135
+ }), o("DELETE Expression", function() {
136
+ return new OpNode('delete', $2);
137
+ }), o("TYPEOF Expression", function() {
138
+ return new OpNode('typeof', $2);
139
+ }), o("Expression --", function() {
140
+ return new OpNode('--', $1, null, true);
141
+ }), o("Expression ++", function() {
142
+ return new OpNode('++', $1, null, true);
143
+ }), o("Expression * Expression", function() {
144
+ return new OpNode('*', $1, $3);
145
+ }), o("Expression / Expression", function() {
146
+ return new OpNode('/', $1, $3);
147
+ }), o("Expression % Expression", function() {
148
+ return new OpNode('%', $1, $3);
149
+ }), o("Expression + Expression", function() {
150
+ return new OpNode('+', $1, $3);
151
+ }), o("Expression - Expression", function() {
152
+ return new OpNode('-', $1, $3);
153
+ }), o("Expression << Expression", function() {
154
+ return new OpNode('<<', $1, $3);
155
+ }), o("Expression >> Expression", function() {
156
+ return new OpNode('>>', $1, $3);
157
+ }), o("Expression >>> Expression", function() {
158
+ return new OpNode('>>>', $1, $3);
159
+ }), o("Expression & Expression", function() {
160
+ return new OpNode('&', $1, $3);
161
+ }), o("Expression | Expression", function() {
162
+ return new OpNode('|', $1, $3);
163
+ }), o("Expression ^ Expression", function() {
164
+ return new OpNode('^', $1, $3);
165
+ }), o("Expression <= Expression", function() {
166
+ return new OpNode('<=', $1, $3);
167
+ }), o("Expression < Expression", function() {
168
+ return new OpNode('<', $1, $3);
169
+ }), o("Expression > Expression", function() {
170
+ return new OpNode('>', $1, $3);
171
+ }), o("Expression >= Expression", function() {
172
+ return new OpNode('>=', $1, $3);
173
+ }), o("Expression == Expression", function() {
174
+ return new OpNode('==', $1, $3);
175
+ }), o("Expression != Expression", function() {
176
+ return new OpNode('!=', $1, $3);
177
+ }), o("Expression IS Expression", function() {
178
+ return new OpNode('is', $1, $3);
179
+ }), o("Expression ISNT Expression", function() {
180
+ return new OpNode('isnt', $1, $3);
181
+ }), o("Expression && Expression", function() {
182
+ return new OpNode('&&', $1, $3);
183
+ }), o("Expression || Expression", function() {
184
+ return new OpNode('||', $1, $3);
185
+ }), o("Expression AND Expression", function() {
186
+ return new OpNode('and', $1, $3);
187
+ }), o("Expression OR Expression", function() {
188
+ return new OpNode('or', $1, $3);
189
+ }), o("Expression ? Expression", function() {
190
+ return new OpNode('?', $1, $3);
191
+ }), o("Expression -= Expression", function() {
192
+ return new OpNode('-=', $1, $3);
193
+ }), o("Expression += Expression", function() {
194
+ return new OpNode('+=', $1, $3);
195
+ }), o("Expression /= Expression", function() {
196
+ return new OpNode('/=', $1, $3);
197
+ }), o("Expression *= Expression", function() {
198
+ return new OpNode('*=', $1, $3);
199
+ }), o("Expression %= Expression", function() {
200
+ return new OpNode('%=', $1, $3);
201
+ }), o("Expression ||= Expression", function() {
202
+ return new OpNode('||=', $1, $3);
203
+ }), o("Expression &&= Expression", function() {
204
+ return new OpNode('&&=', $1, $3);
205
+ }), o("Expression ?= Expression", function() {
206
+ return new OpNode('?=', $1, $3);
207
+ }), o("Expression INSTANCEOF Expression", function() {
208
+ return new OpNode('instanceof', $1, $3);
209
+ }), o("Expression IN Expression", function() {
210
+ return new OpNode('in', $1, $3);
211
+ })
212
+ ],
213
+ // The existence operator.
214
+ Existence: [o("Expression ?", function() {
215
+ return new ExistenceNode($1);
216
+ })
217
+ ],
218
+ // Function definition.
219
+ Code: [o("PARAM_START ParamList PARAM_END FuncGlyph Block", function() {
220
+ return new CodeNode($2, $5, $4);
221
+ }), o("FuncGlyph Block", function() {
222
+ return new CodeNode([], $2, $1);
223
+ })
224
+ ],
225
+ // The symbols to signify functions, and bound functions.
226
+ FuncGlyph: [o("->", function() {
227
+ return 'func';
228
+ }), o("=>", function() {
229
+ return 'boundfunc';
230
+ })
231
+ ],
232
+ // The parameters to a function definition.
233
+ ParamList: [o("", function() {
234
+ return [];
235
+ }), o("Param", function() {
236
+ return [$1];
237
+ }), o("ParamList , Param", function() {
238
+ return $1.concat([$3]);
239
+ })
240
+ ],
241
+ // A Parameter (or ParamSplat) in a function definition.
242
+ Param: [o("PARAM", function() {
243
+ return new LiteralNode(yytext);
244
+ }), o("Param . . .", function() {
245
+ return new SplatNode($1);
246
+ })
247
+ ],
248
+ // A regular splat.
249
+ Splat: [o("Expression . . .", function() {
250
+ return new SplatNode($1);
251
+ })
252
+ ],
253
+ // Expressions that can be treated as values.
254
+ Value: [o("Identifier", function() {
255
+ return new ValueNode($1);
256
+ }), o("Literal", function() {
257
+ return new ValueNode($1);
258
+ }), o("Array", function() {
259
+ return new ValueNode($1);
260
+ }), o("Object", function() {
261
+ return new ValueNode($1);
262
+ }), o("Parenthetical", function() {
263
+ return new ValueNode($1);
264
+ }), o("Range", function() {
265
+ return new ValueNode($1);
266
+ }), o("This", function() {
267
+ return $1;
268
+ }), o("Value Accessor", function() {
269
+ return $1.push($2);
270
+ }), o("Invocation Accessor", function() {
271
+ return new ValueNode($1, [$2]);
272
+ })
273
+ ],
274
+ // Accessing into an object or array, through dot or index notation.
275
+ Accessor: [o("PROPERTY_ACCESS Identifier", function() {
276
+ return new AccessorNode($2);
277
+ }), o("PROTOTYPE_ACCESS Identifier", function() {
278
+ return new AccessorNode($2, 'prototype');
279
+ }), o("SOAK_ACCESS Identifier", function() {
280
+ return new AccessorNode($2, 'soak');
281
+ }), o("Index"), o("Slice", function() {
282
+ return new SliceNode($1);
283
+ })
284
+ ],
285
+ // Indexing into an object or array.
286
+ Index: [o("INDEX_START Expression INDEX_END", function() {
287
+ return new IndexNode($2);
288
+ }), o("SOAKED_INDEX_START Expression SOAKED_INDEX_END", function() {
289
+ return new IndexNode($2, 'soak');
290
+ })
291
+ ],
292
+ // An object literal.
293
+ Object: [o("{ AssignList }", function() {
294
+ return new ObjectNode($2);
295
+ })
296
+ ],
297
+ // Assignment within an object literal (comma or newline separated).
298
+ AssignList: [o("", function() {
299
+ return [];
300
+ }), o("AssignObj", function() {
301
+ return [$1];
302
+ }), o("AssignList , AssignObj", function() {
303
+ return $1.concat([$3]);
304
+ }), o("AssignList TERMINATOR AssignObj", function() {
305
+ return $1.concat([$3]);
306
+ }), o("AssignList , TERMINATOR AssignObj", function() {
307
+ return $1.concat([$4]);
308
+ }), o("INDENT AssignList OUTDENT", function() {
309
+ return $2;
310
+ })
311
+ ],
312
+ // All flavors of function call (instantiation, super, and regular).
313
+ Call: [o("Invocation", function() {
314
+ return $1;
315
+ }), o("NEW Invocation", function() {
316
+ return $2.new_instance();
317
+ }), o("Super", function() {
318
+ return $1;
319
+ })
320
+ ],
321
+ // Extending an object's prototype.
322
+ Extends: [o("Value EXTENDS Value", function() {
323
+ return new ExtendsNode($1, $3);
324
+ })
325
+ ],
326
+ // A generic function invocation.
327
+ Invocation: [o("Value Arguments", function() {
328
+ return new CallNode($1, $2);
329
+ }), o("Invocation Arguments", function() {
330
+ return new CallNode($1, $2);
331
+ })
332
+ ],
333
+ // The list of arguments to a function invocation.
334
+ Arguments: [o("CALL_START ArgList CALL_END", function() {
335
+ return $2;
336
+ })
337
+ ],
338
+ // Calling super.
339
+ Super: [o("SUPER CALL_START ArgList CALL_END", function() {
340
+ return new CallNode('super', $3);
341
+ })
342
+ ],
343
+ // This references, either naked or to a property.
344
+ This: [o("@", function() {
345
+ return new ValueNode(new LiteralNode('this'));
346
+ }), o("@ Identifier", function() {
347
+ return new ValueNode(new LiteralNode('this'), [new AccessorNode($2)]);
348
+ })
349
+ ],
350
+ // The range literal.
351
+ Range: [o("[ Expression . . Expression ]", function() {
352
+ return new RangeNode($2, $5);
353
+ }), o("[ Expression . . . Expression ]", function() {
354
+ return new RangeNode($2, $6, true);
355
+ })
356
+ ],
357
+ // The slice literal.
358
+ Slice: [o("INDEX_START Expression . . Expression INDEX_END", function() {
359
+ return new RangeNode($2, $5);
360
+ }), o("INDEX_START Expression . . . Expression INDEX_END", function() {
361
+ return new RangeNode($2, $6, true);
362
+ })
363
+ ],
364
+ // The array literal.
365
+ Array: [o("[ ArgList ]", function() {
366
+ return new ArrayNode($2);
367
+ })
368
+ ],
369
+ // A list of arguments to a method call, or as the contents of an array.
370
+ ArgList: [o("", function() {
371
+ return [];
372
+ }), o("Expression", function() {
373
+ return [$1];
374
+ }), o("INDENT Expression", function() {
375
+ return [$2];
376
+ }), o("ArgList , Expression", function() {
377
+ return $1.concat([$3]);
378
+ }), o("ArgList TERMINATOR Expression", function() {
379
+ return $1.concat([$3]);
380
+ }), o("ArgList , TERMINATOR Expression", function() {
381
+ return $1.concat([$4]);
382
+ }), o("ArgList , INDENT Expression", function() {
383
+ return $1.concat([$4]);
384
+ }), o("ArgList OUTDENT", function() {
385
+ return $1;
386
+ })
387
+ ],
388
+ // Just simple, comma-separated, required arguments (no fancy syntax).
389
+ SimpleArgs: [o("Expression", function() {
390
+ return $1;
391
+ }), o("SimpleArgs , Expression", function() {
392
+ return $1 instanceof Array ? $1.concat([$3]) : [$1].concat([$3]);
393
+ })
394
+ ],
395
+ // Try/catch/finally exception handling blocks.
396
+ Try: [o("TRY Block Catch", function() {
397
+ return new TryNode($2, $3[0], $3[1]);
398
+ }), o("TRY Block FINALLY Block", function() {
399
+ return new TryNode($2, null, null, $4);
400
+ }), o("TRY Block Catch FINALLY Block", function() {
401
+ return new TryNode($2, $3[0], $3[1], $5);
402
+ })
403
+ ],
404
+ // A catch clause.
405
+ Catch: [o("CATCH Identifier Block", function() {
406
+ return [$2, $3];
407
+ })
408
+ ],
409
+ // Throw an exception.
410
+ Throw: [o("THROW Expression", function() {
411
+ return new ThrowNode($2);
412
+ })
413
+ ],
414
+ // Parenthetical expressions.
415
+ Parenthetical: [o("( Expression )", function() {
416
+ return new ParentheticalNode($2);
417
+ })
418
+ ],
419
+ // The condition for a while loop.
420
+ WhileSource: [o("WHILE Expression", function() {
421
+ return new WhileNode($2);
422
+ }), o("WHILE Expression WHEN Expression", function() {
423
+ return new WhileNode($2, {
424
+ filter: $4
425
+ });
426
+ })
427
+ ],
428
+ // The while loop. (there is no do..while).
429
+ While: [o("WhileSource Block", function() {
430
+ return $1.add_body($2);
431
+ }), o("Expression WhileSource", function() {
432
+ return $2.add_body($1);
433
+ })
434
+ ],
435
+ // Array comprehensions, including guard and current index.
436
+ // Looks a little confusing, check nodes.rb for the arguments to ForNode.
437
+ For: [o("Expression FOR ForVariables ForSource", function() {
438
+ return new ForNode($1, $4, $3[0], $3[1]);
439
+ }), o("FOR ForVariables ForSource Block", function() {
440
+ return new ForNode($4, $3, $2[0], $2[1]);
441
+ })
442
+ ],
443
+ // An array comprehension has variables for the current element and index.
444
+ ForVariables: [o("Identifier", function() {
445
+ return [$1];
446
+ }), o("Identifier , Identifier", function() {
447
+ return [$1, $3];
448
+ })
449
+ ],
450
+ // The source of the array comprehension can optionally be filtered.
451
+ ForSource: [o("IN Expression", function() {
452
+ return {
453
+ source: $2
454
+ };
455
+ }), o("OF Expression", function() {
456
+ return {
457
+ source: $2,
458
+ object: true
459
+ };
460
+ }), o("ForSource WHEN Expression", function() {
461
+ $1.filter = $3;
462
+ return $1;
463
+ }), o("ForSource BY Expression", function() {
464
+ $1.step = $3;
465
+ return $1;
466
+ })
467
+ ],
468
+ // Switch/When blocks.
469
+ Switch: [o("SWITCH Expression INDENT Whens OUTDENT", function() {
470
+ return $4.rewrite_condition($2);
471
+ }), o("SWITCH Expression INDENT Whens ELSE Block OUTDENT", function() {
472
+ return $4.rewrite_condition($2).add_else($6, true);
473
+ })
474
+ ],
475
+ // The inner list of whens.
476
+ Whens: [o("When", function() {
477
+ return $1;
478
+ }), o("Whens When", function() {
479
+ return $1.push($2);
480
+ })
481
+ ],
482
+ // An individual when.
483
+ When: [o("LEADING_WHEN SimpleArgs Block", function() {
484
+ return new IfNode($2, $3, null, {
485
+ statement: true
486
+ });
487
+ }), o("LEADING_WHEN SimpleArgs Block TERMINATOR", function() {
488
+ return new IfNode($2, $3, null, {
489
+ statement: true
490
+ });
491
+ }), o("Comment TERMINATOR When", function() {
492
+ $3.comment = $1;
493
+ return $3;
494
+ })
495
+ ],
496
+ // The most basic form of "if".
497
+ IfStart: [o("IF Expression Block", function() {
498
+ return new IfNode($2, $3);
499
+ }), o("IfStart ElsIfs", function() {
500
+ return $1.add_else($2);
501
+ })
502
+ ],
503
+ IfBlock: [o("IfStart", function() {
504
+ return $1;
505
+ }), o("IfStart ELSE Block", function() {
506
+ return $1.add_else($3);
507
+ })
508
+ ],
509
+ // Multiple elsifs can be chained together.
510
+ ElsIfs: [o("ELSE IF Expression Block", function() {
511
+ return (new IfNode($3, $4)).force_statement();
512
+ }), o("ElsIfs ElsIf", function() {
513
+ return $1.add_else($2);
514
+ })
515
+ ],
516
+ // The full complement of if blocks, including postfix one-liner ifs and unlesses.
517
+ If: [o("IfBlock", function() {
518
+ return $1;
519
+ }), o("Expression IF Expression", function() {
520
+ return new IfNode($3, Expressions.wrap([$1]), null, {
521
+ statement: true
522
+ });
523
+ }), o("Expression UNLESS Expression", function() {
524
+ return new IfNode($3, Expressions.wrap([$1]), null, {
525
+ statement: true,
526
+ invert: true
527
+ });
528
+ })
529
+ ]
530
+ };
531
+ // Helpers ==============================================================
532
+ // Make the Jison parser.
533
+ bnf = {};
534
+ tokens = [];
535
+ _a = grammar;
536
+ for (name in _a) { if (__hasProp.call(_a, name)) {
537
+ non_terminal = _a[name];
538
+ bnf[name] = (function() {
539
+ _b = []; _c = non_terminal;
540
+ for (_d = 0; _d < _c.length; _d++) {
541
+ option = _c[_d];
542
+ _b.push((function() {
543
+ _e = option[0].split(" ");
544
+ for (_f = 0; _f < _e.length; _f++) {
545
+ part = _e[_f];
546
+ !grammar[part] ? tokens.push(part) : null;
547
+ }
548
+ name === "Root" ? (option[1] = "return " + option[1]) : null;
549
+ return option;
550
+ }).call(this));
551
+ }
552
+ return _b;
553
+ }).call(this);
554
+ }}
555
+ tokens = tokens.join(" ");
556
+ exports.parser = new Parser({
557
+ tokens: tokens,
558
+ bnf: bnf,
559
+ operators: operators.reverse(),
560
+ startSymbol: 'Root'
561
+ }, {
562
+ debug: false
563
+ });
564
+ })();