Esempio n. 1
0
 def _expect(self, s):
     if self._accept(s):
         return True
     
     err = ("Error: unexpected symbol in line %d. Expected %s, but found %s" %
             (self._lexer.get_current_line_number(), Symbol.as_str(s), Symbol.as_str(self._sym))) 
     if self._printable_symbol():
         err += " (" + self._text + ")"
     err += ": " + self._lexer.get_raw_buffer()
     raise ValueError(err)
Esempio n. 2
0
    def _expect(self, s):
        if self._accept(s):
            return True

        err = (
            "Error: unexpected symbol in line %d. Expected %s, but found %s" %
            (self._lexer.get_current_line_number(), Symbol.as_str(s),
             Symbol.as_str(self._sym)))
        if self._printable_symbol():
            err += " (" + self._text + ")"
        err += ": " + self._lexer.get_raw_buffer()
        raise ValueError(err)
Esempio n. 3
0
 def _expect_one_of(self, symbol_list):
     if self._accept_one_of(symbol_list):
         return True
     
     expected = ", ".join([Symbol.as_str(x) for x in symbol_list])
     
     err = ("Error: unexpected symbol in line %d. Expected one of %s, but found %s" %
             (self._lexer.get_current_line_number(), expected, Symbol.as_str(self._sym))) 
     if self._printable_symbol():
         err += " (" + self._text + ")"
     err += ": " + self._lexer.get_raw_buffer()
     raise ValueError(err)
Esempio n. 4
0
    def _expect_one_of(self, symbol_list):
        if self._accept_one_of(symbol_list):
            return True

        expected = ", ".join([Symbol.as_str(x) for x in symbol_list])

        err = (
            "Error: unexpected symbol in line %d. Expected one of %s, but found %s"
            % (self._lexer.get_current_line_number(), expected,
               Symbol.as_str(self._sym)))
        if self._printable_symbol():
            err += " (" + self._text + ")"
        err += ": " + self._lexer.get_raw_buffer()
        raise ValueError(err)