Comparing version 0.3.6 to 0.3.7
@@ -43,3 +43,3 @@ var EBNF = (function(){ | ||
var parser = new require('jison').Parser(grammar); | ||
var parser = new require('../jison').Parser(grammar); | ||
@@ -46,0 +46,0 @@ var transformExpression = function(e, opts, emit) { |
@@ -47,3 +47,3 @@ // Basic RegExp Lexer | ||
} | ||
m = new RegExp("^"+m, caseless ? 'i':''); | ||
m = new RegExp("^(?:"+m+")", caseless ? 'i':''); | ||
} | ||
@@ -105,2 +105,6 @@ newRules.push(m); | ||
if (dict.options && dict.options.flex) { | ||
dict.rules.push([".", "console.log(yytext);"]); | ||
} | ||
this.rules = prepareRules(dict.rules, dict.macros, actions, tokens && toks, this.conditions, this.options["case-insensitive"]); | ||
@@ -107,0 +111,0 @@ var fun = actions.join("\n"); |
@@ -5,3 +5,3 @@ { | ||
"description": "A parser generator with Bison's API", | ||
"version": "0.3.6", | ||
"version": "0.3.7", | ||
"keywords": [ | ||
@@ -8,0 +8,0 @@ "jison", |
@@ -757,1 +757,34 @@ var RegExpLexer = require("../setup").RegExpLexer, | ||
}; | ||
exports["test flex mode default rule"] = function() { | ||
var dict = { | ||
rules: [ | ||
["x", "return 'X';" ] | ||
], | ||
options: {flex: true} | ||
}; | ||
var input = "xyx"; | ||
var lexer = new RegExpLexer(dict); | ||
lexer.setInput(input); | ||
assert.equal(lexer.lex(), "X"); | ||
assert.equal(lexer.lex(), "X"); | ||
}; | ||
exports["test pipe precedence"] = function() { | ||
var dict = { | ||
rules: [ | ||
["x|y", "return 'X_Y';" ], | ||
[".", "return 'N';"] | ||
] | ||
}; | ||
var input = "xny"; | ||
var lexer = new RegExpLexer(dict); | ||
lexer.setInput(input); | ||
assert.equal(lexer.lex(), "X_Y"); | ||
assert.equal(lexer.lex(), "N"); | ||
assert.equal(lexer.lex(), "X_Y"); | ||
}; |
276246
6667