Wednesday, 11 September 2013

how to write kleene closure in a production?

how to write kleene closure in a production?

I'm writing a parser using PLY. The language the parser is for is called
s-lang, in the grammar of the language I have the following production:
IdentList ¨ IdentList , identifier ArrayBrackets*
I have already written the production for ArrayBrackets. I tried writing
the above production as
def p_IdentList(t):
'''IdentList : IdentList COMMA ID ArrayBrackets*'''
I have regular expressions for the vars COMMA and ID. Th problem is that
when I include the star, I get the following error:
ERROR: main.py:115: Illegal name 'ArrayBrackets*' in rule 'IdentList'
Traceback (most recent call last):
File "main.py", line 175, in <module>
I tried escpacing the star but it didn't help --- how am I supposed to
write the Kleene closure in a production?

No comments:

Post a Comment