How to obtain a flattened list of tokens

Lex Yaccer <tech.login.id@gmail.com>
Mon, 9 Nov 2009 03:24:39 -0800 (PST)

          From comp.compilers

Related articles
How to obtain a flattened list of tokens tech.login.id@gmail.com (Lex Yaccer) (2009-11-09)
| List of all articles for this month |

From: Lex Yaccer <tech.login.id@gmail.com>
Newsgroups: comp.compilers
Date: Mon, 9 Nov 2009 03:24:39 -0800 (PST)
Organization: Compilers Central
Keywords: parse, question
Posted-Date: 11 Nov 2009 01:01:54 EST

Hello,


I want to view a flattened list of all rules for a particular non-
terminal (can be the top-most one too).
So, for something like:


top: middle1 | middle2


middle1: leaf1 leaf2 | leaf3


leaf1: terminal1 | terminal2
leaf2: terminal3 | terminal4
leaf3: terminal5


I would like to see flattened list for middle1 as




middle1: terminal1 terminal3
| terminal2 terminal3
| terminal1 terminal4
| terminal2 terminal4
| terminal5


Thus, all the possible rules for middle1 are flattened out in terms of
its terminals.


[In general it's impossible since recursive rules have a potentially
infinite expansion, but for cases where there's no reference loops
it's just a simple macro expansion. -John]



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.