solid: regenerate parser and lexer

This commit is contained in:
Ivailo Monev 2015-09-06 01:15:02 +00:00
parent fde07d67d7
commit 3094d78237
5 changed files with 753 additions and 871 deletions

View file

@ -9,7 +9,7 @@
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5
#define YY_FLEX_SUBMINOR_VERSION 35
#define YY_FLEX_SUBMINOR_VERSION 39
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif
@ -159,15 +159,7 @@ typedef void* yyscan_t;
/* Size of default input buffer. */
#ifndef YY_BUF_SIZE
#ifdef __ia64__
/* On IA-64, the buffer size is 16k, not 8k.
* Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
* Ditto for the __ia64__ case accordingly.
*/
#define YY_BUF_SIZE 32768
#else
#define YY_BUF_SIZE 16384
#endif /* __ia64__ */
#endif
/* The state buf must be large enough to hold one state per character in the main buffer.
@ -179,11 +171,17 @@ typedef void* yyscan_t;
typedef struct yy_buffer_state *YY_BUFFER_STATE;
#endif
#ifndef YY_TYPEDEF_YY_SIZE_T
#define YY_TYPEDEF_YY_SIZE_T
typedef size_t yy_size_t;
#endif
#define EOB_ACT_CONTINUE_SCAN 0
#define EOB_ACT_END_OF_FILE 1
#define EOB_ACT_LAST_MATCH 2
#define YY_LESS_LINENO(n)
#define YY_LINENO_REWIND_TO(ptr)
/* Return all but the first "n" matched characters back to the input stream. */
#define yyless(n) \
@ -201,11 +199,6 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE;
#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )
#ifndef YY_TYPEDEF_YY_SIZE_T
#define YY_TYPEDEF_YY_SIZE_T
typedef size_t yy_size_t;
#endif
#ifndef YY_STRUCT_YY_BUFFER_STATE
#define YY_STRUCT_YY_BUFFER_STATE
struct yy_buffer_state
@ -223,7 +216,7 @@ struct yy_buffer_state
/* Number of characters read into yy_ch_buf, not including EOB
* characters.
*/
int yy_n_chars;
yy_size_t yy_n_chars;
/* Whether we "own" the buffer - i.e., we know we created it,
* and can realloc() it to grow it, and should free() it to
@ -302,7 +295,7 @@ static void Solid_init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner
YY_BUFFER_STATE Solid_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
YY_BUFFER_STATE Solid_scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
YY_BUFFER_STATE Solid_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner );
YY_BUFFER_STATE Solid_scan_bytes (yyconst char *bytes,yy_size_t len ,yyscan_t yyscanner );
void *Solidalloc (yy_size_t ,yyscan_t yyscanner );
void *Solidrealloc (void *,yy_size_t ,yyscan_t yyscanner );
@ -476,7 +469,7 @@ char *PredicateParse_putSymbol( char *_name );
char *PredicateParse_putString( char *_str );
void PredicateParse_initFlex( const char *_code, yyscan_t _scanner );
#line 480 "predicate_lexer.c"
#line 473 "predicate_lexer.c"
#define INITIAL 0
@ -505,8 +498,8 @@ struct yyguts_t
size_t yy_buffer_stack_max; /**< capacity of stack. */
YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */
char yy_hold_char;
int yy_n_chars;
int yyleng_r;
yy_size_t yy_n_chars;
yy_size_t yyleng_r;
char *yy_c_buf_p;
int yy_init;
int yy_start;
@ -559,7 +552,7 @@ FILE *Solidget_out (yyscan_t yyscanner );
void Solidset_out (FILE * out_str ,yyscan_t yyscanner );
int Solidget_leng (yyscan_t yyscanner );
yy_size_t Solidget_leng (yyscan_t yyscanner );
char *Solidget_text (yyscan_t yyscanner );
@ -567,6 +560,10 @@ int Solidget_lineno (yyscan_t yyscanner );
void Solidset_lineno (int line_number ,yyscan_t yyscanner );
int Solidget_column (yyscan_t yyscanner );
void Solidset_column (int column_no ,yyscan_t yyscanner );
YYSTYPE * Solidget_lval (yyscan_t yyscanner );
void Solidset_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner );
@ -605,12 +602,7 @@ static int input (yyscan_t yyscanner );
/* Amount of stuff to slurp up with each read. */
#ifndef YY_READ_BUF_SIZE
#ifdef __ia64__
/* On IA-64, the buffer size is 16k, not 8k */
#define YY_READ_BUF_SIZE 16384
#else
#define YY_READ_BUF_SIZE 8192
#endif /* __ia64__ */
#endif
/* Copy whatever the last rule matched to the standard output. */
@ -714,11 +706,6 @@ YY_DECL
register int yy_act;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
#line 25 "predicate_lexer.l"
#line 721 "predicate_lexer.c"
yylval = yylval_param;
if ( !yyg->yy_init )
@ -747,6 +734,12 @@ YY_DECL
Solid_load_buffer_state(yyscanner );
}
{
#line 25 "predicate_lexer.l"
#line 742 "predicate_lexer.c"
while ( 1 ) /* loops until end-of-file is reached */
{
yy_cp = yyg->yy_c_buf_p;
@ -763,7 +756,7 @@ YY_DECL
yy_match:
do
{
register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
if ( yy_accept[yy_current_state] )
{
yyg->yy_last_accepting_state = yy_current_state;
@ -880,7 +873,7 @@ YY_RULE_SETUP
#line 52 "predicate_lexer.l"
ECHO;
YY_BREAK
#line 884 "predicate_lexer.c"
#line 877 "predicate_lexer.c"
case YY_STATE_EOF(INITIAL):
yyterminate();
@ -1012,6 +1005,7 @@ case YY_STATE_EOF(INITIAL):
"fatal flex scanner internal error--no action found" );
} /* end of action switch */
} /* end of scanning one token */
} /* end of user's declarations */
} /* end of Solidlex */
/* yy_get_next_buffer - try to read in a new buffer
@ -1068,21 +1062,21 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
else
{
int num_to_read =
yy_size_t num_to_read =
YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
while ( num_to_read <= 0 )
{ /* Not enough room in the buffer - grow it. */
/* just a shorter name for the current buffer */
YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
int yy_c_buf_p_offset =
(int) (yyg->yy_c_buf_p - b->yy_ch_buf);
if ( b->yy_is_our_buffer )
{
int new_size = b->yy_buf_size * 2;
yy_size_t new_size = b->yy_buf_size * 2;
if ( new_size <= 0 )
b->yy_buf_size += b->yy_buf_size / 8;
@ -1113,7 +1107,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
/* Read in more data. */
YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
yyg->yy_n_chars, (size_t) num_to_read );
yyg->yy_n_chars, num_to_read );
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
}
@ -1210,6 +1204,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
yy_is_jam = (yy_current_state == 40);
(void)yyg;
return yy_is_jam ? 0 : yy_current_state;
}
@ -1226,7 +1221,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
{ /* need to shift things up to make room */
/* +2 for EOB chars. */
register int number_to_move = yyg->yy_n_chars + 2;
register yy_size_t number_to_move = yyg->yy_n_chars + 2;
register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
register char *source =
@ -1276,7 +1271,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
else
{ /* need more input */
int offset = yyg->yy_c_buf_p - yyg->yytext_ptr;
yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr;
++yyg->yy_c_buf_p;
switch ( yy_get_next_buffer( yyscanner ) )
@ -1556,7 +1551,7 @@ void Solidpop_buffer_state (yyscan_t yyscanner)
*/
static void Solidensure_buffer_stack (yyscan_t yyscanner)
{
int num_to_alloc;
yy_size_t num_to_alloc;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if (!yyg->yy_buffer_stack) {
@ -1654,12 +1649,12 @@ YY_BUFFER_STATE Solid_scan_string (yyconst char * yystr , yyscan_t yyscanner)
* @param yyscanner The scanner object.
* @return the newly allocated buffer state object.
*/
YY_BUFFER_STATE Solid_scan_bytes (yyconst char * yybytes, int _yybytes_len , yyscan_t yyscanner)
YY_BUFFER_STATE Solid_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len , yyscan_t yyscanner)
{
YY_BUFFER_STATE b;
char *buf;
yy_size_t n;
int i;
yy_size_t i;
/* Get memory for full buffer, including space for trailing EOB's. */
n = _yybytes_len + 2;
@ -1769,7 +1764,7 @@ FILE *Solidget_out (yyscan_t yyscanner)
/** Get the length of the current token.
* @param yyscanner The scanner object.
*/
int Solidget_leng (yyscan_t yyscanner)
yy_size_t Solidget_leng (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
return yyleng;
@ -1805,7 +1800,7 @@ void Solidset_lineno (int line_number , yyscan_t yyscanner)
/* lineno is only valid if an input buffer exists. */
if (! YY_CURRENT_BUFFER )
yy_fatal_error( "Solidset_lineno called with no buffer" , yyscanner);
YY_FATAL_ERROR( "Solidset_lineno called with no buffer" );
yylineno = line_number;
}
@ -1820,7 +1815,7 @@ void Solidset_column (int column_no , yyscan_t yyscanner)
/* column is only valid if an input buffer exists. */
if (! YY_CURRENT_BUFFER )
yy_fatal_error( "Solidset_column called with no buffer" , yyscanner);
YY_FATAL_ERROR( "Solidset_column called with no buffer" );
yycolumn = column_no;
}

File diff suppressed because it is too large Load diff

View file

@ -1,25 +1,21 @@
/* A Bison parser, made by GNU Bison 3.0.4. */
/* A Bison parser, made by GNU Bison 2.4.1. */
/* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
/* Skeleton interface for Bison's Yacc-like parsers in C
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
@ -30,38 +26,44 @@
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum yytokentype {
EQ = 258,
MASK = 259,
AND = 260,
OR = 261,
IS = 262,
VAL_BOOL = 263,
VAL_STRING = 264,
VAL_ID = 265,
VAL_NUM = 266,
VAL_FLOAT = 267
};
#ifndef YY_SOLID_PREDICATE_PARSER_H_INCLUDED
# define YY_SOLID_PREDICATE_PARSER_H_INCLUDED
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
#if YYDEBUG
extern int Soliddebug;
#endif
/* Token type. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
enum yytokentype
{
EQ = 258,
MASK = 259,
AND = 260,
OR = 261,
IS = 262,
VAL_BOOL = 263,
VAL_STRING = 264,
VAL_ID = 265,
VAL_NUM = 266,
VAL_FLOAT = 267
};
#endif
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
{
/* Line 1676 of yacc.c */
#line 22 "predicate_parser.y"
union YYSTYPE
{
#line 22 "predicate_parser.y" /* yacc.c:1909 */
char valb;
int vali;
@ -69,16 +71,16 @@ typedef union YYSTYPE
char *name;
void *ptr;
#line 75 "predicate_parser.h" /* yacc.c:1909 */
};
/* Line 1676 of yacc.c */
#line 74 "predicate_parser.tab.h"
} YYSTYPE;
typedef union YYSTYPE YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
#endif
int Solidparse (void *_scanner);
#endif /* !YY_SOLID_PREDICATE_PARSER_H_INCLUDED */

View file

@ -9,7 +9,7 @@
#define YYLEX_PARAM scanner
#define YYPARSE_PARAM scanner
typedef void* yyscan_t;
void Soliderror(const char *s);
void Soliderror(void *_scanner, const char *s);
int Solidlex( YYSTYPE *yylval, yyscan_t scanner );
int Solidlex_init( yyscan_t *scanner );
int Solidlex_destroy( yyscan_t *scanner );
@ -27,6 +27,9 @@ void PredicateParse_mainParse( const char *_code );
void *ptr;
}
%lex-param { void *_scanner }
%parse-param { void *_scanner }
%token EQ
%token MASK
@ -83,7 +86,7 @@ string_list_rec: /* empty */ { $$ = PredicateParse_newEmptyStringListValue(); }
%%
void Soliderror ( const char *s ) /* Called by Solidparse on error */
void Soliderror ( void *_scanner, const char *s ) /* Called by Solidparse on error */
{
PredicateParse_errorDetected(s);
}

9
solid/solid/regen.sh Executable file
View file

@ -0,0 +1,9 @@
#!/bin/sh
# a little helper script to regenerate predicate_parser.[c,h] and predicate_lexer.c
YACC="bison"
LEX="flex"
$YACC -p Solid -d -o predicate_parser.c predicate_parser.y
$LEX -PSolid -B -i -opredicate_lexer.c predicate_lexer.l