def p_error(p):
    """
        YACC Error Callback from the parser.  The parameter is the token
        in error and contains information on the file and position of the
        error. If p is `None`, PLY is returning eof error.
    """

    if p is None:
        raise MOFParseError(msg='Unexpected end of file')

    msg = p.lexer.last_msg
    p.lexer.last_msg = None
    raise MOFParseError(parser_token=p, msg=msg)