I'm trying to use Jison.
Here's my grammar:
var grammar = {
lex:{
rules:[
["\\s+", ""],
["then", "return 'newline';"],
["goto", "return 'goto';"],
["http[^\\s]*", "return 'url';"],
["search", "return 'search';"],
["should_exist", "return 'exist';"],
//["#(.)*", "return 'elementById';"],
//["$", "return 'EOF';"]
]
},
bnf:{
lines:[
['lines line', "console.log('big expression is ',$3); return ['l2',$1, $2];"],
['line', "console.log('expression is ',$1); return ['l1',$1]"],
],
line:[
["line newline", "console.log('line newline', $1); $$ = $1"],
["goto url", "console.log('goto', $2); $$ = {cmd:'goto', url: $2 } "],
["elementById exist", "$$ = {cmd:'assert', elId: $1} "]
]
}
};
When I try to parse goto http://www.google.com then goto http://www.bing.com
I only ever get [ 'l1', { cmd: 'goto', url: 'http://www.google.com' } ]
returned.
I'm expecting to get both goto commands returned.
Any help with me figuring out my grammar?