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,14 @@
1
+ {
2
+ "name": "jison",
3
+ "author": "Zach Carter",
4
+ "email": "zach@carter.name",
5
+ "keywords": [
6
+ "jison",
7
+ "parser",
8
+ "lexer",
9
+ "compiler"
10
+ ],
11
+ "githubName": "jison",
12
+ "type": "zip",
13
+ "location": "http://github.com/zaach/jison/zipball/master"
14
+ }
@@ -0,0 +1,110 @@
1
+ %%
2
+
3
+ spec
4
+ : declaration_list '%%' grammar EOF
5
+ {$$ = $1; $$.bnf = $3; return $$;}
6
+ | declaration_list '%%' grammar '%%' EOF
7
+ {$$ = $1; $$.bnf = $3; return $$;}
8
+ ;
9
+
10
+ declaration_list
11
+ : declaration_list declaration
12
+ {$$ = $1; yy.addDeclaration($$, $2);}
13
+ |
14
+ <$$ = {};>
15
+ ;
16
+
17
+ declaration
18
+ : START id
19
+ <$$ = {start: $2};>
20
+ | operator
21
+ <$$ = {operator: $1};>
22
+ ;
23
+
24
+ operator
25
+ : associativity token_list
26
+ {$$ = [$1]; $$.push.apply($$, $2);}
27
+ ;
28
+
29
+ associativity
30
+ : LEFT
31
+ {$$ = 'left';}
32
+ | RIGHT
33
+ {$$ = 'right';}
34
+ | NONASSOC
35
+ {$$ = 'nonassoc';}
36
+ ;
37
+
38
+ token_list
39
+ : token_list symbol
40
+ {$$ = $1; $$.push($2);}
41
+ | symbol
42
+ {$$ = [$1];}
43
+ ;
44
+
45
+ grammar
46
+ : production_list
47
+ {$$ = $1;}
48
+ ;
49
+
50
+ production_list
51
+ : production_list production
52
+ {$$ = $1; $$[$2[0]] = $2[1];}
53
+ | production
54
+ <$$ = {}; $$[$1[0]] = $1[1];>
55
+ ;
56
+
57
+ production
58
+ : id ':' handle_list ';'
59
+ {$$ = [$1, $3];}
60
+ ;
61
+
62
+ handle_list
63
+ : handle_list '|' handle_action
64
+ {$$ = $1; $$.push($3);}
65
+ | handle_action
66
+ {$$ = [$1];}
67
+ ;
68
+
69
+ handle_action
70
+ : handle action prec
71
+ {$$ = [($1.length ? $1.join(' ') : '')];
72
+ if($2) $$.push($2);
73
+ if($3) $$.push($3);
74
+ if ($$.length === 1) $$ = $$[0];
75
+ }
76
+ ;
77
+
78
+ handle
79
+ : handle symbol
80
+ {$$ = $1; $$.push($2)}
81
+ |
82
+ {$$ = [];}
83
+ ;
84
+
85
+ prec
86
+ : PREC symbol
87
+ <$$ = {prec: $2};>
88
+ |
89
+ {$$ = null;}
90
+ ;
91
+
92
+ symbol
93
+ : id
94
+ {$$ = $1;}
95
+ | STRING
96
+ {$$ = yytext;}
97
+ ;
98
+
99
+ id
100
+ : ID
101
+ {$$ = yytext;}
102
+ ;
103
+
104
+ action
105
+ : ACTION
106
+ {$$ = yytext;}
107
+ |
108
+ {$$ = '';}
109
+ ;
110
+
@@ -0,0 +1,25 @@
1
+
2
+ %%
3
+ \s+ {/* skip whitespace */}
4
+ "/*"[^*]*"*" {return yy.lexComment(this);}
5
+ [a-zA-Z][a-zA-Z0-9_-]* {return 'ID';}
6
+ '"'[^"]+'"' {yytext = yytext.substr(1, yyleng-2); return 'STRING';}
7
+ "'"[^']+"'" {yytext = yytext.substr(1, yyleng-2); return 'STRING';}
8
+ ":" {return ':';}
9
+ ";" {return ';';}
10
+ "|" {return '|';}
11
+ "%%" {return '%%';}
12
+ "%prec" {return 'PREC';}
13
+ "%start" {return 'START';}
14
+ "%left" {return 'LEFT';}
15
+ "%right" {return 'RIGHT';}
16
+ "%nonassoc" {return 'NONASSOC';}
17
+ "%"[a-zA-Z]+[^\n]* {/* ignore unrecognized decl */}
18
+ "{{"[^}]*"}" {return yy.lexAction(this);}
19
+ "{"[^}]*"}" {yytext = yytext.substr(1, yyleng-2); return 'ACTION';}
20
+ "<"[^>]*">" {yytext = yytext.substr(1, yyleng-2); return 'ACTION';}
21
+ . {/* ignore bad characters */}
22
+ <<EOF>> {return 'EOF';}
23
+
24
+ %%
25
+
@@ -0,0 +1,24 @@
1
+ {
2
+ "rules": [
3
+ ["\\s+", "/* skip whitespace */"],
4
+ ["\\/\\*[^*]*\\*", "return yy.lexComment(this);"],
5
+ ["[a-zA-Z][a-zA-Z0-9_-]*", "return 'ID';"],
6
+ ["\"[^\"]+\"", "yytext = yytext.substr(1, yyleng-2); return 'STRING';"],
7
+ ["'[^']+'", "yytext = yytext.substr(1, yyleng-2); return 'STRING';"],
8
+ [":", "return ':';"],
9
+ [";", "return ';';"],
10
+ ["\\|", "return '|';"],
11
+ ["%%", "return '%%';"],
12
+ ["%prec\\b", "return 'PREC';"],
13
+ ["%start\\b", "return 'START';"],
14
+ ["%left\\b", "return 'LEFT';"],
15
+ ["%right\\b", "return 'RIGHT';"],
16
+ ["%nonassoc\\b", "return 'NONASSOC';"],
17
+ ["%[a-zA-Z]+[^\\n]*", "/* ignore unrecognized decl */"],
18
+ ["\\{\\{[^}]*\\}", "return yy.lexAction(this);"],
19
+ ["\\{[^}]*\\}", "yytext = yytext.substr(1, yyleng-2); return 'ACTION';"],
20
+ ["<[^>]*>", "yytext = yytext.substr(1, yyleng-2); return 'ACTION';"],
21
+ [".", "/* ignore bad characters */"],
22
+ ["$", "return 'EOF';"]
23
+ ]
24
+ }
@@ -0,0 +1,129 @@
1
+ /* Jison lexer file format grammar */
2
+
3
+ %nonassoc '/'
4
+
5
+ %left '*' '+' '?' RANGE_REGEX
6
+
7
+ %%
8
+
9
+ lex
10
+ : definitions include '%%' rules '%%' EOF
11
+ {{ $$ = {rules: $4};
12
+ if ($1.length) $$.macros = $1;
13
+ if ($2) $$.actionInclude = $2;
14
+ return $$; }}
15
+ | definitions include '%%' rules EOF
16
+ {{ $$ = {rules: $4};
17
+ if ($1.length) $$.macros = $1;
18
+ if ($2) $$.actionInclude = $2;
19
+ return $$; }}
20
+ ;
21
+
22
+ include
23
+ : action
24
+ |
25
+ ;
26
+
27
+ definitions
28
+ : definitions definition
29
+ { $$ = $1; $$.push($2); }
30
+ |
31
+ { $$ = []; }
32
+ ;
33
+
34
+ definition
35
+ : name regex
36
+ { $$ = [$1, $2]; }
37
+ ;
38
+
39
+ name
40
+ : NAME
41
+ { $$ = yytext; }
42
+ ;
43
+
44
+ rules
45
+ : rules rule
46
+ { $$ = $1; $$.push($2); }
47
+ | rule
48
+ { $$ = [$1]; }
49
+ ;
50
+
51
+ rule
52
+ : regex action
53
+ { $$ = [$1, $2]; }
54
+ ;
55
+
56
+ action
57
+ : ACTION
58
+ { $$ = yytext; }
59
+ ;
60
+
61
+ regex
62
+ : regex_list
63
+ { $$ = $1;
64
+ if ($$.match(/[\w\d]$/))
65
+ $$ += "\\b";
66
+ }
67
+ ;
68
+
69
+ regex_list
70
+ : regex_list '|' regex_list
71
+ { $$ = $1+'|'+$3; }
72
+ | regex_concat
73
+ ;
74
+
75
+ regex_concat
76
+ : regex_concat regex_base
77
+ { $$ = $1+$2; }
78
+ | regex_base
79
+ ;
80
+
81
+ regex_base
82
+ : '(' regex_list ')'
83
+ { $$ = '('+$2+')'; }
84
+ | regex_base '+'
85
+ { $$ = $1+'+'; }
86
+ | regex_base '*'
87
+ { $$ = $1+'*'; }
88
+ | regex_base '?'
89
+ { $$ = $1+'?'; }
90
+ | '/' regex_base
91
+ { $$ = '(?='+$2+')'; }
92
+ | name_expansion
93
+ | regex_base range_regex
94
+ { $$ = $1+$2; }
95
+ | any_group_regex
96
+ | '.'
97
+ { $$ = '.'; }
98
+ | '^'
99
+ { $$ = '^'; }
100
+ | '$'
101
+ { $$ = '$'; }
102
+ | string
103
+ | escape_char
104
+ ;
105
+
106
+ name_expansion
107
+ : '{' name '}'
108
+ {{ $$ = '{'+$2+'}'; }}
109
+ ;
110
+
111
+ any_group_regex
112
+ : ANY_GROUP_REGEX
113
+ { $$ = yytext; }
114
+ ;
115
+
116
+ escape_char
117
+ : ESCAPE_CHAR
118
+ { $$ = yytext; }
119
+ ;
120
+
121
+ range_regex
122
+ : RANGE_REGEX
123
+ { $$ = yytext; }
124
+ ;
125
+
126
+ string
127
+ : STRING_LIT
128
+ { $$ = yy.prepareString(yytext.substr(1, yytext.length-2)); }
129
+ ;
@@ -0,0 +1,31 @@
1
+
2
+ %%
3
+ \n+ {yy.freshLine = true;}
4
+ \s+ {if (yy.ruleSection) yy.freshLine = false;}
5
+ "y{"[^}]*"}" {yytext = yytext.substr(2, yytext.length-3);return 'ACTION';}
6
+ [a-zA-Z_][a-zA-Z0-9_-]* {return 'NAME';}
7
+ '"'("\\\\"|'\"'|[^"])*'"' {yytext = yytext.replace(/\\"/g,'"');return 'STRING_LIT';}
8
+ "'"("\\\\"|"\'"|[^'])*"'" {yytext = yytext.replace(/\\'/g,"'");return 'STRING_LIT';}
9
+ "|" {return '|';}
10
+ "["("\]"|[^\]])*"]" {return 'ANY_GROUP_REGEX';}
11
+ "(" {return '(';}
12
+ ")" {return ')';}
13
+ "+" {return '+';}
14
+ "*" {return '*';}
15
+ "?" {return '?';}
16
+ "^" {return '^';}
17
+ "/" {return '/';}
18
+ "\\"[a-zA-Z0] {return 'ESCAPE_CHAR';}
19
+ "$" {return '$';}
20
+ "<<EOF>>" {return '$';}
21
+ "." {return '.';}
22
+ "%%" {yy.ruleSection = true; return '%%';}
23
+ "{"\d+(","\s?\d+|",")?"}" {return 'RANGE_REGEX';}
24
+ /"{" %{if (yy.freshLine) {this.input('{');return '{';} else this.unput('y');%}
25
+ "}" %{return '}';%}
26
+ "%{"(.|\n)*?"%}" {yytext = yytext.substr(2, yytext.length-4);return 'ACTION';}
27
+ . {/* ignore bad characters */}
28
+ <<EOF>> {return 'EOF';}
29
+
30
+ %%
31
+
@@ -0,0 +1,30 @@
1
+ {
2
+ "rules": [
3
+ ["\\n+", "yy.freshLine = true;"],
4
+ ["\\s+", "yy.freshLine = false;"],
5
+ ["y\\{[^}]*\\}", "yytext = yytext.substr(2, yytext.length-3);return 'ACTION';"],
6
+ ["[a-zA-Z_][a-zA-Z0-9_-]*", "return 'NAME';"],
7
+ ["\"(?:[^\"]|\\\\\")*\"", "return 'STRING_LIT';"],
8
+ ["'(?:[^']|\\\\')*'", "return 'STRING_LIT';"],
9
+ ["\\|", "return '|';"],
10
+ ["\\[(?:\\\\\\]|[^\\]])*\\]", "return 'ANY_GROUP_REGEX';"],
11
+ ["\\(", "return '(';"],
12
+ ["\\)", "return ')';"],
13
+ ["\\+", "return '+';"],
14
+ ["\\*", "return '*';"],
15
+ ["\\?", "return '?';"],
16
+ ["\\^", "return '^';"],
17
+ ["\\/", "return '/';"],
18
+ ["\\\\[a-zA-Z0]", "return 'ESCAPE_CHAR';"],
19
+ ["\\$", "return '$';"],
20
+ ["<<EOF>>", "return '$';"],
21
+ ["\\.", "return '.';"],
22
+ ["%%", "return '%%';"],
23
+ ["\\{\\d+(?:,\\s?\\d+|,)?\\}", "return 'RANGE_REGEX';"],
24
+ ["(?=\\{)", "if(yy.freshLine){this.input('{');return '{';} else this.unput('y');"],
25
+ ["\\}", "return '}';"],
26
+ ["%\\{(?:.|\\n)*?\\}%", "yytext = yytext.substr(2, yytext.length-4);return 'ACTION';"],
27
+ [".", "/* ignore bad characters */"],
28
+ ["$", "return 'EOF';"]
29
+ ]
30
+ }
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env narwhal
2
+
3
+ exports.testParser = require("./parser/parser-tests");
4
+ exports.testLexer = require("./lexer/lexer-tests");
5
+ exports.testGrammar = require("./grammar/grammar-tests");
6
+
7
+ if (require.main === module)
8
+ require("os").exit(require("test").run(exports));
@@ -0,0 +1,91 @@
1
+ var Jison = require("../setup").Jison,
2
+ Lexer = require("../setup").Lexer,
3
+ assert = require("assert");
4
+
5
+ exports["test BNF parser"] = function () {
6
+ var grammar = {
7
+ "lex": {
8
+ "rules": [
9
+ ["\\s+", "/* skip whitespace */"],
10
+ ["[a-zA-Z][a-zA-Z0-9_-]*", "return 'ID';"],
11
+ ["\"[^\"]+\"", "yytext = yytext.substr(1, yyleng-2); return 'STRING';"],
12
+ ["'[^']+'", "yytext = yytext.substr(1, yyleng-2); return 'STRING';"],
13
+ [":", "return ':';"],
14
+ [";", "return ';';"],
15
+ ["\\|", "return '|';"],
16
+ ["%%", "return '%%';"],
17
+ ["%prec", "return 'PREC';"],
18
+ ["%start", "return 'START';"],
19
+ ["%left", "return 'LEFT';"],
20
+ ["%right", "return 'RIGHT';"],
21
+ ["%nonassoc", "return 'NONASSOC';"],
22
+ ["\\{[^}]*\\}", "yytext = yytext.substr(1, yyleng-2); return 'ACTION';"],
23
+ [".", "/* ignore bad characters */"],
24
+ ["$", "return 'EOF';"]
25
+ ]
26
+ },
27
+ "bnf": {
28
+ "spec" :[[ "declaration_list %% grammar EOF", "$$ = $1; $$.bnf = $3; return $$;" ]],
29
+
30
+ "declaration_list" :[[ "declaration_list declaration", "$$ = $1; yy.addDeclaration($$, $2);" ],
31
+ [ "", "$$ = {};" ]],
32
+
33
+ "declaration" :[[ "START id", "$$ = {start: $2};" ],
34
+ [ "operator", "$$ = {operator: $1};" ]],
35
+
36
+ "operator" :[[ "associativity token_list", "$$ = [$1]; $$.push.apply($$, $2);" ]],
37
+
38
+ "associativity" :[[ "LEFT", "$$ = 'left';" ],
39
+ [ "RIGHT", "$$ = 'right';" ],
40
+ [ "NONASSOC", "$$ = 'nonassoc';" ]],
41
+
42
+ "token_list" :[[ "token_list symbol", "$$ = $1; $$.push($2);" ],
43
+ [ "symbol", "$$ = [$1];" ]],
44
+
45
+ "grammar" :[[ "production_list", "$$ = $1;" ]],
46
+
47
+ "production_list" :[[ "production_list production", "$$ = $1; $$[$2[0]] = $2[1];" ],
48
+ [ "production", "$$ = {}; $$[$1[0]] = $1[1];" ]],
49
+
50
+ "production" :[[ "id : handle_list ;", "$$ = [$1, $3];" ]],
51
+
52
+ "handle_list" :[[ "handle_list | handle_action", "$$ = $1; $$.push($3);" ],
53
+ [ "handle_action", "$$ = [$1];" ]],
54
+
55
+ "handle_action" :[[ "handle action prec", "$$ = [($1.length ? $1.join(' ') : '')]; if($2) $$.push($2); if($3) $$.push($3); if ($$.length === 1) $$ = $$[0];" ]],
56
+
57
+ "handle" :[[ "handle symbol", "$$ = $1; $$.push($2)" ],
58
+ [ "", "$$ = [];" ]],
59
+
60
+ "prec" :[[ "PREC symbol", "$$ = {prec: $2};" ],
61
+ [ "", "$$ = null;" ]],
62
+
63
+ "symbol" :[[ "id", "$$ = $1;" ],
64
+ [ "STRING", "$$ = yytext;" ]],
65
+
66
+ "id" :[[ "ID", "$$ = yytext;" ]],
67
+
68
+ "action" :[[ "ACTION", "$$ = yytext;" ],
69
+ [ "", "$$ = '';" ]]
70
+ }
71
+
72
+ };
73
+
74
+ var parser = new Jison.Parser(grammar);
75
+ parser.yy.addDeclaration = function (grammar, decl) {
76
+ if (decl.start) {
77
+ grammar.start = decl.start
78
+ }
79
+ if (decl.operator) {
80
+ if (!grammar.operators) {
81
+ grammar.operators = [];
82
+ }
83
+ grammar.operators.push(decl.operator);
84
+ }
85
+
86
+ };
87
+
88
+ var result = parser.parse('%start foo %left "+" "-" %right "*" "/" %nonassoc "=" STUFF %left UMINUS %% foo : bar baz blitz { stuff } %prec GEMINI | bar %prec UMINUS | ;\nbar: { things };\nbaz: | foo ;');
89
+ assert.ok(result, "parse bnf production");
90
+ };
91
+
@@ -0,0 +1,65 @@
1
+ var assert = require("assert"),
2
+ bnf = require("../../lib/jison/bnf"),
3
+ json2jison = require("../../lib/jison/json2jison");
4
+
5
+ exports["test basic grammar"] = function () {
6
+ var grammar = "%% test: foo bar | baz ; hello: world ;";
7
+ var expected = {bnf: {test: ["foo bar", "baz"], hello: ["world"]}};
8
+
9
+ assert.deepEqual(bnf.parse(grammar), expected, "grammar should be parsed correctly");
10
+ };
11
+
12
+ exports["test classy grammar"] = function () {
13
+ var grammar = "%%\n\npgm \n: cdl MAIN LBRACE vdl el RBRACE ENDOFFILE \n; cdl \n: c cdl \n| \n;";
14
+ var expected = {bnf: {pgm: ["cdl MAIN LBRACE vdl el RBRACE ENDOFFILE"], cdl: ["c cdl", ""]}};
15
+
16
+ assert.deepEqual(bnf.parse(grammar), expected, "grammar should be parsed correctly");
17
+ };
18
+
19
+ exports["test advanced grammar"] = function () {
20
+ var grammar = "%% test: foo bar {action} | baz ; hello: world %prec UMINUS ;extra: foo {action} %prec '-' ;";
21
+ var expected = {bnf: {test: [["foo bar", "action" ], "baz"], hello: [[ "world", {prec:"UMINUS"} ]], extra: [[ "foo", "action", {prec: "-"} ]]}};
22
+
23
+ assert.deepEqual(bnf.parse(grammar), expected, "grammar should be parsed correctly");
24
+ };
25
+
26
+ exports["test nullable rule"] = function () {
27
+ var grammar = "%% test: foo bar | ; hello: world ;";
28
+ var expected = {bnf: {test: ["foo bar", ""], hello: ["world"]}};
29
+
30
+ assert.deepEqual(bnf.parse(grammar), expected, "grammar should be parsed correctly");
31
+ };
32
+
33
+ exports["test nullable rule with action"] = function () {
34
+ var grammar = "%% test: foo bar | {action}; hello: world ;";
35
+ var expected = {bnf: {test: ["foo bar", [ "", "action" ]], hello: ["world"]}};
36
+
37
+ assert.deepEqual(bnf.parse(grammar), expected, "grammar should be parsed correctly");
38
+ };
39
+
40
+ exports["test nullable rule with < > delimited action"] = function () {
41
+ var grammar = "%% test: foo bar | <action{}>; hello: world ;";
42
+ var expected = {bnf: {test: ["foo bar", [ "", "action{}" ]], hello: ["world"]}};
43
+
44
+ assert.deepEqual(bnf.parse(grammar), expected, "grammar should be parsed correctly");
45
+ };
46
+
47
+ exports["test nullable rule with {{ }} delimited action"] = function () {
48
+ var grammar = "%% test: foo bar | {{action{};}}; hello: world ;";
49
+ var expected = {bnf: {test: ["foo bar", [ "", "action{};" ]], hello: ["world"]}};
50
+
51
+ assert.deepEqual(bnf.parse(grammar), expected, "grammar should be parsed correctly");
52
+ };
53
+
54
+ exports["test comment"] = function () {
55
+ var grammar = "/* comment */ %% hello: world ;";
56
+ var expected = {bnf: {hello: ["world"]}};
57
+
58
+ assert.deepEqual(bnf.parse(grammar), expected, "grammar should be parsed correctly");
59
+ };
60
+ exports["test comment with nested *"] = function () {
61
+ var grammar = "/* comment * not done */ %% hello: /* oh hai */ world ;";
62
+ var expected = {bnf: {hello: ["world"]}};
63
+
64
+ assert.deepEqual(bnf.parse(grammar), expected, "grammar should be parsed correctly");
65
+ };
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env narwhal
2
+
3
+ //exports.testBNF = require("./bnf");
4
+ exports.testBNFParse = require("./bnf_parse");
5
+ exports.testConvert = require("./json2jison");
6
+ //exports.testLex = require("./lex");
7
+ exports.testLexParse = require("./lex_parse");
8
+
9
+ if (require.main === module)
10
+ require("os").exit(require("test").run(exports));
@@ -0,0 +1,24 @@
1
+ var assert = require("assert"),
2
+ bnf = require("../../lib/jison/bnf");
3
+ json2jison = require("../../lib/jison/json2jison");
4
+
5
+ exports["test basic grammar"] = function () {
6
+ var grammar = "%% test: foo bar | baz ; hello: world ;";
7
+ var expected = {bnf: {test: ["foo bar", "baz"], hello: ["world"]}};
8
+
9
+ assert.deepEqual(json2jison.convert(bnf.parse(grammar)), json2jison.convert(expected), "grammar should be parsed correctly");
10
+ };
11
+
12
+ exports["test advanced grammar"] = function () {
13
+ var grammar = "%start foo %% test: foo bar | baz ; hello: world {action} %prec UM;";
14
+ var expected = {start: "foo", bnf: {test: ["foo bar", "baz"], hello: [[ "world", "action", {prec: "UM"} ]]}};
15
+
16
+ assert.deepEqual(json2jison.convert(bnf.parse(grammar)), json2jison.convert(expected), "grammar should be parsed correctly");
17
+ };
18
+
19
+ exports["test actions"] = function () {
20
+ var grammar = "%start foo %% test: foo bar | baz ; hello: world {{action{} }} %prec UM;";
21
+ var expected = {start: "foo", bnf: {test: ["foo bar", "baz"], hello: [[ "world", "action{}", {prec: "UM"} ]]}};
22
+
23
+ assert.deepEqual(json2jison.convert(bnf.parse(grammar)), json2jison.convert(expected), "grammar should be parsed correctly");
24
+ };