def t_NUMBER(self, t): r'[0-9]+' try: t.value = int(t.value) except ValueError: raise ParseError("Illegal number", t) return t
def t_FLOATNUMBER(self, t): '[0-9]+[.][0-9]+' try: t.value = float(t.value) except ValueError: raise ParseError("Illegal float", t) return t
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