I am trying write a parser code for following production rule.
Statement: Variable+ | epsilon
My initial implementation:
'''
Statement: Variables | epsilon
Variables: Variable Variables | Variable (one or more variable)
epsilon: null ('')
'''
*** Variable is already implemented***
@_('Variables')
def Statement(self,p):
return p.Variables
@_('Variable Variables', 'Variable')
def Variables(self,p):
return p.Variable
@_('')
def epsilon(self,p):
pass
@_('epsilon')
def Statement(self,p):
return p
I get following error:
WARNING: Symbol 'epsilon' is unreachable.
WARNING: Symbol 'Statement' is unreachable
Without having your complete code on-hand, I suspect that what has happened is that you defined "Variable" earlier than "Statement". As per the documentation:
Indeed, if I take the calc example shipped with the program, and add an additional rule before "statement", even one that is used by "statement", I get very similar errors to what you have listed, since Sly can't figure out how to get to "statement" from that first grammar rule.
Added Rules
Error on running