[Tutor] Parsing suggestion? (CUE file) -- identify result
spir
denis.spir at free.fr
Wed Feb 4 09:08:27 CET 2009
Le Tue, 3 Feb 2009 17:36:41 -0500,
Kent Johnson <kent37 at tds.net> a écrit :
> I think your use of the csv module is fine. What I really meant to say
> was more like, I would have looked to pyparsing to solve the same
> problem, and if you want a parser that parses the file into meaningful
> records, then it might still be worth a look.
This would require heavy use of the setResultsName() method to attach "semantic tags" to the parse results; so that when you dig into them you know what each snippet is -- without the need of partial reparsing ;-)
The point can be illustrated with the simple case of parsing arithmetic operations. Imagine each operand of a '+' can be a (litteral) number, a symbol (name), a grouped (parenthesized) sub-operation, an operation of higher priority. The result beeing of the form
[op1, '+', op2]
There is no other way to know what kind of thing op1 and op2 are, if they don't themselves carry the information, than re-examining them. Which has already beeing done while parsing. (The information needed is the name of the parsing rule used to yield the result.)
Denis
>
> Kent
------
la vida e estranya
More information about the Tutor
mailing list