示例#1
0
 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])])
示例#2
0
 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)))
示例#3
0
 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)))
示例#4
0
 def statements(self, p):
     if p.statement is None:
         node('code')
     else:
         return node('code', [p.statement])
示例#5
0
 def code(self, p):
     if p.statements is None:
         pass
     else:
         return node('code', [p.statements])
示例#6
0
 def bexpr(self, p):
     return node(p[1], [p.expr0, p.expr1])
示例#7
0
 def expr(self, p):
     return node('uminus', [p.expr])
示例#8
0
 def expr(self, p):
     return node(('string', p.STRING))
示例#9
0
 def expr(self, p):
     return node(('id', p.ID))
示例#10
0
 def expr(self, p):
     return node(('bool', p.BOOL))
示例#11
0
 def expr(self, p):
     return node(('number', p.NUMBER))
示例#12
0
 def codeblock(self, p):
     return node('codeblock', [p.statements])
示例#13
0
 def statement(self, p):
     self.line_start = p.index
     return node(('mission', p.STRING), [p.codeblock])