[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Call a non-start production
From: |
Joel E. Denny |
Subject: |
Re: Call a non-start production |
Date: |
Sun, 18 Jul 2010 14:08:24 -0400 (EDT) |
User-agent: |
Alpine 1.00 (DEB 882 2007-12-20) |
On Sun, 18 Jul 2010, Panayiotis Karabassis wrote:
> The problem is that I would like to select different start symbols at
> run-time.
Where start is your original start symbol, extend your grammar like this:
start_extended:
start
| TK_EXPRESSION expression
| TK_FOO foo
;
At run-time, if you want to test expression, set a flag that causes your
scanner to return TK_EXPRESSION before scanning the input. Likewise for
foo and TK_FOO.
A push parser makes this even easier because you can push TK_EXPRESSION or
TK_FOO to the parser before pull-parsing the rest of the input stream, so
you don't have to implement flags to direct the scanner. However, we
haven't implemented push parsing for C++ yet.