def parse(data): global prop prop = [] lexer = lex.lex() lexer.input(data) import lexer.ply.yacc as yacc parser = yacc.yacc() parser.parse(data, tracking=True) return prop
def yaccing(data, get_errros=True): global erreurs, lignes erreurs = [] lignes = {} lexer = lex.lex() lexer.input(data) import lexer.ply.yacc as yacc parser = yacc.yacc() parser.parse(data, tracking=True) return [erreurs, lignes] if get_errros else lignes
def yaccing(data, get_errros=True): global erreurs, lignes erreurs = [] lignes = {} lexer = lex.lex() lexer.input(data) import lexer.ply.yacc as yacc parser = yacc.yacc() parser.parse(data, tracking=True) # parser.parse(data) # for i in sorted([int(i) for i in list(lignes.keys())]): # print("ligne numero %s: %s" % (i + 1, lignes[str(i)]), "\n\n") return [erreurs, lignes] if get_errros else lignes
""" if len(p) == 4: p[0] = p[2] else: p[0] = p[1] def p_oper(p): "oper : expr OPER" p[0] = S('oper', (p[1], p[2])) def p_error(p): if p: print("PLYPLUS: Syntax error in grammar at '%s'" % p.value, 'line', p.lineno, 'type', p.type) else: print("PLYPLUS: Unknown syntax error in grammar") start = "extgrammar" _parser = yacc.yacc(debug=DEBUG, tabmodule=YACC_TAB_MODULE, outputdir=PLYPLUS_DIR) # Return parser object def parse(text, debug=False): lexer.lineno = 1 return _parser.parse(text, lexer=lexer, debug=debug)
def build_parser(self, cache_file): self.parser = yacc.yacc(module=self.callback, debug=self.options.debug, tabmodule=cache_file, errorlog=grammar_logger, outputdir=PLYPLUS_DIR)