parsing w spark
Vassilis Virvilis
vasvir at iit.demokritos.gr
Tue Nov 21 01:25:15 EST 2000
Halo,
I understand this is more related to spark than python but since I can't
find a spark related forum I thought I can ask here. If I missed one you
can point me to the right direction anyway...
A week ago I asked a question about parsing solutions on python. After a
semi careful evaluation of this group feedback I decided to use the
spark module. So currently I am trying to achieve the equivalent of a
print 'Hello world' in the compiler's world. What I would like to do is
to successfully parse the following line:
variable=value
And here is the grammar I am feeding spark.
bcfile ::= bcfile_cont
bcfile_cont ::= bcfile_cont NL
bcfile_cont ::= bcfile_cont stmt
bcfile_cont ::=
stmt ::= IDENTIFIER OPERATOR IDENTIFIER NL
I have to mention that the scanner part works as expected, but I don't
really understand how I am supposed to debug the parsing stuff (p_*
functions).
Anyway here is the output of the program with the _dump function enabled
during parsing.
Type = 'IDENTIFIER' attr = 'VERSION'
Type = 'OPERATOR' attr = '='
Type = 'IDENTIFIER' attr = '1.23p12'
Type = 'NL' attr = '\012'
state 0
START ::= . bcfile EOF , 0
bcfile ::= . bcfile_cont , 0
bcfile_cont ::= . bcfile_cont NL , 0
bcfile_cont ::= . bcfile_cont stmt , 0
bcfile_cont ::= . , 0
bcfile ::= bcfile_cont . , 0
bcfile_cont ::= bcfile_cont . NL , 0
bcfile_cont ::= bcfile_cont . stmt , 0
START ::= bcfile . EOF , 0
stmt ::= . IDENTIFIER OPERATOR IDENTIFIER NL , 0
token Type = 'IDENTIFIER' attr = 'VERSION'
state 1
token Type = 'OPERATOR' attr = '='
state 2
token Type = 'IDENTIFIER' attr = '1.23p12'
Syntax error at Type = 'IDENTIFIER' attr = 'VERSION'' (line -1)
.Bill
More information about the Python-list
mailing list