Trailing comments in bison

2020-12-06 Thread Maury Markowitz
In (8-bit) MS BASIC, you can do this: 10 PRINT10:REM this is a remark Or even: 20 PRINT20:' this is a remark too But I came across some code, obvious in retrospect, that does this: 30 PRINT30' this is also a remark In my flex I have these rules: REM.* { yylval.s = strndup(yytext + 3, y

Re: Trailing comments in bison

2020-12-06 Thread John P. Hartmann
First of all, my commiserations. Second, you need to deal with this in the scanner, not in the parser. Essentially, any scanner that processes random data (aka comment) as if it were program statements is going to fail miserably. And so will any parser that attempts to make sense of the maels

Re: Trailing comments in bison

2020-12-06 Thread Christian Schoenebeck
On Sonntag, 6. Dezember 2020 17:24:40 CET Maury Markowitz wrote: > In my flex I have these rules: > > REM.* { yylval.s = strndup(yytext + 3, yyleng - 3); return REM; } > '.* { yylval.s = strndup(yytext + 1, yyleng - 1); return QUOTEREM; } > > And in my bison I formerly had this: >