Alien-LibJIT
view release on metacpan or search on metacpan
libjit/dpas/dpas-parser.y view on Meta::CPAN
%{
/*
* dpas-parser.y - Bison grammar for the Dynamic Pascal language.
*
* Copyright (C) 2004 Southern Storm Software, Pty Ltd.
*
* This file is part of the libjit library.
*
* The libjit library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 2.1 of
* the License, or (at your option) any later version.
*
* The libjit library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with the libjit library. If not, see
* <http://www.gnu.org/licenses/>.
*/
#include "dpas-internal.h"
#include <jit/jit-dump.h>
#include <config.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_STDARG_H
#include <stdarg.h>
#elif HAVE_VARARGS_H
#include <varargs.h>
#endif
/*
* Imports from the lexical analyser.
*/
extern int yylex(void);
#ifdef YYTEXT_POINTER
extern char *yytext;
#else
extern char yytext[];
#endif
/*
* Error reporting flag.
*/
int dpas_error_reported = 0;
/*
* Function dumping flag.
*/
int dpas_dump_functions = 0;
/*
* Report error messages from the parser.
*/
static void yyerror(char *msg)
{
char *text = yytext;
char *newmsg;
int posn, outposn;
dpas_error_reported = 1;
if(!jit_strcmp(msg, "parse error") || !jit_strcmp(msg, "syntax error"))
{
/* This error is pretty much useless at telling the user
what is happening. Try to print a better message
based on the current input token */
simpleError:
if(text && *text != '\0')
{
fprintf(stderr, "%s:%ld: parse error at or near `%s'\n",
dpas_filename, dpas_linenum, text);
}
else
{
fprintf(stderr, "%s:%ld: parse error\n",
dpas_filename, dpas_linenum);
}
}
( run in 0.491 second using v1.01-cache-2.11-cpan-df04353d9ac )