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,115 @@
1
+ D [0-9]
2
+ L [a-zA-Z_]
3
+ H [a-fA-F0-9]
4
+ E [Ee][+-]?{D}+
5
+ FS [fFlL]
6
+ IS [uUlL]*
7
+
8
+ %{
9
+ #include <stdio.h>
10
+ #include "y.tab.h"
11
+
12
+ void count();
13
+ %}
14
+
15
+ %%
16
+ "/*" { comment(); }
17
+
18
+ "auto" { count(); return(AUTO); }
19
+ "break" { count(); return(BREAK); }
20
+ "case" { count(); return(CASE); }
21
+ "char" { count(); return(CHAR); }
22
+ "const" { count(); return(CONST); }
23
+ "continue" { count(); return(CONTINUE); }
24
+ "default" { count(); return(DEFAULT); }
25
+ "do" { count(); return(DO); }
26
+ "double" { count(); return(DOUBLE); }
27
+ "else" { count(); return(ELSE); }
28
+ "enum" { count(); return(ENUM); }
29
+ "extern" { count(); return(EXTERN); }
30
+ "float" { count(); return(FLOAT); }
31
+ "for" { count(); return(FOR); }
32
+ "goto" { count(); return(GOTO); }
33
+ "if" { count(); return(IF); }
34
+ "int" { count(); return(INT); }
35
+ "long" { count(); return(LONG); }
36
+ "register" { count(); return(REGISTER); }
37
+ "return" { count(); return(RETURN); }
38
+ "short" { count(); return(SHORT); }
39
+ "signed" { count(); return(SIGNED); }
40
+ "sizeof" { count(); return(SIZEOF); }
41
+ "static" { count(); return(STATIC); }
42
+ "struct" { count(); return(STRUCT); }
43
+ "switch" { count(); return(SWITCH); }
44
+ "typedef" { count(); return(TYPEDEF); }
45
+ "union" { count(); return(UNION); }
46
+ "unsigned" { count(); return(UNSIGNED); }
47
+ "void" { count(); return(VOID); }
48
+ "volatile" { count(); return(VOLATILE); }
49
+ "while" { count(); return(WHILE); }
50
+
51
+ {L}({L}|{D})* { count(); return(check_type()); }
52
+
53
+ "0"[xX]{H}+{IS}? { count(); return(CONSTANT); }
54
+ "0"{D}+{IS}? { count(); return(CONSTANT); }
55
+ {D}+{IS}? { count(); return(CONSTANT); }
56
+ "L"?"'"("\'"|[^'])+"'" { count(); return(CONSTANT); }
57
+
58
+ {D}+{E}{FS}? { count(); return(CONSTANT); }
59
+ {D}*"."{D}+({E})?{FS}? { count(); return(CONSTANT); }
60
+ {D}+"."{D}*({E})?{FS}? { count(); return(CONSTANT); }
61
+
62
+ "L"?'"'('\"'|[^"])*'"' { count(); return(STRING_LITERAL); }
63
+
64
+ "..." { count(); return(ELLIPSIS); }
65
+ ">>=" { count(); return(RIGHT_ASSIGN); }
66
+ "<<=" { count(); return(LEFT_ASSIGN); }
67
+ "+=" { count(); return(ADD_ASSIGN); }
68
+ "-=" { count(); return(SUB_ASSIGN); }
69
+ "*=" { count(); return(MUL_ASSIGN); }
70
+ "/=" { count(); return(DIV_ASSIGN); }
71
+ "%=" { count(); return(MOD_ASSIGN); }
72
+ "&=" { count(); return(AND_ASSIGN); }
73
+ "^=" { count(); return(XOR_ASSIGN); }
74
+ "|=" { count(); return(OR_ASSIGN); }
75
+ ">>" { count(); return(RIGHT_OP); }
76
+ "<<" { count(); return(LEFT_OP); }
77
+ "++" { count(); return(INC_OP); }
78
+ "--" { count(); return(DEC_OP); }
79
+ "->" { count(); return(PTR_OP); }
80
+ "&&" { count(); return(AND_OP); }
81
+ "||" { count(); return(OR_OP); }
82
+ "<=" { count(); return(LE_OP); }
83
+ ">=" { count(); return(GE_OP); }
84
+ "==" { count(); return(EQ_OP); }
85
+ "!=" { count(); return(NE_OP); }
86
+ ";" { count(); return(';'); }
87
+ ("{"|"<%") { count(); return('{'); }
88
+ ("}"|"%>") %{ count(); return('}'); %}
89
+ "," { count(); return(','); }
90
+ ":" { count(); return(':'); }
91
+ "=" { count(); return('='); }
92
+ "(" { count(); return('('); }
93
+ ")" { count(); return(')'); }
94
+ ("["|"<:") { count(); return('['); }
95
+ ("]"|":>") { count(); return(']'); }
96
+ "." { count(); return('.'); }
97
+ "&" { count(); return('&'); }
98
+ "!" { count(); return('!'); }
99
+ "~" { count(); return('~'); }
100
+ "-" { count(); return('-'); }
101
+ "+" { count(); return('+'); }
102
+ "*" { count(); return('*'); }
103
+ "/" { count(); return('/'); }
104
+ "%" { count(); return('%'); }
105
+ "<" { count(); return('<'); }
106
+ ">" { count(); return('>'); }
107
+ "^" { count(); return('^'); }
108
+ "|" { count(); return('|'); }
109
+ "?" { count(); return('?'); }
110
+
111
+ [ \t\v\n\f] { count(); }
112
+ . { /* ignore bad characters */ }
113
+
114
+ %%
115
+
@@ -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,31 @@
1
+
2
+ %%
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
+ <<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,119 @@
1
+ %%
2
+
3
+ lex
4
+ : definitions include '%%' rules '%%' EOF
5
+ {{ $$ = {macros: $1, rules: $4};
6
+ if ($2) $$.actionInclude = $2;
7
+ return $$; }}
8
+ | definitions include '%%' rules EOF
9
+ {{ $$ = {macros: $1, rules: $4};
10
+ if ($2) $$.actionInclude = $2;
11
+ return $$; }}
12
+ ;
13
+
14
+ include
15
+ : action
16
+ |
17
+ ;
18
+
19
+ definitions
20
+ : definitions definition
21
+ { $$ = $1; $$.concat($2); }
22
+ | definition
23
+ { $$ = [$1]; }
24
+ ;
25
+
26
+ definition
27
+ : name regex
28
+ { $$ = [$1, $2]; }
29
+ ;
30
+
31
+ name
32
+ : NAME
33
+ { $$ = yytext; }
34
+ ;
35
+
36
+ rules
37
+ : rules rule
38
+ { $$ = $1; $$.push($2); }
39
+ | rule
40
+ { $$ = [$1]; }
41
+ ;
42
+
43
+ rule
44
+ : regex action
45
+ { $$ = [$1, $2]; }
46
+ ;
47
+
48
+ action
49
+ : ACTION
50
+ { $$ = yytext; }
51
+ ;
52
+
53
+ regex
54
+ : start_caret regex_list end_dollar
55
+ { $$ = $1+$2+$3; }
56
+ ;
57
+
58
+ start_caret
59
+ : '^'
60
+ { $$ = '^'; }
61
+ |
62
+ { $$ = ''; }
63
+ ;
64
+
65
+ end_dollar
66
+ : '$'
67
+ { $$ = '$'; }
68
+ |
69
+ { $$ = ''; }
70
+ ;
71
+
72
+ regex_list
73
+ : regex_list '|' regex_list
74
+ { $$ = $1+'|'+$3; }
75
+ | regex_list regex_base
76
+ { $$ = $1+$2;}
77
+ | regex_base
78
+ { $$ = $1;}
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
+ | string
99
+ ;
100
+
101
+ name_expansion
102
+ : '{' name '}'
103
+ {{ $$ = '{'+$2+'}'; }}
104
+ ;
105
+
106
+ any_group_regex
107
+ : ANY_GROUP_REGEX
108
+ { $$ = yytext; }
109
+ ;
110
+
111
+ range_regex
112
+ : RANGE_REGEX
113
+ { $$ = yytext; }
114
+ ;
115
+
116
+ string
117
+ : STRING_LIT
118
+ { $$ = yy.prepareString(yytext.substr(1, yytext.length-2)); }
119
+ ;
@@ -0,0 +1,58 @@
1
+ var Jison = require("../setup").Jison,
2
+ Lexer = require("../setup").Lexer,
3
+ bnf = require("../../lib/jison/bnf"),
4
+ assert = require("assert");
5
+
6
+ exports["test Lex parser"] = function () {
7
+ var lex = {
8
+ "rules": [
9
+ ["\\n+", "yy.freshLine = true;"],
10
+ ["\\s+", "yy.freshLine = false;"],
11
+ ["y\\{[^}]*\\}", "yytext = yytext.substr(2, yytext.length-3);return 'ACTION';"],
12
+ ["[a-zA-Z_][a-zA-Z0-9_-]*", "return 'NAME';"],
13
+ ["\"(?:[^\"]|\\\\\")*\"", "return 'STRING_LIT';"],
14
+ ["'(?:[^']|\\\\')*'", "return 'STRING_LIT';"],
15
+ ["\\|", "return '|';"],
16
+ ["\\[(?:[^\\]]|\\\\])*\\]", "return 'ANY_GROUP_REGEX';"],
17
+ ["\\(", "return '(';"],
18
+ ["\\)", "return ')';"],
19
+ ["\\+", "return '+';"],
20
+ ["\\*", "return '*';"],
21
+ ["\\?", "return '?';"],
22
+ ["\\^", "return '^';"],
23
+ ["\\/", "return '/';"],
24
+ ["\\$", "return '$';"],
25
+ ["%%", "return '%%';"],
26
+ ["\\{\\d+(?:,\\s?\\d+\\|,)?\\}", "return 'RANGE_REGEX';"],
27
+ ["(?=\\{)", "if(yy.freshLine){this.input('{');return '{';} else this.unput('y');"],
28
+ ["\\}", "return '}';"],
29
+ ["%\\{(?:.|\\n)*?\\}%", "yytext = yytext.substr(2, yytext.length-4);return 'ACTION';"],
30
+ [".", "/* ignore bad characters */"],
31
+ ["$", "return 'EOF';"]
32
+ ]
33
+ };
34
+
35
+ var fs = require("file");
36
+ var grammar = bnf.parse(fs.path(fs.dirname(module.id))
37
+ .join('lex.jison')
38
+ .read({charset: "utf-8"}));
39
+
40
+ var parser = new Jison.Parser(grammar);
41
+ parser.lexer = new Lexer(lex);
42
+
43
+ function encodeRE (s) { return s.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1'); }
44
+
45
+ parser.yy = {
46
+ prepareString: function (s) {
47
+ s = encodeRE(s);
48
+ if (s.match(/\w|\d$/)) {
49
+ s = s+"\\b";
50
+ }
51
+ return s;
52
+ }
53
+ };
54
+
55
+ var result = parser.parse('D [0-9]\nID [a-zA-Z][a-zA-Z0-9]+\n%%\n\n{D}"ohh\nai" {print(9);}\n"}" {stuff}');
56
+ assert.ok(result, "parse bnf production");
57
+ };
58
+
@@ -0,0 +1,117 @@
1
+ var assert = require("assert"),
2
+ lex = require("../../lib/jison/jisonlex");
3
+
4
+ exports["test lex grammar with macros"] = function () {
5
+ var lexgrammar = 'D [0-9]\nID [a-zA-Z][a-zA-Z0-9]+\n%%\n\n{D}"ohhai" {print(9);}\n"{" {return \'{\';}';
6
+ var expected = {
7
+ macros: [["D", "[0-9]"], ["ID", "[a-zA-Z][a-zA-Z0-9]+"]],
8
+ rules: [
9
+ ["{D}ohhai\\b", "print(9);"],
10
+ ["\\{", "return '{';"]
11
+ ]
12
+ };
13
+
14
+ assert.deepEqual(lex.parse(lexgrammar), expected, "grammar should be parsed correctly");
15
+ };
16
+
17
+ exports["test excaped chars"] = function () {
18
+ var lexgrammar = '%%\n"\\n"+ {return \'NL\';}\n\\n+ {return \'NL2\';}\n\\s+ {/* skip */}';
19
+ var expected = {
20
+ rules: [
21
+ ["\\\\n+", "return 'NL';"],
22
+ ["\\n+", "return 'NL2';"],
23
+ ["\\s+", "/* skip */"]
24
+ ]
25
+ };
26
+
27
+ assert.deepEqual(lex.parse(lexgrammar), expected, "grammar should be parsed correctly");
28
+ };
29
+
30
+ exports["test advanced"] = function () {
31
+ var lexgrammar = '%%\n$ {return \'EOF\';}\n. {/* skip */}\n"stuff"*/("{"|";") {/* ok */}\n(.+)[a-z]{1,2}"hi"*? {/* skip */}\n';
32
+ var expected = {
33
+ rules: [
34
+ ["$", "return 'EOF';"],
35
+ [".", "/* skip */"],
36
+ ["stuff*(?=(\\{|;))", "/* ok */"],
37
+ ["(.+)[a-z]{1,2}hi*?", "/* skip */"]
38
+ ]
39
+ };
40
+
41
+ assert.deepEqual(lex.parse(lexgrammar), expected, "grammar should be parsed correctly");
42
+ };
43
+
44
+ exports["test [^\]]"] = function () {
45
+ var lexgrammar = '%%\n"["[^\\]]"]" {return true;}\n\'f"oo\\\'bar\' {return \'baz2\';}\n"fo\\"obar" {return \'baz\';}\n';
46
+ var expected = {
47
+ rules: [
48
+ ["\\[[^\\]]\\]", "return true;"],
49
+ ["f\"oo'bar\\b", "return 'baz2';"],
50
+ ['fo"obar\\b', "return 'baz';"]
51
+ ]
52
+ };
53
+
54
+ assert.deepEqual(lex.parse(lexgrammar), expected, "grammar should be parsed correctly");
55
+ };
56
+
57
+ exports["test multiline action"] = function () {
58
+ var lexgrammar = '%%\n"["[^\\]]"]" %{\nreturn true;\n%}\n';
59
+ var expected = {
60
+ rules: [
61
+ ["\\[[^\\]]\\]", "\nreturn true;\n"]
62
+ ]
63
+ };
64
+
65
+ assert.deepEqual(lex.parse(lexgrammar), expected, "grammar should be parsed correctly");
66
+ };
67
+
68
+ exports["test include"] = function () {
69
+ var lexgrammar = '\nRULE [0-9]\n\n%{\n hi <stuff> \n%}\n%%\n"["[^\\]]"]" %{\nreturn true;\n%}\n';
70
+ var expected = {
71
+ macros: [["RULE", "[0-9]"]],
72
+ actionInclude: "\n hi <stuff> \n",
73
+ rules: [
74
+ ["\\[[^\\]]\\]", "\nreturn true;\n"]
75
+ ]
76
+ };
77
+
78
+ assert.deepEqual(lex.parse(lexgrammar), expected, "grammar should be parsed correctly");
79
+ };
80
+
81
+ exports["test bnf lex grammar"] = function () {
82
+ var fs = require("file");
83
+
84
+ var lexgrammar = lex.parse(fs.path(fs.dirname(module.id))
85
+ .join('lex', 'bnf.jisonlex')
86
+ .read({charset: "utf-8"}));
87
+
88
+ var expected = JSON.parse(fs.path(fs.dirname(module.id))
89
+ .join('lex', 'bnf.lex.json')
90
+ .read({charset: "utf-8"}));
91
+
92
+ assert.deepEqual(lexgrammar, expected, "grammar should be parsed correctly");
93
+ };
94
+
95
+ exports["test lex grammar bootstrap"] = function () {
96
+ var fs = require("file");
97
+
98
+ var lexgrammar = lex.parse(fs.path(fs.dirname(module.id))
99
+ .join('lex', 'lex_grammar.jisonlex')
100
+ .read({charset: "utf-8"}));
101
+
102
+ var expected = JSON.parse(fs.path(fs.dirname(module.id))
103
+ .join('lex', 'lex_grammar.lex.json')
104
+ .read({charset: "utf-8"}));
105
+
106
+ assert.deepEqual(lexgrammar, expected, "grammar should be parsed correctly");
107
+ };
108
+
109
+ exports["test ANSI C lexical grammar"] = function () {
110
+ var fs = require("file");
111
+
112
+ var lexgrammar = lex.parse(fs.path(fs.dirname(module.id))
113
+ .join('lex', 'ansic.jisonlex')
114
+ .read({charset: "utf-8"}));
115
+
116
+ assert.ok(lexgrammar, "grammar should be parsed correctly");
117
+ };
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env narwhal
2
+
3
+ exports.testRegExpLexer = require("./regexplexer");
4
+
5
+ if (require.main === module)
6
+ require("os").exit(require("test").run(exports));