Пример #1
0
 def t_FLOATNUMBER(self, t):
     '[0-9]+[.][0-9]+'
     try:
         t.value = float(t.value)
     except ValueError:
         raise ParseError("Illegal float", t)
     return t
Пример #2
0
 def t_NUMBER(self, t):
     r'[0-9]+'
     try:
         t.value = int(t.value)
     except ValueError:
         raise ParseError("Illegal number", t)
     return t
Пример #3
0
 def p_decl__protocol(self, p):
     "decl : PROTOCOL STRING SEMI"
     if self.protocol:
         msg = "Protocol can only be set once! Error at %s:%s\n" % \
             (self.current_source, self.current_line)
         raise ParseError(msg)
     self.protocol = p[2]
     p[0] = None