lex-parser icon indicating copy to clipboard operation
lex-parser copied to clipboard

end of line ($) doesn't work as expected

Open husio-org opened this issue 12 years ago • 2 comments

just tried to use jison, and this got me lost for hours.

$ doesn't seem to work.

jison documentation points to bison, where $ is widely used.

in the samples here the \n+ is been used instead.

husio-org avatar Aug 02 '13 13:08 husio-org

Could you provide a link to the bison docs and jison samples you're referring to? I may have totally missed this.

zaach avatar Aug 02 '13 17:08 zaach

Yes of course:

From Jison's Lexical Analysis docs you can follow "pattern matchers" into this URL:

http://dinosaur.compilertools.net/flex/flex_7.html#SEC7

And there you find:

`r$'
an r, but only at the end of a line (i.e., just before a newline). Equivalent to "r/\n".
Note that flex's notion of "newline" is exactly whatever the C compiler used to 
compile flex interprets '\n' as; in particular, on some DOS systems you must 
either filter out \r's in the input yourself, or explicitly use r/\r\n for "r$".

I was testing to write an HTTP parser where end of line is used to delimiter headers, etc. ^ and $ are very convenient in those cases.

husio-org avatar Aug 05 '13 06:08 husio-org