ZCCparser.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:ZCC 作者: hlFu 项目源码 文件源码
def p_error(p):
    if not p:
        print("End of file.")
        return

    if p.type == 'EOF':
        if ZCClex.lexer.lexer.curlyBalance > 0:
            parser.errok()
            return lex.LexToken(
                'RCURCLYBRACKET',
                '}',
                p.lexer.lineno,
                p.lexer.lexpos)
        else:
            return

    print("Syntax error at %r, at line: %d, column: %d." % (
        p.value, p.lexer.lineno, ZCClex.find_column(p.lexer.lexdata, p)))
    if p.type == 'IDENTIFIER':
        print("Undefined Type " + p.value[1])

    if parser.errorCounter > 0:
        print("In panic mode\n")
        while True:
            tok = parser.token()
            if not tok or tok.type == 'SEMICOLON' or tok.type == 'RCURLYBRACKET':
                break
        parser.restart()
    else:
        parser.errorCounter += 1
    return p
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号