[talk] lex start conditions.
Warner Losh
imp at bsdimp.com
Wed Oct 28 21:04:09 EDT 2020
What was the original OS this thing is from? 40 years is 1980, which
suggests V7. If so, I'd lookup how to boot V7 on a PDP-11 with simh and
compile it there to see what this translates to... If you have the source
code and can share off list, I can run it on one of mine...
Warner
On Wed, Oct 28, 2020 at 6:31 PM R. Clayton <factotum at rclayton.org> wrote:
> I'm working with a 40-year-old lex program that uses statements like
>
> BEGIN PROGRAM + 1;
>
> I understand what
>
> BEGIN PROGRAM;
>
> does, but what is the intention of the "+ 1"? Does it skip the first rule
> in
> the <PROGRAM> context? The generated code suggests not, but I haven't dug
> into
> it too deeply. Does it select the context listed after the <PROGRAM>
> context?
> That seems slightly more plausible, but a test lex program doesn't support
> that
> intention (it's likely the test program is ineffectively written). I'm
> using
> flex, not a 40-year-old version of lex.
>
> For completeness, here's the test program:
>
> $ cat t.lex
> %s A B C
>
> %%
> BEGIN A;
>
> <A>[BC] if (yytext[0] == 'B') BEGIN B + 1; else BEGIN C;
> <A>. printf("A: '%c'\n", yytext[0]);
>
> <B>[AC] if (yytext[0] == 'A') BEGIN A; else BEGIN C;
> <B>. printf("B: '%c'\n", yytext[0]);
>
> <C>[AB] if (yytext[0] == 'A') BEGIN A; else BEGIN B;
> <C>. printf("C: '%c'\n", yytext[0]);
>
> %%
>
> main() { yylex(); }
>
> $ echo abcBabc | ./a.out
> A: 'a'
> A: 'b'
> A: 'c'
> B: 'a'
> B: 'b'
> B: 'c'
>
> $
>
> _______________________________________________
> talk mailing list
> talk at lists.nycbug.org
> http://lists.nycbug.org:8080/mailman/listinfo/talk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nycbug.org/pipermail/talk/attachments/20201028/34402671/attachment.htm>
More information about the talk
mailing list