zaach / jison

Bison in JavaScript.
http://jison.org
4.34k stars 448 forks source link

definitions inconsistencies between lex and jison #333

Open mbroadst opened 7 years ago

mbroadst commented 7 years ago

Hi, I'm attempting to port the ansi C lex grammar here and running into issues with the initial definitions, specifically with the sections:

FS          (f|F|l|L)
IS          (u|U|l|L)*

throwing an Error: Could not parse lex grammar error.

It's my understanding that these should just be regular expressions, so I'm not sure why jison is having trouble parsing them. I'm sure I'm missing something very simple here, but a cursory perusal of the documentation didn't elicit anything on this end - hopefully someone can correct me.

GerHobbelt commented 7 years ago

AFAICT this is a 'problem' in the 'vanilla' lexer, which requires double-quotes around literal parts of a lexer rule regex, i.e.

FS          ("f"|"F"|"l"|"L")
IS          ("u"|"U"|"l"|"L")*

should work.

The GerHobbelt fork doesn't exhibit this problem as I augmented the lexer to recognize literal regex parts without the need for quotes, whenever possible, as this was pretty frustrating to me, back when I started out using jison (and having grown up on yacc/bison/lex/flex and similar code generators)