def statements(self, p): if p.statements is None and p.statement is None: return None elif p.statement is None: return node('statements', [p.statements]) elif p.statements is None: return node('statements', [node('statement', [p.statement])]) else: return node( 'statements', [p.statements, node('statement', [p.statement])])
def statement(self, p): self.line_start = p.index #return node('print', [p[2]]) if hasattr(p, 'expr'): return node(('print'), [p[2]]) elif hasattr(p, 'bexpr'): return node(('print'), [p[2]]) else: return node( ('error', "There was a print error at line {}, char {}. Token {}({})". format(p.error.lineno, p.error.index - self.line_start, p.error.type, p.error.value)))
def expr(self, p): #return p[1] if hasattr(p, 'expr'): return p[1] else: return node(( 'error', "There was an operator error at line {}, char {}. Token {}({})" .format(p.error.lineno, p.error.index - self.line_start - self.char_adj, p.error.type, p.error.value)))
def statements(self, p): if p.statement is None: node('code') else: return node('code', [p.statement])
def code(self, p): if p.statements is None: pass else: return node('code', [p.statements])
def bexpr(self, p): return node(p[1], [p.expr0, p.expr1])
def expr(self, p): return node('uminus', [p.expr])
def expr(self, p): return node(('string', p.STRING))
def expr(self, p): return node(('id', p.ID))
def expr(self, p): return node(('bool', p.BOOL))
def expr(self, p): return node(('number', p.NUMBER))
def codeblock(self, p): return node('codeblock', [p.statements])
def statement(self, p): self.line_start = p.index return node(('mission', p.STRING), [p.codeblock])