def parse(string): return parse_tokens(jcli_tokenizer.tokenize(string))
value = bool(string) if name == "STRING": value = str(string) if name == "ID": value = sym(string) if value is not None: return syntax(value, token.line_no, token.char_no), 1 class ParserError(Exception): def __init__(self, token): self.token = token def __str__(self): t = self.token return "Syntax error at line %s, char %s: %s" % (t.line_no, t.char_no, t.string) def syntax_to_list(ast): v = ast.value if isinstance(v, linked_list): return linked_list(list(map(syntax_to_list, v))) return v if __name__ == "__main__": import jcli_tokenizer tokens = jcli_tokenizer.tokenize("'1") print(parse_tokens(tokens))