mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
Prototype support of %lex-param and %parse-param.
* src/parse-gram.y: Add the definition of the %lex-param and %parse-param tokens, plus their rules. Drop the `_' version of %glr-parser. Add the "," token. * src/scan-gram.l (INITIAL): Scan them. * src/muscle_tab.c: Comment changes. (muscle_insert, muscle_find): Rename `pair' as `probe'. * src/muscle_tab.h (MUSCLE_INSERT_PREFIX): Remove unused. (muscle_entry_s): The `value' member is no longer const. Adjust all dependencies. * src/muscle_tab.c (muscle_init): Adjust: use MUSCLE_INSERT_STRING. Initialize the obstack earlier. * src/muscle_tab.h, src/muscle_tab.c (muscle_grow) (muscle_pair_list_grow): New. * data/c.m4 (b4_c_function_call, b4_c_args): New. * data/yacc.c (YYLEX): Use b4_c_function_call to honor %lex-param. * tests/calc.at: Use %locations, not --locations. (AT_CHECK_CALC_GLR): Use %glr-parser, not %glr_parser.
This commit is contained in:
24
ChangeLog
24
ChangeLog
@@ -1,3 +1,27 @@
|
||||
2002-10-19 Akim Demaille <akim@epita.fr>
|
||||
|
||||
Prototype support of %lex-param and %parse-param.
|
||||
|
||||
* src/parse-gram.y: Add the definition of the %lex-param and
|
||||
%parse-param tokens, plus their rules.
|
||||
Drop the `_' version of %glr-parser.
|
||||
Add the "," token.
|
||||
* src/scan-gram.l (INITIAL): Scan them.
|
||||
* src/muscle_tab.c: Comment changes.
|
||||
(muscle_insert, muscle_find): Rename `pair' as `probe'.
|
||||
* src/muscle_tab.h (MUSCLE_INSERT_PREFIX): Remove unused.
|
||||
(muscle_entry_s): The `value' member is no longer const.
|
||||
Adjust all dependencies.
|
||||
* src/muscle_tab.c (muscle_init): Adjust: use
|
||||
MUSCLE_INSERT_STRING.
|
||||
Initialize the obstack earlier.
|
||||
* src/muscle_tab.h, src/muscle_tab.c (muscle_grow)
|
||||
(muscle_pair_list_grow): New.
|
||||
* data/c.m4 (b4_c_function_call, b4_c_args): New.
|
||||
* data/yacc.c (YYLEX): Use b4_c_function_call to honor %lex-param.
|
||||
* tests/calc.at: Use %locations, not --locations.
|
||||
(AT_CHECK_CALC_GLR): Use %glr-parser, not %glr_parser.
|
||||
|
||||
2002-10-19 Akim Demaille <akim@epita.fr>
|
||||
|
||||
* src/getargs.c (usage): Take status as argument and exit
|
||||
|
||||
12
TODO
12
TODO
@@ -5,6 +5,18 @@
|
||||
From Franc,ois: should we keep the directory part in the CPP guard?
|
||||
|
||||
|
||||
* readpipe
|
||||
|
||||
It should be replaced to avoid tmp files and to improve portability.
|
||||
Also, as it is it does not call error () when execve fails, and
|
||||
therefore, running M4='m4 --version' bison will silently fail instead
|
||||
of:
|
||||
|
||||
bison: cannot run m4 --version: No such file or directory
|
||||
|
||||
BTW: I would really like to be able to pass arguments to m4...
|
||||
|
||||
|
||||
* URGENT: Documenting C++ output
|
||||
Write a first documentation for C++ output.
|
||||
|
||||
|
||||
27
data/c.m4
27
data/c.m4
@@ -1,4 +1,4 @@
|
||||
m4_divert(-1) -*- C -*-
|
||||
m4_divert(-1) *- Autoconf -*-
|
||||
|
||||
# C M4 Macros for Bison.
|
||||
# Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
@@ -122,13 +122,36 @@ m4_map([b4_token_define], [$@])
|
||||
])
|
||||
|
||||
|
||||
## --------------------- ##
|
||||
## Calling C functions. ##
|
||||
## --------------------- ##
|
||||
|
||||
|
||||
# b4_c_function_call(NAME, RETURN-VALUE, [TYPE1, NAME1], ...)
|
||||
# -----------------------------------------------------------
|
||||
# Call the function NAME with arguments NAME1, NAME2 etc.
|
||||
m4_define([b4_c_function_call],
|
||||
[$1 (b4_c_args(m4_shiftn(2, $@)))[]dnl
|
||||
])
|
||||
|
||||
|
||||
# b4_c_args([TYPE1, NAME1], ...)
|
||||
# ------------------------------
|
||||
# Output the arguments NAME1, NAME2...
|
||||
m4_define([b4_c_args],
|
||||
[m4_map_sep([b4_c_arg], [, ], [$@])])
|
||||
|
||||
m4_define([b4_c_arg],
|
||||
[$2])
|
||||
|
||||
|
||||
## ---------------------------------------------- ##
|
||||
## Declaring C functions in both K&R and ANSI-C. ##
|
||||
## ---------------------------------------------- ##
|
||||
|
||||
|
||||
# b4_c_function(NAME, RETURN-VALUE, [TYPE1, NAME1], ...)
|
||||
# ------------------------------------------------
|
||||
# ------------------------------------------------------
|
||||
# Declare the function NAME.
|
||||
m4_define([b4_c_function],
|
||||
[$2
|
||||
|
||||
13
data/yacc.c
13
data/yacc.c
@@ -506,13 +506,14 @@ while (0)
|
||||
|
||||
/* YYLEX -- calling `yylex' with the right arguments. */
|
||||
|
||||
b4_pure_if(
|
||||
[#ifdef YYLEX_PARAM
|
||||
# define YYLEX yylex (&yylval[]b4_location_if([, &yylloc]), YYLEX_PARAM)
|
||||
#ifdef YYLEX_PARAM
|
||||
# define YYLEX yylex (b4_pure_if([&yylval[]b4_location_if([, &yylloc]), ])YYLEX_PARAM)
|
||||
#else
|
||||
# define YYLEX yylex (&yylval[]b4_location_if([, &yylloc]))
|
||||
#endif],
|
||||
[#define YYLEX yylex ()])
|
||||
# define YYLEX b4_c_function_call([yylex],
|
||||
b4_pure_if([[[[]], [[&yylval]]],
|
||||
b4_location_if([[[], [&yylloc]],])])
|
||||
m4_fst(b4_lex_param))
|
||||
#endif
|
||||
|
||||
/* Enable debugging if requested. */
|
||||
#if YYDEBUG
|
||||
|
||||
120
src/muscle_tab.c
120
src/muscle_tab.c
@@ -1,4 +1,4 @@
|
||||
/* Macro table manager for Bison,
|
||||
/* Muscle table manager for Bison,
|
||||
Copyright (C) 2001, 2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of Bison, the GNU Compiler Compiler.
|
||||
@@ -56,31 +56,31 @@ hash_muscle (const void *x, unsigned int tablesize)
|
||||
void
|
||||
muscle_init (void)
|
||||
{
|
||||
/* Initialize the muscle obstack. */
|
||||
obstack_init (&muscle_obstack);
|
||||
|
||||
muscle_table = hash_initialize (HT_INITIAL_CAPACITY, NULL, hash_muscle,
|
||||
hash_compare_muscles, free);
|
||||
|
||||
/* Version and input file. */
|
||||
muscle_insert ("version", VERSION);
|
||||
muscle_insert ("filename", infile);
|
||||
MUSCLE_INSERT_STRING ("version", VERSION);
|
||||
MUSCLE_INSERT_STRING ("filename", infile);
|
||||
|
||||
/* FIXME: there should probably be no default here, only in the
|
||||
skeletons. */
|
||||
|
||||
/* Types. */
|
||||
muscle_insert ("ltype", "yyltype");
|
||||
MUSCLE_INSERT_STRING ("ltype", "yyltype");
|
||||
|
||||
/* Default #line formatting. */
|
||||
muscle_insert ("linef", "#line %d %s\n");
|
||||
MUSCLE_INSERT_STRING ("linef", "#line %d %s\n");
|
||||
|
||||
/* Stack parameters. */
|
||||
muscle_insert ("maxdepth", "10000");
|
||||
muscle_insert ("initdepth", "200");
|
||||
MUSCLE_INSERT_STRING ("maxdepth", "10000");
|
||||
MUSCLE_INSERT_STRING ("initdepth", "200");
|
||||
|
||||
/* C++ macros. */
|
||||
muscle_insert ("name", "Parser");
|
||||
|
||||
/* Initialize the muscle obstack. */
|
||||
obstack_init (&muscle_obstack);
|
||||
MUSCLE_INSERT_STRING ("name", "Parser");
|
||||
}
|
||||
|
||||
|
||||
@@ -97,14 +97,19 @@ muscle_free (void)
|
||||
|
||||
|
||||
|
||||
/*------------------------------------------------------------.
|
||||
| Insert (KEY, VALUE). If KEY already existed, overwrite the |
|
||||
| previous value. |
|
||||
`------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
muscle_insert (const char *key, const char *value)
|
||||
muscle_insert (const char *key, char *value)
|
||||
{
|
||||
muscle_entry_t pair;
|
||||
muscle_entry_t probe;
|
||||
muscle_entry_t *entry = NULL;
|
||||
|
||||
pair.key = key;
|
||||
entry = hash_lookup (muscle_table, &pair);
|
||||
probe.key = key;
|
||||
entry = hash_lookup (muscle_table, &probe);
|
||||
|
||||
if (!entry)
|
||||
{
|
||||
@@ -116,32 +121,99 @@ muscle_insert (const char *key, const char *value)
|
||||
entry->value = value;
|
||||
}
|
||||
|
||||
const char*
|
||||
|
||||
/*-------------------------------------------------------------------.
|
||||
| Insert (KEY, VALUE). If KEY already existed, overwrite the |
|
||||
| previous value. Uses MUSCLE_OBSTACK. De-allocates the previously |
|
||||
| associated value. VALUE and SEPARATOR are copied. |
|
||||
`-------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
muscle_grow (const char *key, const char *val, const char *separator)
|
||||
{
|
||||
muscle_entry_t probe;
|
||||
muscle_entry_t *entry = NULL;
|
||||
|
||||
probe.key = key;
|
||||
entry = hash_lookup (muscle_table, &probe);
|
||||
|
||||
if (!entry)
|
||||
{
|
||||
/* First insertion in the hash. */
|
||||
entry = XMALLOC (muscle_entry_t, 1);
|
||||
entry->key = key;
|
||||
hash_insert (muscle_table, entry);
|
||||
entry->value = xstrdup (val);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Grow the current value. */
|
||||
char *new_val;
|
||||
fprintf (stderr, "<= %s + %s\n", entry->value, val);
|
||||
obstack_sgrow (&muscle_obstack, entry->value);
|
||||
free (entry->value);
|
||||
obstack_sgrow (&muscle_obstack, separator);
|
||||
obstack_sgrow (&muscle_obstack, val);
|
||||
obstack_1grow (&muscle_obstack, 0);
|
||||
new_val = obstack_finish (&muscle_obstack);
|
||||
entry->value = xstrdup (new_val);
|
||||
fprintf (stderr, "=> %s\n", new_val);
|
||||
obstack_free (&muscle_obstack, new_val);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------.
|
||||
| MUSCLE is an M4 list of pairs. Create or extend it with the pair |
|
||||
| (A1, A2). Note that because the muscle values are output *double* |
|
||||
| quoted, one needs to strip the first level of quotes to reach the |
|
||||
| list itself. |
|
||||
`-------------------------------------------------------------------*/
|
||||
|
||||
void muscle_pair_list_grow (const char *muscle,
|
||||
const char *a1, const char *a2)
|
||||
{
|
||||
char *value;
|
||||
obstack_fgrow2 (&muscle_obstack, "[[[%s]], [[%s]]]", a1, a2);
|
||||
obstack_1grow (&muscle_obstack, 0);
|
||||
value = obstack_finish (&muscle_obstack);
|
||||
muscle_grow (muscle, value, ",\n");
|
||||
obstack_free (&muscle_obstack, value);
|
||||
}
|
||||
|
||||
/*-------------------------------.
|
||||
| Find the value of muscle KEY. |
|
||||
`-------------------------------*/
|
||||
|
||||
char*
|
||||
muscle_find (const char *key)
|
||||
{
|
||||
muscle_entry_t pair;
|
||||
muscle_entry_t probe;
|
||||
muscle_entry_t *result = NULL;
|
||||
|
||||
pair.key = key;
|
||||
result = hash_lookup (muscle_table, &pair);
|
||||
probe.key = key;
|
||||
result = hash_lookup (muscle_table, &probe);
|
||||
return result ? result->value : NULL;
|
||||
}
|
||||
|
||||
|
||||
/* Output the definition of all the current muscles into a list of
|
||||
m4_defines. */
|
||||
/*------------------------------------------------.
|
||||
| Output the definition of ENTRY as a m4_define. |
|
||||
`------------------------------------------------*/
|
||||
|
||||
static int
|
||||
muscle_m4_output (muscle_entry_t *entry, FILE *out)
|
||||
{
|
||||
fprintf (out, "m4_define([b4_%s],\n", entry->key);
|
||||
fprintf (out, " [[%s]])\n\n\n", entry->value);
|
||||
fprintf (out, "[[%s]])\n\n\n", entry->value);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* Output the definition of all the current muscles into a list of
|
||||
m4_defines. */
|
||||
/*----------------------------------------------------------------.
|
||||
| Output the definition of all the current muscles into a list of |
|
||||
| m4_defines. |
|
||||
`----------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
muscles_m4_output (FILE *out)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Definitions for macrotab.c and callers, part of bison,
|
||||
/* Muscle table manager for Bison,
|
||||
Copyright (C) 2001, 2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of Bison, the GNU Compiler Compiler.
|
||||
@@ -21,17 +21,15 @@
|
||||
#ifndef MUSCLE_TAB_H_
|
||||
# define MUSCLE_TAB_H_
|
||||
|
||||
# define MTABSIZE 101
|
||||
|
||||
typedef struct muscle_entry_s
|
||||
{
|
||||
const char *key;
|
||||
const char *value;
|
||||
char *value;
|
||||
} muscle_entry_t;
|
||||
|
||||
void muscle_init PARAMS ((void));
|
||||
void muscle_insert PARAMS ((const char *key, const char *value));
|
||||
const char *muscle_find PARAMS ((const char *key));
|
||||
void muscle_insert PARAMS ((const char *key, char *value));
|
||||
char *muscle_find PARAMS ((const char *key));
|
||||
void muscle_free PARAMS ((void));
|
||||
|
||||
|
||||
@@ -59,14 +57,27 @@ extern struct obstack muscle_obstack;
|
||||
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
||||
}
|
||||
|
||||
#define MUSCLE_INSERT_PREFIX(Key, Value) \
|
||||
{ \
|
||||
obstack_fgrow2 (&muscle_obstack, "%s%s", \
|
||||
spec_name_prefix ? spec_name_prefix : "yy", Value); \
|
||||
obstack_1grow (&muscle_obstack, 0); \
|
||||
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
||||
#define MUSCLE_GROW_STRING_PAIR(Key, Value1, Value2) \
|
||||
{ \
|
||||
obstack_sgrow (&muscle_obstack, Value1); \
|
||||
obstack_1grow (&muscle_obstack, 0); \
|
||||
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
||||
}
|
||||
|
||||
/* Insert (KEY, VALUE). If KEY already existed, overwrite the
|
||||
previous value. Uses MUSCLE_OBSTACK. De-allocates the previously
|
||||
associated value. VALUE and SEPARATOR are copied. */
|
||||
|
||||
void muscle_grow PARAMS ((const char *key,
|
||||
const char *value, const char *separator));
|
||||
|
||||
/* MUSCLE is an M4 list of pairs. Create or extend it with the pair
|
||||
(A1, A2). Note that because the muscle values are output *double*
|
||||
quoted, one needs to strip the first level of quotes to reach the
|
||||
list itself. */
|
||||
|
||||
void muscle_pair_list_grow PARAMS ((const char *muscle,
|
||||
const char *a1, const char *a2));
|
||||
|
||||
void muscles_m4_output PARAMS ((FILE *out));
|
||||
|
||||
|
||||
20
src/output.c
20
src/output.c
@@ -355,9 +355,9 @@ merger_output (FILE *out)
|
||||
fputs ("]])\n\n", out);
|
||||
}
|
||||
|
||||
/*---------------------------------------.
|
||||
| Output the tokens definition to OOUT. |
|
||||
`---------------------------------------*/
|
||||
/*--------------------------------------.
|
||||
| Output the tokens definition to OUT. |
|
||||
`--------------------------------------*/
|
||||
|
||||
static void
|
||||
token_definitions_output (FILE *out)
|
||||
@@ -405,9 +405,9 @@ token_definitions_output (FILE *out)
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------.
|
||||
| Output the symbol destructors to OOUT. |
|
||||
`----------------------------------------*/
|
||||
/*---------------------------------------.
|
||||
| Output the symbol destructors to OUT. |
|
||||
`---------------------------------------*/
|
||||
|
||||
static void
|
||||
symbol_destructors_output (FILE *out)
|
||||
@@ -438,9 +438,9 @@ symbol_destructors_output (FILE *out)
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------.
|
||||
| Output the symbol printers to OOUT. |
|
||||
`-------------------------------------*/
|
||||
/*------------------------------------.
|
||||
| Output the symbol printers to OUT. |
|
||||
`------------------------------------*/
|
||||
|
||||
static void
|
||||
symbol_printers_output (FILE *out)
|
||||
@@ -456,7 +456,7 @@ symbol_printers_output (FILE *out)
|
||||
|
||||
/* Filename, lineno,
|
||||
Symbol-name, Symbol-number,
|
||||
destructor, typename. */
|
||||
printer, typename. */
|
||||
fprintf (out, "%s[[[%s]], [[%d]], [[%s]], [[%d]], [[%s]], [[%s]]]",
|
||||
first ? "" : ",\n",
|
||||
infile, symbol->printer_location.first_line,
|
||||
|
||||
965
src/parse-gram.c
965
src/parse-gram.c
File diff suppressed because it is too large
Load Diff
127
src/parse-gram.h
127
src/parse-gram.h
@@ -1,4 +1,4 @@
|
||||
/* A Bison parser, made from parse-gram.y, by GNU bison 1.49c. */
|
||||
/* A Bison parser, made from parse-gram.y, by GNU bison 1.75a. */
|
||||
|
||||
/* Skeleton parser for Yacc-like parsing with Bison,
|
||||
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc.
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
/* Tokens. */
|
||||
#ifndef YYTOKENTYPE
|
||||
# if defined (__STDC__) || defined (__cplusplus)
|
||||
# define YYTOKENTYPE
|
||||
/* Put the tokens into the symbol table, so that GDB and other debuggers
|
||||
know about them. */
|
||||
enum yytokentype {
|
||||
@@ -45,41 +45,41 @@
|
||||
PERCENT_LEFT = 267,
|
||||
PERCENT_RIGHT = 268,
|
||||
PERCENT_NONASSOC = 269,
|
||||
PERCENT_EXPECT = 270,
|
||||
PERCENT_START = 271,
|
||||
PERCENT_PREC = 272,
|
||||
PERCENT_DPREC = 273,
|
||||
PERCENT_MERGE = 274,
|
||||
PERCENT_VERBOSE = 275,
|
||||
PERCENT_PREC = 270,
|
||||
PERCENT_DPREC = 271,
|
||||
PERCENT_MERGE = 272,
|
||||
PERCENT_DEBUG = 273,
|
||||
PERCENT_DEFINE = 274,
|
||||
PERCENT_DEFINES = 275,
|
||||
PERCENT_ERROR_VERBOSE = 276,
|
||||
PERCENT_OUTPUT = 277,
|
||||
PERCENT_EXPECT = 277,
|
||||
PERCENT_FILE_PREFIX = 278,
|
||||
PERCENT_NAME_PREFIX = 279,
|
||||
PERCENT_DEFINE = 280,
|
||||
PERCENT_PURE_PARSER = 281,
|
||||
PERCENT_GLR_PARSER = 282,
|
||||
PERCENT_DEFINES = 283,
|
||||
PERCENT_YACC = 284,
|
||||
PERCENT_DEBUG = 285,
|
||||
PERCENT_LOCATIONS = 286,
|
||||
PERCENT_NO_LINES = 287,
|
||||
PERCENT_SKELETON = 288,
|
||||
PERCENT_GLR_PARSER = 279,
|
||||
PERCENT_LEX_PARAM = 280,
|
||||
PERCENT_LOCATIONS = 281,
|
||||
PERCENT_NAME_PREFIX = 282,
|
||||
PERCENT_NO_LINES = 283,
|
||||
PERCENT_OUTPUT = 284,
|
||||
PERCENT_PARSE_PARAM = 285,
|
||||
PERCENT_PURE_PARSER = 286,
|
||||
PERCENT_SKELETON = 287,
|
||||
PERCENT_START = 288,
|
||||
PERCENT_TOKEN_TABLE = 289,
|
||||
TYPE = 290,
|
||||
EQUAL = 291,
|
||||
SEMICOLON = 292,
|
||||
COLON = 293,
|
||||
PIPE = 294,
|
||||
ID = 295,
|
||||
PERCENT_PERCENT = 296,
|
||||
PROLOGUE = 297,
|
||||
EPILOGUE = 298,
|
||||
BRACED_CODE = 299
|
||||
PERCENT_VERBOSE = 290,
|
||||
PERCENT_YACC = 291,
|
||||
TYPE = 292,
|
||||
EQUAL = 293,
|
||||
SEMICOLON = 294,
|
||||
COLON = 295,
|
||||
COMMA = 296,
|
||||
PIPE = 297,
|
||||
ID = 298,
|
||||
PERCENT_PERCENT = 299,
|
||||
PROLOGUE = 300,
|
||||
EPILOGUE = 301,
|
||||
BRACED_CODE = 302
|
||||
};
|
||||
# endif
|
||||
/* POSIX requires `int' for tokens in interfaces. */
|
||||
# define YYTOKENTYPE int
|
||||
#endif /* !YYTOKENTYPE */
|
||||
#endif
|
||||
#define GRAM_EOF 0
|
||||
#define STRING 258
|
||||
#define CHARACTER 259
|
||||
@@ -93,36 +93,39 @@
|
||||
#define PERCENT_LEFT 267
|
||||
#define PERCENT_RIGHT 268
|
||||
#define PERCENT_NONASSOC 269
|
||||
#define PERCENT_EXPECT 270
|
||||
#define PERCENT_START 271
|
||||
#define PERCENT_PREC 272
|
||||
#define PERCENT_DPREC 273
|
||||
#define PERCENT_MERGE 274
|
||||
#define PERCENT_VERBOSE 275
|
||||
#define PERCENT_PREC 270
|
||||
#define PERCENT_DPREC 271
|
||||
#define PERCENT_MERGE 272
|
||||
#define PERCENT_DEBUG 273
|
||||
#define PERCENT_DEFINE 274
|
||||
#define PERCENT_DEFINES 275
|
||||
#define PERCENT_ERROR_VERBOSE 276
|
||||
#define PERCENT_OUTPUT 277
|
||||
#define PERCENT_EXPECT 277
|
||||
#define PERCENT_FILE_PREFIX 278
|
||||
#define PERCENT_NAME_PREFIX 279
|
||||
#define PERCENT_DEFINE 280
|
||||
#define PERCENT_PURE_PARSER 281
|
||||
#define PERCENT_GLR_PARSER 282
|
||||
#define PERCENT_DEFINES 283
|
||||
#define PERCENT_YACC 284
|
||||
#define PERCENT_DEBUG 285
|
||||
#define PERCENT_LOCATIONS 286
|
||||
#define PERCENT_NO_LINES 287
|
||||
#define PERCENT_SKELETON 288
|
||||
#define PERCENT_GLR_PARSER 279
|
||||
#define PERCENT_LEX_PARAM 280
|
||||
#define PERCENT_LOCATIONS 281
|
||||
#define PERCENT_NAME_PREFIX 282
|
||||
#define PERCENT_NO_LINES 283
|
||||
#define PERCENT_OUTPUT 284
|
||||
#define PERCENT_PARSE_PARAM 285
|
||||
#define PERCENT_PURE_PARSER 286
|
||||
#define PERCENT_SKELETON 287
|
||||
#define PERCENT_START 288
|
||||
#define PERCENT_TOKEN_TABLE 289
|
||||
#define TYPE 290
|
||||
#define EQUAL 291
|
||||
#define SEMICOLON 292
|
||||
#define COLON 293
|
||||
#define PIPE 294
|
||||
#define ID 295
|
||||
#define PERCENT_PERCENT 296
|
||||
#define PROLOGUE 297
|
||||
#define EPILOGUE 298
|
||||
#define BRACED_CODE 299
|
||||
#define PERCENT_VERBOSE 290
|
||||
#define PERCENT_YACC 291
|
||||
#define TYPE 292
|
||||
#define EQUAL 293
|
||||
#define SEMICOLON 294
|
||||
#define COLON 295
|
||||
#define COMMA 296
|
||||
#define PIPE 297
|
||||
#define ID 298
|
||||
#define PERCENT_PERCENT 299
|
||||
#define PROLOGUE 300
|
||||
#define EPILOGUE 301
|
||||
#define BRACED_CODE 302
|
||||
|
||||
|
||||
|
||||
@@ -136,8 +139,8 @@ typedef union {
|
||||
char *string;
|
||||
assoc_t assoc;
|
||||
} yystype;
|
||||
/* Line 1294 of /usr/local/share/bison/yacc.c. */
|
||||
#line 141 "y.tab.h"
|
||||
/* Line 1281 of /usr/local/share/bison/yacc.c. */
|
||||
#line 144 "y.tab.h"
|
||||
# define YYSTYPE yystype
|
||||
#endif
|
||||
|
||||
|
||||
@@ -113,36 +113,42 @@ braced_code_t current_braced_code = action_braced_code;
|
||||
%token PERCENT_RIGHT "%right"
|
||||
%token PERCENT_NONASSOC "%nonassoc"
|
||||
|
||||
%token PERCENT_EXPECT "%expect"
|
||||
%token PERCENT_START "%start"
|
||||
%token PERCENT_PREC "%prec"
|
||||
%token PERCENT_DPREC "%dprec"
|
||||
%token PERCENT_MERGE "%merge"
|
||||
%token PERCENT_VERBOSE "%verbose"
|
||||
%token PERCENT_ERROR_VERBOSE "%error-verbose"
|
||||
|
||||
%token PERCENT_OUTPUT "%output"
|
||||
%token PERCENT_FILE_PREFIX "%file-prefix"
|
||||
%token PERCENT_NAME_PREFIX "%name-prefix"
|
||||
|
||||
%token PERCENT_DEFINE "%define"
|
||||
%token PERCENT_PURE_PARSER "%pure-parser"
|
||||
%token PERCENT_GLR_PARSER "%glr-parser"
|
||||
/*----------------------.
|
||||
| Global Declarations. |
|
||||
`----------------------*/
|
||||
|
||||
%token PERCENT_DEFINES "%defines"
|
||||
|
||||
%token PERCENT_YACC "%yacc"
|
||||
|
||||
%token PERCENT_DEBUG "%debug"
|
||||
%token PERCENT_LOCATIONS "%locations"
|
||||
%token PERCENT_NO_LINES "%no-lines"
|
||||
%token PERCENT_SKELETON "%skeleton"
|
||||
%token PERCENT_TOKEN_TABLE "%token-table"
|
||||
%token
|
||||
PERCENT_DEBUG "%debug"
|
||||
PERCENT_DEFINE "%define"
|
||||
PERCENT_DEFINES "%defines"
|
||||
PERCENT_ERROR_VERBOSE "%error-verbose"
|
||||
PERCENT_EXPECT "%expect"
|
||||
PERCENT_FILE_PREFIX "%file-prefix"
|
||||
PERCENT_GLR_PARSER "%glr-parser"
|
||||
PERCENT_LEX_PARAM "%lex-param"
|
||||
PERCENT_LOCATIONS "%locations"
|
||||
PERCENT_NAME_PREFIX "%name-prefix"
|
||||
PERCENT_NO_LINES "%no-lines"
|
||||
PERCENT_OUTPUT "%output"
|
||||
PERCENT_PARSE_PARAM "%parse-param"
|
||||
PERCENT_PURE_PARSER "%pure-parser"
|
||||
PERCENT_SKELETON "%skeleton"
|
||||
PERCENT_START "%start"
|
||||
PERCENT_TOKEN_TABLE "%token-table"
|
||||
PERCENT_VERBOSE "%verbose"
|
||||
PERCENT_YACC "%yacc"
|
||||
;
|
||||
|
||||
%token TYPE "type"
|
||||
%token EQUAL "="
|
||||
%token SEMICOLON ";"
|
||||
%token COLON ":"
|
||||
%token COMMA ","
|
||||
%token PIPE "|"
|
||||
%token ID "identifier"
|
||||
%token PERCENT_PERCENT "%%"
|
||||
@@ -186,12 +192,16 @@ declaration:
|
||||
| "%error-verbose" { error_verbose = 1; }
|
||||
| "%expect" INT { expected_conflicts = $2; }
|
||||
| "%file-prefix" "=" string_content { spec_file_prefix = $3; }
|
||||
| "%glr-parser" { glr_parser = 1; }
|
||||
| "%lex-param" string_content "," string_content
|
||||
{ muscle_pair_list_grow ("lex_param", $2, $4); }
|
||||
| "%locations" { locations_flag = 1; }
|
||||
| "%name-prefix" "=" string_content { spec_name_prefix = $3; }
|
||||
| "%no-lines" { no_lines_flag = 1; }
|
||||
| "%output" "=" string_content { spec_outfile = $3; }
|
||||
| "%parse-param" string_content "," string_content
|
||||
{ muscle_pair_list_grow ("parse_param", $2, $4); }
|
||||
| "%pure-parser" { pure_parser = 1; }
|
||||
| "%glr-parser" { glr_parser = 1; }
|
||||
| "%skeleton" string_content { skeleton = $2; }
|
||||
| "%token-table" { token_table_flag = 1; }
|
||||
| "%verbose" { report_flag = 1; }
|
||||
|
||||
1044
src/scan-gram.c
1044
src/scan-gram.c
File diff suppressed because it is too large
Load Diff
@@ -126,7 +126,7 @@ blanks [ \t\f]+
|
||||
"%expect" return PERCENT_EXPECT;
|
||||
"%file-prefix" return PERCENT_FILE_PREFIX;
|
||||
"%fixed"[-_]"output"[-_]"files" return PERCENT_YACC;
|
||||
"%glr"[-_]"parser" return PERCENT_GLR_PARSER;
|
||||
"%glr-parser" return PERCENT_GLR_PARSER;
|
||||
"%left" return PERCENT_LEFT;
|
||||
"%locations" return PERCENT_LOCATIONS;
|
||||
"%merge" return PERCENT_MERGE;
|
||||
@@ -135,10 +135,12 @@ blanks [ \t\f]+
|
||||
"%nonassoc" return PERCENT_NONASSOC;
|
||||
"%nterm" return PERCENT_NTERM;
|
||||
"%output" return PERCENT_OUTPUT;
|
||||
"%parse-param" return PERCENT_PARSE_PARAM;
|
||||
"%prec" { rule_length--; return PERCENT_PREC; }
|
||||
"%printer" return PERCENT_PRINTER;
|
||||
"%pure"[-_]"parser" return PERCENT_PURE_PARSER;
|
||||
"%right" return PERCENT_RIGHT;
|
||||
"%lex-param" return PERCENT_LEX_PARAM;
|
||||
"%skeleton" return PERCENT_SKELETON;
|
||||
"%start" return PERCENT_START;
|
||||
"%term" return PERCENT_TOKEN;
|
||||
@@ -152,6 +154,7 @@ blanks [ \t\f]+
|
||||
"=" return EQUAL;
|
||||
":" { rule_length = 0; return COLON; }
|
||||
"|" { rule_length = 0; return PIPE; }
|
||||
"," return COMMA;
|
||||
";" return SEMICOLON;
|
||||
|
||||
{eols} YY_LINES; YY_STEP;
|
||||
|
||||
@@ -354,7 +354,7 @@ AT_DATA([[expout]],
|
||||
[$4
|
||||
])
|
||||
# 3. If locations are not used, remove them.
|
||||
m4_bmatch([$1], [--location], [],
|
||||
m4_bmatch([$1], [%locations], [],
|
||||
[[sed 's/^[-0-9.]*: //' expout >at-expout
|
||||
mv at-expout expout]])
|
||||
# 4. If error-verbose is not used, strip the`, unexpected....' part.
|
||||
@@ -451,18 +451,18 @@ m4_define([AT_CHECK_CALC_LALR],
|
||||
AT_CHECK_CALC_LALR()
|
||||
|
||||
AT_CHECK_CALC_LALR([--defines])
|
||||
AT_CHECK_CALC_LALR([--locations])
|
||||
AT_CHECK_CALC_LALR([%locations])
|
||||
AT_CHECK_CALC_LALR([--name-prefix=calc])
|
||||
AT_CHECK_CALC_LALR([--verbose])
|
||||
AT_CHECK_CALC_LALR([--yacc])
|
||||
AT_CHECK_CALC_LALR([%error-verbose])
|
||||
|
||||
AT_CHECK_CALC_LALR([%error-verbose --locations])
|
||||
AT_CHECK_CALC_LALR([%error-verbose %locations])
|
||||
|
||||
AT_CHECK_CALC_LALR([%error-verbose --defines --locations --name-prefix=calc --verbose --yacc])
|
||||
AT_CHECK_CALC_LALR([%error-verbose --defines %locations --name-prefix=calc --verbose --yacc])
|
||||
|
||||
AT_CHECK_CALC_LALR([%debug])
|
||||
AT_CHECK_CALC_LALR([%error-verbose %debug --defines --locations --name-prefix=calc --verbose --yacc])
|
||||
AT_CHECK_CALC_LALR([%error-verbose %debug --defines %locations --name-prefix=calc --verbose --yacc])
|
||||
|
||||
|
||||
# ----------------------- #
|
||||
@@ -476,21 +476,21 @@ AT_BANNER([[Simple GLR Calculator.]])
|
||||
# Start a testing chunk which compiles `calc' grammar with
|
||||
# BISON-OPTIONS and %glr-parser, and performs several tests over the parser.
|
||||
m4_define([AT_CHECK_CALC_GLR],
|
||||
[AT_CHECK_CALC([%glr_parser] $@)])
|
||||
[AT_CHECK_CALC([%glr-parser] $@)])
|
||||
|
||||
|
||||
AT_CHECK_CALC_GLR()
|
||||
|
||||
AT_CHECK_CALC_GLR([--defines])
|
||||
AT_CHECK_CALC_GLR([--locations])
|
||||
AT_CHECK_CALC_GLR([%locations])
|
||||
AT_CHECK_CALC_GLR([--name-prefix=calc])
|
||||
AT_CHECK_CALC_GLR([--verbose])
|
||||
AT_CHECK_CALC_GLR([--yacc])
|
||||
AT_CHECK_CALC_GLR([%error-verbose])
|
||||
|
||||
AT_CHECK_CALC_GLR([%error-verbose --locations])
|
||||
AT_CHECK_CALC_GLR([%error-verbose %locations])
|
||||
|
||||
AT_CHECK_CALC_GLR([%error-verbose --defines --locations --name-prefix=calc --verbose --yacc])
|
||||
AT_CHECK_CALC_GLR([%error-verbose --defines %locations --name-prefix=calc --verbose --yacc])
|
||||
|
||||
AT_CHECK_CALC_GLR([%debug])
|
||||
AT_CHECK_CALC_GLR([%error-verbose %debug --defines --locations --name-prefix=calc --verbose --yacc])
|
||||
AT_CHECK_CALC_GLR([%error-verbose %debug --defines %locations --name-prefix=calc --verbose --yacc])
|
||||
|
||||
Reference in New Issue
Block a user