Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

allow comments in lexer files - issue #103

  • Loading branch information...
commit cb46c39ac35cc1786c2298b3d64d4a3dabc81070 1 parent ffcd4be
@zaach authored
Showing with 14 additions and 0 deletions.
  1. +3 −0  src/jisonlex.l
  2. +11 −0 tests/grammar/lex_parse.js
View
3  src/jisonlex.l
@@ -37,6 +37,9 @@ NAME [a-zA-Z_][a-zA-Z0-9_-]*
"%{"(.|\n)*?"%}" yytext = yytext.substr(2, yytext.length-4); return 'ACTION'
<indented>.+ this.begin('rules'); return 'ACTION'
+"/*"(.|\n|\r)*?"*/" /* ignore */
+"//".* /* ignore */
+
\n+ /* */
\s+ /* */
{NAME} return 'NAME'
View
11 tests/grammar/lex_parse.js
@@ -294,3 +294,14 @@ exports["test [^\\\\]"] = function () {
assert.deepEqual(lex.parse(lexgrammar), expected, "grammar should be parsed correctly");
};
+
+exports["test comments"] = function () {
+ var lexgrammar = "/* */ // foo\n%%\nfoo* return 1";
+ var expected = {
+ rules: [
+ ["foo*", "return 1"]
+ ]
+ };
+
+ assert.deepEqual(lex.parse(lexgrammar), expected, "grammar should be parsed correctly");
+};
Please sign in to comment.
Something went wrong with that request. Please try again.