Re: evaluating parsed expressions

[email protected] (Ted Zlatanov)
Newsgroups perl.recdescent
Organization Теодор Златанов @ Cienfuegos
Message-ID <[email protected]>
Thanks for the suggestions.  I don't want to keep a symbol table,
because it would have to be cleared every time I re-run the parser.
The state of the defined classes (and thus the logical value of each
symbol) may change with each invocation of the parser (once per
configuration line).  I'm not parsing a static file, each line may
actually define a new class or undefine an old one.  Something like
this (define/undefine syntax is not important):

 # start with a,c,d defined
 a.c.d:: define(hello) # will run
 a.c.hello:: undefine(a) # will run
 a:: anything() # will not run

A simplified version of my unsuccessful grammars:

 or: atom '|' atom { $return = $item[1] || $item[3]; 1; }
 atom: /(\w+)/ { $return = ::get_value($1); 1; }

did not work for me.  The parser would always break off at the 'or'
without descending into the atom evaluation, or I would get weird
parsing errors.  I ended up having each parsed element return a
subroutine that, when evaluated with the matched parameters, will do
the right thing.  See my previous message for the gory details.

I hope my explanations are making this clearer.  I keep having the
feeling the answer is very simple, I just don't get it :)

Thanks
Ted
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.