Path: csiph.com!xmission!news.snarked.org!border2.nntp.dca1.giganews.com!nntp.giganews.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end From: rockbrentwood@gmail.com Newsgroups: comp.compilers Subject: Yacc with multiple entry points. Date: Mon, 9 Dec 2019 16:13:06 -0800 (PST) Organization: Compilers Central Lines: 8 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <19-12-003@comp.compilers> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="96022"; mail-complaints-to="abuse@iecc.com" Keywords: yacc, parse, comment Posted-Date: 10 Dec 2019 13:23:10 EST X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com Xref: csiph.com comp.compilers:2384 There is a lot of saving and code-reuse possible if multiple entry points are allowed in a parser generator. This can be done by a simple extension of the LR process, but does complicate the issue of end-markers a little. You'll see brief mention of it, by the way, here on page 199 of the Lex and Yacc reference. https://books.google.com/books?id=vsHcnR4kXIAC&pg=PA199&lpg=PA199 authored by (... searching author page ...) Oh! The moderator, John! [I put the same trick on pp 163-164 of flex&bison. Fiddle the lexer so it sends the parser a fake token when it starts and use initial rules with the fake token to select the real entry point. That works in plain yacc or bison. -John]