mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-20 09:43:03 +00:00
* NEWS: Reword %destructor vs YYABORT etc.
* data/glr.c: Use American spacing, for consistency. * data/glr.cc: Likewise. * data/lalr1.cc: Likewise. * data/yacc.c: Likewise. * data/yacc.c: Reformat comments slightly. * doc/bison.texinfo: Replace "non-" with "non" when that makes sense, for consistency. Fix some spelling errors and reword recently-included text slightly. * tests/cxx-type.at: Cast results of malloc, for C++.
This commit is contained in:
13
ChangeLog
13
ChangeLog
@@ -1,3 +1,16 @@
|
|||||||
|
2005-12-21 Paul Eggert <eggert@cs.ucla.edu>
|
||||||
|
|
||||||
|
* NEWS: Reword %destructor vs YYABORT etc.
|
||||||
|
* data/glr.c: Use American spacing, for consistency.
|
||||||
|
* data/glr.cc: Likewise.
|
||||||
|
* data/lalr1.cc: Likewise.
|
||||||
|
* data/yacc.c: Likewise.
|
||||||
|
* data/yacc.c: Reformat comments slightly.
|
||||||
|
* doc/bison.texinfo: Replace "non-" with "non" when that makes sense,
|
||||||
|
for consistency. Fix some spelling errors and reword recently-included
|
||||||
|
text slightly.
|
||||||
|
* tests/cxx-type.at: Cast results of malloc, for C++.
|
||||||
|
|
||||||
2005-12-21 Joel E. Denny <address@hidden>
|
2005-12-21 Joel E. Denny <address@hidden>
|
||||||
|
|
||||||
* tests/cxx-type.at: Construct a tree, count the parents of shared
|
* tests/cxx-type.at: Construct a tree, count the parents of shared
|
||||||
|
|||||||
8
NEWS
8
NEWS
@@ -3,10 +3,10 @@ Bison News
|
|||||||
|
|
||||||
Changes in version 2.1a:
|
Changes in version 2.1a:
|
||||||
|
|
||||||
* %destructor vs. YYACCEPT, YYERROR, and YYABORT.
|
* %destructor vs. YYABORT, YYACCEPT, and YYERROR.
|
||||||
When the parsing/action is cut by the user using one of these
|
Destructors are now called when user code invokes YYABORT, YYACCEPT,
|
||||||
special actions, the stack is freed except the right-hand side
|
and YYERROR, for all objects on the stack, other than objects
|
||||||
symbols of the current rule.
|
corresponding to the right-hand side of the current rule.
|
||||||
|
|
||||||
* GLR, C++ LALR(1) parsers.
|
* GLR, C++ LALR(1) parsers.
|
||||||
These parser skeletons are now distributed with the same special
|
These parser skeletons are now distributed with the same special
|
||||||
|
|||||||
116
data/glr.c
116
data/glr.c
@@ -151,7 +151,7 @@ m4_divert(0)dnl
|
|||||||
b4_copyright([Skeleton parser for GLR parsing with Bison],
|
b4_copyright([Skeleton parser for GLR parsing with Bison],
|
||||||
[2002, 2003, 2004, 2005])
|
[2002, 2003, 2004, 2005])
|
||||||
[
|
[
|
||||||
/* This is the parser code for GLR (Generalized LR) parser. */
|
/* This is the parser code for GLR (Generalized LR) parser. */
|
||||||
|
|
||||||
]b4_identification
|
]b4_identification
|
||||||
|
|
||||||
@@ -230,7 +230,7 @@ m4_if(b4_defines_flag, 0,
|
|||||||
right-hand sides. Unlike the standard yacc.c template,
|
right-hand sides. Unlike the standard yacc.c template,
|
||||||
here we set the default value of $$ to a zeroed-out value.
|
here we set the default value of $$ to a zeroed-out value.
|
||||||
Since the default value is undefined, this behavior is
|
Since the default value is undefined, this behavior is
|
||||||
technically correct. */
|
technically correct. */
|
||||||
static YYSTYPE yyval_default;
|
static YYSTYPE yyval_default;
|
||||||
|
|
||||||
/* Copy the second part of user declarations. */
|
/* Copy the second part of user declarations. */
|
||||||
@@ -323,23 +323,23 @@ b4_syncline([@oline@], [@ofile@])
|
|||||||
# define YYASSERT(condition) ((void) ((condition) || (abort (), 0)))
|
# define YYASSERT(condition) ((void) ((condition) || (abort (), 0)))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* YYFINAL -- State number of the termination state. */
|
/* YYFINAL -- State number of the termination state. */
|
||||||
#define YYFINAL ]b4_final_state_number[
|
#define YYFINAL ]b4_final_state_number[
|
||||||
/* YYLAST -- Last index in YYTABLE. */
|
/* YYLAST -- Last index in YYTABLE. */
|
||||||
#define YYLAST ]b4_last[
|
#define YYLAST ]b4_last[
|
||||||
|
|
||||||
/* YYNTOKENS -- Number of terminals. */
|
/* YYNTOKENS -- Number of terminals. */
|
||||||
#define YYNTOKENS ]b4_tokens_number[
|
#define YYNTOKENS ]b4_tokens_number[
|
||||||
/* YYNNTS -- Number of nonterminals. */
|
/* YYNNTS -- Number of nonterminals. */
|
||||||
#define YYNNTS ]b4_nterms_number[
|
#define YYNNTS ]b4_nterms_number[
|
||||||
/* YYNRULES -- Number of rules. */
|
/* YYNRULES -- Number of rules. */
|
||||||
#define YYNRULES ]b4_rules_number[
|
#define YYNRULES ]b4_rules_number[
|
||||||
/* YYNRULES -- Number of states. */
|
/* YYNRULES -- Number of states. */
|
||||||
#define YYNSTATES ]b4_states_number[
|
#define YYNSTATES ]b4_states_number[
|
||||||
/* YYMAXRHS -- Maximum number of symbols on right-hand side of rule. */
|
/* YYMAXRHS -- Maximum number of symbols on right-hand side of rule. */
|
||||||
#define YYMAXRHS ]b4_r2_max[
|
#define YYMAXRHS ]b4_r2_max[
|
||||||
/* YYMAXLEFT -- Maximum number of symbols to the left of a handle
|
/* YYMAXLEFT -- Maximum number of symbols to the left of a handle
|
||||||
accessed by $0, $-1, etc., in any rule. */
|
accessed by $0, $-1, etc., in any rule. */
|
||||||
#define YYMAXLEFT ]b4_max_left_semantic_context[
|
#define YYMAXLEFT ]b4_max_left_semantic_context[
|
||||||
|
|
||||||
/* YYTRANSLATE(X) -- Bison symbol number corresponding to X. */
|
/* YYTRANSLATE(X) -- Bison symbol number corresponding to X. */
|
||||||
@@ -364,7 +364,7 @@ static const ]b4_int_type_for([b4_prhs])[ yyprhs[] =
|
|||||||
]b4_prhs[
|
]b4_prhs[
|
||||||
};
|
};
|
||||||
|
|
||||||
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
|
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
|
||||||
static const ]b4_int_type_for([b4_rhs])[ yyrhs[] =
|
static const ]b4_int_type_for([b4_rhs])[ yyrhs[] =
|
||||||
{
|
{
|
||||||
]b4_rhs[
|
]b4_rhs[
|
||||||
@@ -379,7 +379,7 @@ static const ]b4_int_type_for([b4_rline])[ yyrline[] =
|
|||||||
|
|
||||||
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
|
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
|
||||||
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
|
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
|
||||||
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
|
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
|
||||||
static const char *const yytname[] =
|
static const char *const yytname[] =
|
||||||
{
|
{
|
||||||
]b4_tname[
|
]b4_tname[
|
||||||
@@ -398,13 +398,13 @@ static const ]b4_int_type_for([b4_r2])[ yyr2[] =
|
|||||||
]b4_r2[
|
]b4_r2[
|
||||||
};
|
};
|
||||||
|
|
||||||
/* YYDPREC[RULE-NUM] -- Dynamic precedence of rule #RULE-NUM (0 if none). */
|
/* YYDPREC[RULE-NUM] -- Dynamic precedence of rule #RULE-NUM (0 if none). */
|
||||||
static const ]b4_int_type_for([b4_dprec])[ yydprec[] =
|
static const ]b4_int_type_for([b4_dprec])[ yydprec[] =
|
||||||
{
|
{
|
||||||
]b4_dprec[
|
]b4_dprec[
|
||||||
};
|
};
|
||||||
|
|
||||||
/* YYMERGER[RULE-NUM] -- Index of merging function for rule #RULE-NUM. */
|
/* YYMERGER[RULE-NUM] -- Index of merging function for rule #RULE-NUM. */
|
||||||
static const ]b4_int_type_for([b4_merger])[ yymerger[] =
|
static const ]b4_int_type_for([b4_merger])[ yymerger[] =
|
||||||
{
|
{
|
||||||
]b4_merger[
|
]b4_merger[
|
||||||
@@ -418,7 +418,7 @@ static const ]b4_int_type_for([b4_defact])[ yydefact[] =
|
|||||||
]b4_defact[
|
]b4_defact[
|
||||||
};
|
};
|
||||||
|
|
||||||
/* YYPDEFGOTO[NTERM-NUM]. */
|
/* YYPDEFGOTO[NTERM-NUM]. */
|
||||||
static const ]b4_int_type_for([b4_defgoto])[ yydefgoto[] =
|
static const ]b4_int_type_for([b4_defgoto])[ yydefgoto[] =
|
||||||
{
|
{
|
||||||
]b4_defgoto[
|
]b4_defgoto[
|
||||||
@@ -621,7 +621,7 @@ int yydebug;
|
|||||||
allocation. This is to allow allocation and initialization
|
allocation. This is to allow allocation and initialization
|
||||||
to be completed by functions that call yyexpandGLRStack before the
|
to be completed by functions that call yyexpandGLRStack before the
|
||||||
stack is expanded, thus insuring that all necessary pointers get
|
stack is expanded, thus insuring that all necessary pointers get
|
||||||
properly redirected to new data. */
|
properly redirected to new data. */
|
||||||
#define YYHEADROOM 2
|
#define YYHEADROOM 2
|
||||||
|
|
||||||
#ifndef YYSTACKEXPANDABLE
|
#ifndef YYSTACKEXPANDABLE
|
||||||
@@ -740,12 +740,12 @@ typedef union yyGLRStackItem yyGLRStackItem;
|
|||||||
typedef struct yyGLRStack yyGLRStack;
|
typedef struct yyGLRStack yyGLRStack;
|
||||||
|
|
||||||
struct yyGLRState {
|
struct yyGLRState {
|
||||||
/** Type tag: always true. */
|
/** Type tag: always true. */
|
||||||
yybool yyisState;
|
yybool yyisState;
|
||||||
/** Type tag for yysemantics. If true, yysval applies, otherwise
|
/** Type tag for yysemantics. If true, yysval applies, otherwise
|
||||||
* yyfirstVal applies. */
|
* yyfirstVal applies. */
|
||||||
yybool yyresolved;
|
yybool yyresolved;
|
||||||
/** Number of corresponding LALR(1) machine state. */
|
/** Number of corresponding LALR(1) machine state. */
|
||||||
yyStateNum yylrState;
|
yyStateNum yylrState;
|
||||||
/** Preceding state in this stack */
|
/** Preceding state in this stack */
|
||||||
yyGLRState* yypred;
|
yyGLRState* yypred;
|
||||||
@@ -754,12 +754,12 @@ struct yyGLRState {
|
|||||||
union {
|
union {
|
||||||
/** First in a chain of alternative reductions producing the
|
/** First in a chain of alternative reductions producing the
|
||||||
* non-terminal corresponding to this state, threaded through
|
* non-terminal corresponding to this state, threaded through
|
||||||
* yynext. */
|
* yynext. */
|
||||||
yySemanticOption* yyfirstVal;
|
yySemanticOption* yyfirstVal;
|
||||||
/** Semantic value for this state. */
|
/** Semantic value for this state. */
|
||||||
YYSTYPE yysval;
|
YYSTYPE yysval;
|
||||||
} yysemantics;
|
} yysemantics;
|
||||||
/** Source location for this state. */
|
/** Source location for this state. */
|
||||||
YYLTYPE yyloc;
|
YYLTYPE yyloc;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -769,19 +769,19 @@ struct yyGLRStateSet {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct yySemanticOption {
|
struct yySemanticOption {
|
||||||
/** Type tag: always false. */
|
/** Type tag: always false. */
|
||||||
yybool yyisState;
|
yybool yyisState;
|
||||||
/** Rule number for this reduction */
|
/** Rule number for this reduction */
|
||||||
yyRuleNum yyrule;
|
yyRuleNum yyrule;
|
||||||
/** The last RHS state in the list of states to be reduced. */
|
/** The last RHS state in the list of states to be reduced. */
|
||||||
yyGLRState* yystate;
|
yyGLRState* yystate;
|
||||||
/** Next sibling in chain of options. To facilitate merging,
|
/** Next sibling in chain of options. To facilitate merging,
|
||||||
* options are chained in decreasing order by address. */
|
* options are chained in decreasing order by address. */
|
||||||
yySemanticOption* yynext;
|
yySemanticOption* yynext;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Type of the items in the GLR stack. The yyisState field
|
/** Type of the items in the GLR stack. The yyisState field
|
||||||
* indicates which item of the union is valid. */
|
* indicates which item of the union is valid. */
|
||||||
union yyGLRStackItem {
|
union yyGLRStackItem {
|
||||||
yyGLRState yystate;
|
yyGLRState yystate;
|
||||||
yySemanticOption yyoption;
|
yySemanticOption yyoption;
|
||||||
@@ -844,7 +844,7 @@ yytokenName (yySymbol yytoken)
|
|||||||
|
|
||||||
/** Fill in YYVSP[YYLOW1 .. YYLOW0-1] from the chain of states starting
|
/** Fill in YYVSP[YYLOW1 .. YYLOW0-1] from the chain of states starting
|
||||||
* at YYVSP[YYLOW0].yystate.yypred. Leaves YYVSP[YYLOW1].yystate.yypred
|
* at YYVSP[YYLOW0].yystate.yypred. Leaves YYVSP[YYLOW1].yystate.yypred
|
||||||
* containing the pointer to the next state in the chain. */
|
* containing the pointer to the next state in the chain. */
|
||||||
static void yyfillin (yyGLRStackItem *, int, int) __attribute__ ((__unused__));
|
static void yyfillin (yyGLRStackItem *, int, int) __attribute__ ((__unused__));
|
||||||
static void
|
static void
|
||||||
yyfillin (yyGLRStackItem *yyvsp, int yylow0, int yylow1)
|
yyfillin (yyGLRStackItem *yyvsp, int yylow0, int yylow1)
|
||||||
@@ -881,8 +881,8 @@ yyfill (yyGLRStackItem *yyvsp, int *yylow, int yylow1, yybool yynormal)
|
|||||||
/** Perform user action for rule number YYN, with RHS length YYRHSLEN,
|
/** Perform user action for rule number YYN, with RHS length YYRHSLEN,
|
||||||
* and top stack item YYVSP. YYLVALP points to place to put semantic
|
* and top stack item YYVSP. YYLVALP points to place to put semantic
|
||||||
* value ($$), and yylocp points to place for location information
|
* value ($$), and yylocp points to place for location information
|
||||||
* (@@$). Returns yyok for normal return, yyaccept for YYACCEPT,
|
* (@@$). Returns yyok for normal return, yyaccept for YYACCEPT,
|
||||||
* yyerr for YYERROR, yyabort for YYABORT. */
|
* yyerr for YYERROR, yyabort for YYABORT. */
|
||||||
/*ARGSUSED*/ static YYRESULTTAG
|
/*ARGSUSED*/ static YYRESULTTAG
|
||||||
yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp,
|
yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp,
|
||||||
YYSTYPE* yyvalp,
|
YYSTYPE* yyvalp,
|
||||||
@@ -995,7 +995,7 @@ yydestroyGLRState (char const *yymsg, yyGLRState *yys]b4_user_formals[)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Left-hand-side symbol for rule #RULE. */
|
/** Left-hand-side symbol for rule #RULE. */
|
||||||
static inline yySymbol
|
static inline yySymbol
|
||||||
yylhsNonterm (yyRuleNum yyrule)
|
yylhsNonterm (yyRuleNum yyrule)
|
||||||
{
|
{
|
||||||
@@ -1008,14 +1008,14 @@ yylhsNonterm (yyRuleNum yyrule)
|
|||||||
[((yystate) == YYPACT_NINF)])[
|
[((yystate) == YYPACT_NINF)])[
|
||||||
|
|
||||||
/** True iff LR state STATE has only a default reduction (regardless
|
/** True iff LR state STATE has only a default reduction (regardless
|
||||||
* of token). */
|
* of token). */
|
||||||
static inline yybool
|
static inline yybool
|
||||||
yyisDefaultedState (yyStateNum yystate)
|
yyisDefaultedState (yyStateNum yystate)
|
||||||
{
|
{
|
||||||
return yyis_pact_ninf (yypact[yystate]);
|
return yyis_pact_ninf (yypact[yystate]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The default reduction for STATE, assuming it has one. */
|
/** The default reduction for STATE, assuming it has one. */
|
||||||
static inline yyRuleNum
|
static inline yyRuleNum
|
||||||
yydefaultAction (yyStateNum yystate)
|
yydefaultAction (yyStateNum yystate)
|
||||||
{
|
{
|
||||||
@@ -1112,7 +1112,7 @@ yyaddDeferredAction (yyGLRStack* yystackp, yyGLRState* yystate,
|
|||||||
|
|
||||||
/* GLRStacks */
|
/* GLRStacks */
|
||||||
|
|
||||||
/** Initialize SET to a singleton set containing an empty stack. */
|
/** Initialize SET to a singleton set containing an empty stack. */
|
||||||
static yybool
|
static yybool
|
||||||
yyinitStateSet (yyGLRStateSet* yyset)
|
yyinitStateSet (yyGLRStateSet* yyset)
|
||||||
{
|
{
|
||||||
@@ -1131,7 +1131,7 @@ static void yyfreeStateSet (yyGLRStateSet* yyset)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Initialize STACK to a single empty stack, with total maximum
|
/** Initialize STACK to a single empty stack, with total maximum
|
||||||
* capacity for all stacks of SIZE. */
|
* capacity for all stacks of SIZE. */
|
||||||
static yybool
|
static yybool
|
||||||
yyinitGLRStack (yyGLRStack* yystackp, size_t yysize)
|
yyinitGLRStack (yyGLRStack* yystackp, size_t yysize)
|
||||||
{
|
{
|
||||||
@@ -1157,7 +1157,7 @@ yyinitGLRStack (yyGLRStack* yystackp, size_t yysize)
|
|||||||
stack from outside should be considered invalid after this call.
|
stack from outside should be considered invalid after this call.
|
||||||
We always expand when there are 1 or fewer items left AFTER an
|
We always expand when there are 1 or fewer items left AFTER an
|
||||||
allocation, so that we can avoid having external pointers exist
|
allocation, so that we can avoid having external pointers exist
|
||||||
across an allocation. */
|
across an allocation. */
|
||||||
static void
|
static void
|
||||||
yyexpandGLRStack (yyGLRStack* yystackp)
|
yyexpandGLRStack (yyGLRStack* yystackp)
|
||||||
{
|
{
|
||||||
@@ -1225,7 +1225,7 @@ yyfreeGLRStack (yyGLRStack* yystackp)
|
|||||||
|
|
||||||
/** Assuming that S is a GLRState somewhere on STACK, update the
|
/** Assuming that S is a GLRState somewhere on STACK, update the
|
||||||
* splitpoint of STACK, if needed, so that it is at least as deep as
|
* splitpoint of STACK, if needed, so that it is at least as deep as
|
||||||
* S. */
|
* S. */
|
||||||
static inline void
|
static inline void
|
||||||
yyupdateSplit (yyGLRStack* yystackp, yyGLRState* yys)
|
yyupdateSplit (yyGLRStack* yystackp, yyGLRState* yys)
|
||||||
{
|
{
|
||||||
@@ -1233,7 +1233,7 @@ yyupdateSplit (yyGLRStack* yystackp, yyGLRState* yys)
|
|||||||
yystackp->yysplitPoint = yys;
|
yystackp->yysplitPoint = yys;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Invalidate stack #K in STACK. */
|
/** Invalidate stack #K in STACK. */
|
||||||
static inline void
|
static inline void
|
||||||
yymarkStackDeleted (yyGLRStack* yystackp, size_t yyk)
|
yymarkStackDeleted (yyGLRStack* yystackp, size_t yyk)
|
||||||
{
|
{
|
||||||
@@ -1244,7 +1244,7 @@ yymarkStackDeleted (yyGLRStack* yystackp, size_t yyk)
|
|||||||
|
|
||||||
/** Undelete the last stack that was marked as deleted. Can only be
|
/** Undelete the last stack that was marked as deleted. Can only be
|
||||||
done once after a deletion, and only when all other stacks have
|
done once after a deletion, and only when all other stacks have
|
||||||
been deleted. */
|
been deleted. */
|
||||||
static void
|
static void
|
||||||
yyundeleteLastStack (yyGLRStack* yystackp)
|
yyundeleteLastStack (yyGLRStack* yystackp)
|
||||||
{
|
{
|
||||||
@@ -1286,7 +1286,7 @@ yyremoveDeletes (yyGLRStack* yystackp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Shift to a new state on stack #K of STACK, corresponding to LR state
|
/** Shift to a new state on stack #K of STACK, corresponding to LR state
|
||||||
* LRSTATE, at input position POSN, with (resolved) semantic value SVAL. */
|
* LRSTATE, at input position POSN, with (resolved) semantic value SVAL. */
|
||||||
static inline void
|
static inline void
|
||||||
yyglrShift (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState,
|
yyglrShift (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState,
|
||||||
size_t yyposn,
|
size_t yyposn,
|
||||||
@@ -1307,7 +1307,7 @@ yyglrShift (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState,
|
|||||||
|
|
||||||
/** Shift stack #K of YYSTACK, to a new state corresponding to LR
|
/** Shift stack #K of YYSTACK, to a new state corresponding to LR
|
||||||
* state YYLRSTATE, at input position YYPOSN, with the (unresolved)
|
* state YYLRSTATE, at input position YYPOSN, with the (unresolved)
|
||||||
* semantic value of YYRHS under the action for YYRULE. */
|
* semantic value of YYRHS under the action for YYRULE. */
|
||||||
static inline void
|
static inline void
|
||||||
yyglrShiftDefer (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState,
|
yyglrShiftDefer (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState,
|
||||||
size_t yyposn, yyGLRState* rhs, yyRuleNum yyrule)
|
size_t yyposn, yyGLRState* rhs, yyRuleNum yyrule)
|
||||||
@@ -1321,16 +1321,16 @@ yyglrShiftDefer (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState,
|
|||||||
yynewState->yysemantics.yyfirstVal = NULL;
|
yynewState->yysemantics.yyfirstVal = NULL;
|
||||||
yystackp->yytops.yystates[yyk] = yynewState;
|
yystackp->yytops.yystates[yyk] = yynewState;
|
||||||
|
|
||||||
/* Invokes YY_RESERVE_GLRSTACK. */
|
/* Invokes YY_RESERVE_GLRSTACK. */
|
||||||
yyaddDeferredAction (yystackp, yynewState, rhs, yyrule);
|
yyaddDeferredAction (yystackp, yynewState, rhs, yyrule);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Pop the symbols consumed by reduction #RULE from the top of stack
|
/** Pop the symbols consumed by reduction #RULE from the top of stack
|
||||||
* #K of STACK, and perform the appropriate semantic action on their
|
* #K of STACK, and perform the appropriate semantic action on their
|
||||||
* semantic values. Assumes that all ambiguities in semantic values
|
* semantic values. Assumes that all ambiguities in semantic values
|
||||||
* have been previously resolved. Set *VALP to the resulting value,
|
* have been previously resolved. Set *VALP to the resulting value,
|
||||||
* and *LOCP to the computed location (if any). Return value is as
|
* and *LOCP to the computed location (if any). Return value is as
|
||||||
* for userAction. */
|
* for userAction. */
|
||||||
static inline YYRESULTTAG
|
static inline YYRESULTTAG
|
||||||
yydoAction (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
|
yydoAction (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
|
||||||
YYSTYPE* yyvalp, YYLTYPE* yylocp]b4_user_formals[)
|
YYSTYPE* yyvalp, YYLTYPE* yylocp]b4_user_formals[)
|
||||||
@@ -1339,7 +1339,7 @@ yydoAction (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
|
|||||||
|
|
||||||
if (yystackp->yysplitPoint == NULL)
|
if (yystackp->yysplitPoint == NULL)
|
||||||
{
|
{
|
||||||
/* Standard special case: single stack. */
|
/* Standard special case: single stack. */
|
||||||
yyGLRStackItem* rhs = (yyGLRStackItem*) yystackp->yytops.yystates[yyk];
|
yyGLRStackItem* rhs = (yyGLRStackItem*) yystackp->yytops.yystates[yyk];
|
||||||
YYASSERT (yyk == 0);
|
YYASSERT (yyk == 0);
|
||||||
yystackp->yynextFree -= yynrhs;
|
yystackp->yynextFree -= yynrhs;
|
||||||
@@ -1353,14 +1353,14 @@ yydoAction (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
|
|||||||
/* At present, doAction is never called in nondeterministic
|
/* At present, doAction is never called in nondeterministic
|
||||||
* mode, so this branch is never taken. It is here in
|
* mode, so this branch is never taken. It is here in
|
||||||
* anticipation of a future feature that will allow immediate
|
* anticipation of a future feature that will allow immediate
|
||||||
* evaluation of selected actions in nondeterministic mode. */
|
* evaluation of selected actions in nondeterministic mode. */
|
||||||
int yyi;
|
int yyi;
|
||||||
yyGLRState* yys;
|
yyGLRState* yys;
|
||||||
yyGLRStackItem yyrhsVals[YYMAXRHS + YYMAXLEFT + 1];
|
yyGLRStackItem yyrhsVals[YYMAXRHS + YYMAXLEFT + 1];
|
||||||
yys = yyrhsVals[YYMAXRHS + YYMAXLEFT].yystate.yypred
|
yys = yyrhsVals[YYMAXRHS + YYMAXLEFT].yystate.yypred
|
||||||
= yystackp->yytops.yystates[yyk];]b4_location_if([[
|
= yystackp->yytops.yystates[yyk];]b4_location_if([[
|
||||||
if (yynrhs == 0)
|
if (yynrhs == 0)
|
||||||
/* Set default location. */
|
/* Set default location. */
|
||||||
yyrhsVals[YYMAXRHS + YYMAXLEFT - 1].yystate.yyloc = yys->yyloc;]])[
|
yyrhsVals[YYMAXRHS + YYMAXLEFT - 1].yystate.yyloc = yys->yyloc;]])[
|
||||||
for (yyi = 0; yyi < yynrhs; yyi += 1)
|
for (yyi = 0; yyi < yynrhs; yyi += 1)
|
||||||
{
|
{
|
||||||
@@ -1424,7 +1424,7 @@ yy_reduce_print (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
|
|||||||
* the new state. If the new state would have an identical input
|
* the new state. If the new state would have an identical input
|
||||||
* position, LR state, and predecessor to an existing state on the stack,
|
* position, LR state, and predecessor to an existing state on the stack,
|
||||||
* it is identified with that existing state, eliminating stack #K from
|
* it is identified with that existing state, eliminating stack #K from
|
||||||
* the STACK. In this case, the (necessarily deferred) semantic value is
|
* the STACK. In this case, the (necessarily deferred) semantic value is
|
||||||
* added to the options for the existing state's semantic value.
|
* added to the options for the existing state's semantic value.
|
||||||
*/
|
*/
|
||||||
static inline YYRESULTTAG
|
static inline YYRESULTTAG
|
||||||
@@ -1463,7 +1463,7 @@ yyglrReduce (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
|
|||||||
yyupdateSplit (yystackp, yys);
|
yyupdateSplit (yystackp, yys);
|
||||||
yynewLRState = yyLRgotoState (yys->yylrState, yylhsNonterm (yyrule));
|
yynewLRState = yyLRgotoState (yys->yylrState, yylhsNonterm (yyrule));
|
||||||
YYDPRINTF ((stderr,
|
YYDPRINTF ((stderr,
|
||||||
"Reduced stack %lu by rule #%d; action deferred. Now in state %d.\n",
|
"Reduced stack %lu by rule #%d; action deferred. Now in state %d.\n",
|
||||||
(unsigned long int) yyk, yyrule - 1, yynewLRState));
|
(unsigned long int) yyk, yyrule - 1, yynewLRState));
|
||||||
for (yyi = 0; yyi < yystackp->yytops.yysize; yyi += 1)
|
for (yyi = 0; yyi < yystackp->yytops.yysize; yyi += 1)
|
||||||
if (yyi != yyk && yystackp->yytops.yystates[yyi] != NULL)
|
if (yyi != yyk && yystackp->yytops.yystates[yyi] != NULL)
|
||||||
@@ -1518,7 +1518,7 @@ yysplitStack (yyGLRStack* yystackp, size_t yyk)
|
|||||||
|
|
||||||
/** True iff Y0 and Y1 represent identical options at the top level.
|
/** True iff Y0 and Y1 represent identical options at the top level.
|
||||||
* That is, they represent the same rule applied to RHS symbols
|
* That is, they represent the same rule applied to RHS symbols
|
||||||
* that produce the same terminal symbols. */
|
* that produce the same terminal symbols. */
|
||||||
static yybool
|
static yybool
|
||||||
yyidenticalOptions (yySemanticOption* yyy0, yySemanticOption* yyy1)
|
yyidenticalOptions (yySemanticOption* yyy0, yySemanticOption* yyy1)
|
||||||
{
|
{
|
||||||
@@ -1539,7 +1539,7 @@ yyidenticalOptions (yySemanticOption* yyy0, yySemanticOption* yyy1)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Assuming identicalOptions (Y0,Y1), destructively merge the
|
/** Assuming identicalOptions (Y0,Y1), destructively merge the
|
||||||
* alternative semantic values for the RHS-symbols of Y1 and Y0. */
|
* alternative semantic values for the RHS-symbols of Y1 and Y0. */
|
||||||
static void
|
static void
|
||||||
yymergeOptionSets (yySemanticOption* yyy0, yySemanticOption* yyy1)
|
yymergeOptionSets (yySemanticOption* yyy0, yySemanticOption* yyy1)
|
||||||
{
|
{
|
||||||
@@ -1593,7 +1593,7 @@ yymergeOptionSets (yySemanticOption* yyy0, yySemanticOption* yyy1)
|
|||||||
|
|
||||||
/** Y0 and Y1 represent two possible actions to take in a given
|
/** Y0 and Y1 represent two possible actions to take in a given
|
||||||
* parsing state; return 0 if no combination is possible,
|
* parsing state; return 0 if no combination is possible,
|
||||||
* 1 if user-mergeable, 2 if Y0 is preferred, 3 if Y1 is preferred. */
|
* 1 if user-mergeable, 2 if Y0 is preferred, 3 if Y1 is preferred. */
|
||||||
static int
|
static int
|
||||||
yypreference (yySemanticOption* y0, yySemanticOption* y1)
|
yypreference (yySemanticOption* y0, yySemanticOption* y1)
|
||||||
{
|
{
|
||||||
@@ -1655,7 +1655,7 @@ yyresolveAction (yySemanticOption* yyopt, yyGLRStack* yystackp,
|
|||||||
YYCHK (yyresolveStates (yyopt->yystate, yynrhs, yystackp]b4_user_args[));
|
YYCHK (yyresolveStates (yyopt->yystate, yynrhs, yystackp]b4_user_args[));
|
||||||
yyrhsVals[YYMAXRHS + YYMAXLEFT].yystate.yypred = yyopt->yystate;]b4_location_if([[
|
yyrhsVals[YYMAXRHS + YYMAXLEFT].yystate.yypred = yyopt->yystate;]b4_location_if([[
|
||||||
if (yynrhs == 0)
|
if (yynrhs == 0)
|
||||||
/* Set default location. */
|
/* Set default location. */
|
||||||
yyrhsVals[YYMAXRHS + YYMAXLEFT - 1].yystate.yyloc = yyopt->yystate->yyloc;]])[
|
yyrhsVals[YYMAXRHS + YYMAXLEFT - 1].yystate.yyloc = yyopt->yystate->yyloc;]])[
|
||||||
return yyuserAction (yyopt->yyrule, yynrhs,
|
return yyuserAction (yyopt->yyrule, yynrhs,
|
||||||
yyrhsVals + YYMAXRHS + YYMAXLEFT - 1,
|
yyrhsVals + YYMAXRHS + YYMAXLEFT - 1,
|
||||||
@@ -1733,7 +1733,7 @@ yyreportAmbiguity (yySemanticOption* yyx0, yySemanticOption* yyx1,
|
|||||||
|
|
||||||
|
|
||||||
/** Resolve the ambiguity represented by OPTIONLIST, perform the indicated
|
/** Resolve the ambiguity represented by OPTIONLIST, perform the indicated
|
||||||
* actions, and return the result. */
|
* actions, and return the result. */
|
||||||
static YYRESULTTAG
|
static YYRESULTTAG
|
||||||
yyresolveValue (yySemanticOption* yyoptionList, yyGLRStack* yystackp,
|
yyresolveValue (yySemanticOption* yyoptionList, yyGLRStack* yystackp,
|
||||||
YYSTYPE* yyvalp, YYLTYPE* yylocp]b4_user_formals[)
|
YYSTYPE* yyvalp, YYLTYPE* yylocp]b4_user_formals[)
|
||||||
@@ -2040,7 +2040,7 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
|
|||||||
if (*yytokenp != YYEMPTY)
|
if (*yytokenp != YYEMPTY)
|
||||||
{]b4_location_if([[
|
{]b4_location_if([[
|
||||||
/* We throw away the lookahead, but the error range
|
/* We throw away the lookahead, but the error range
|
||||||
of the shifted error token must take it into account. */
|
of the shifted error token must take it into account. */
|
||||||
yyGLRState *yys = yystackp->yytops.yystates[0];
|
yyGLRState *yys = yystackp->yytops.yystates[0];
|
||||||
yyGLRStackItem yyerror_range[3];
|
yyGLRStackItem yyerror_range[3];
|
||||||
yyerror_range[1].yystate.yyloc = yys->yyloc;
|
yyerror_range[1].yystate.yyloc = yys->yyloc;
|
||||||
@@ -2077,7 +2077,7 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
|
|||||||
yyremoveDeletes (yystackp);
|
yyremoveDeletes (yystackp);
|
||||||
yycompressStack (yystackp);
|
yycompressStack (yystackp);
|
||||||
|
|
||||||
/* Now pop stack until we find a state that shifts the error token. */
|
/* Now pop stack until we find a state that shifts the error token. */
|
||||||
yystackp->yyerrState = 3;
|
yystackp->yyerrState = 3;
|
||||||
while (yystackp->yytops.yystates[0] != NULL)
|
while (yystackp->yytops.yystates[0] != NULL)
|
||||||
{
|
{
|
||||||
@@ -2153,7 +2153,7 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
|
|||||||
m4_ifdef([b4_initial_action], [
|
m4_ifdef([b4_initial_action], [
|
||||||
m4_pushdef([b4_at_dollar], [yylloc])dnl
|
m4_pushdef([b4_at_dollar], [yylloc])dnl
|
||||||
m4_pushdef([b4_dollar_dollar], [yylval])dnl
|
m4_pushdef([b4_dollar_dollar], [yylval])dnl
|
||||||
/* User initialization code. */
|
/* User initialization code. */
|
||||||
b4_initial_action
|
b4_initial_action
|
||||||
m4_popdef([b4_dollar_dollar])dnl
|
m4_popdef([b4_dollar_dollar])dnl
|
||||||
m4_popdef([b4_at_dollar])dnl
|
m4_popdef([b4_at_dollar])dnl
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ m4_popdef([b4_parse_param])dnl
|
|||||||
/* Pacify ``unused variable'' warnings. */
|
/* Pacify ``unused variable'' warnings. */
|
||||||
YYUSE (yyvaluep);
|
YYUSE (yyvaluep);
|
||||||
YYUSE (yylocationp);
|
YYUSE (yylocationp);
|
||||||
/* Backward compatibility, but should be removed eventually. */
|
/* Backward compatibility, but should be removed eventually. */
|
||||||
std::ostream& cdebug_ = *yycdebug_;
|
std::ostream& cdebug_ = *yycdebug_;
|
||||||
YYUSE (cdebug_);
|
YYUSE (cdebug_);
|
||||||
|
|
||||||
|
|||||||
@@ -285,7 +285,7 @@ b4_error_verbose_if([, int tok])[);
|
|||||||
[b4_token_defines(b4_tokens)
|
[b4_token_defines(b4_tokens)
|
||||||
|
|
||||||
#ifndef YYSTYPE
|
#ifndef YYSTYPE
|
||||||
/* Redirection for backward compatibility. */
|
/* Redirection for backward compatibility. */
|
||||||
# define YYSTYPE yy::b4_parser_class_name::semantic_type
|
# define YYSTYPE yy::b4_parser_class_name::semantic_type
|
||||||
#endif
|
#endif
|
||||||
])[
|
])[
|
||||||
@@ -323,7 +323,7 @@ b4_syncline([@oline@], [@ofile@])[
|
|||||||
/* Suppress unused-variable warnings by "using" E. */
|
/* Suppress unused-variable warnings by "using" E. */
|
||||||
#define YYUSE(e) ((void) (e))
|
#define YYUSE(e) ((void) (e))
|
||||||
|
|
||||||
/* A pseudo ostream that takes yydebug_ into account. */
|
/* A pseudo ostream that takes yydebug_ into account. */
|
||||||
# define YYCDEBUG \
|
# define YYCDEBUG \
|
||||||
for (bool yydebugcond_ = yydebug_; yydebugcond_; yydebugcond_ = false) \
|
for (bool yydebugcond_ = yydebug_; yydebugcond_; yydebugcond_ = false) \
|
||||||
(*yycdebug_)
|
(*yycdebug_)
|
||||||
@@ -428,7 +428,7 @@ namespace yy
|
|||||||
]b4_parser_class_name[::yysymprint_ (int yytype,
|
]b4_parser_class_name[::yysymprint_ (int yytype,
|
||||||
const semantic_type* yyvaluep, const location_type* yylocationp)
|
const semantic_type* yyvaluep, const location_type* yylocationp)
|
||||||
{
|
{
|
||||||
/* Backward compatibility, but should be removed eventually. */
|
/* Backward compatibility, but should be removed eventually. */
|
||||||
std::ostream& cdebug_ = *yycdebug_;
|
std::ostream& cdebug_ = *yycdebug_;
|
||||||
|
|
||||||
YYUSE (!&cdebug_);
|
YYUSE (!&cdebug_);
|
||||||
@@ -512,7 +512,7 @@ namespace yy
|
|||||||
int yylen = 0;
|
int yylen = 0;
|
||||||
int yystate = 0;
|
int yystate = 0;
|
||||||
|
|
||||||
/* Error handling. */
|
/* Error handling. */
|
||||||
int yynerrs_ = 0;
|
int yynerrs_ = 0;
|
||||||
int yyerrstatus_ = 0;
|
int yyerrstatus_ = 0;
|
||||||
|
|
||||||
@@ -535,7 +535,7 @@ namespace yy
|
|||||||
]m4_ifdef([b4_initial_action], [
|
]m4_ifdef([b4_initial_action], [
|
||||||
m4_pushdef([b4_at_dollar], [yylloc])dnl
|
m4_pushdef([b4_at_dollar], [yylloc])dnl
|
||||||
m4_pushdef([b4_dollar_dollar], [yylval])dnl
|
m4_pushdef([b4_dollar_dollar], [yylval])dnl
|
||||||
/* User initialization code. */
|
/* User initialization code. */
|
||||||
b4_initial_action
|
b4_initial_action
|
||||||
m4_popdef([b4_dollar_dollar])dnl
|
m4_popdef([b4_dollar_dollar])dnl
|
||||||
m4_popdef([b4_at_dollar])dnl
|
m4_popdef([b4_at_dollar])dnl
|
||||||
@@ -732,7 +732,7 @@ b4_error_verbose_if([, yytoken])[));
|
|||||||
|
|
||||||
yyerror_range[0] = yylocation_stack_[yylen - 1];
|
yyerror_range[0] = yylocation_stack_[yylen - 1];
|
||||||
/* Do not reclaim the symbols of the rule which action triggered
|
/* Do not reclaim the symbols of the rule which action triggered
|
||||||
this YYERROR. */
|
this YYERROR. */
|
||||||
yypop_ (yylen);
|
yypop_ (yylen);
|
||||||
yylen = 0;
|
yylen = 0;
|
||||||
yystate = yystate_stack_[0];
|
yystate = yystate_stack_[0];
|
||||||
@@ -781,7 +781,7 @@ b4_error_verbose_if([, yytoken])[));
|
|||||||
yysemantic_stack_.push (yylval);
|
yysemantic_stack_.push (yylval);
|
||||||
yylocation_stack_.push (yyloc);
|
yylocation_stack_.push (yyloc);
|
||||||
|
|
||||||
/* Shift the error token. */
|
/* Shift the error token. */
|
||||||
YY_SYMBOL_PRINT ("Shifting", yystos_[yyn],
|
YY_SYMBOL_PRINT ("Shifting", yystos_[yyn],
|
||||||
&yysemantic_stack_[0], &yylocation_stack_[0]);
|
&yysemantic_stack_[0], &yylocation_stack_[0]);
|
||||||
|
|
||||||
@@ -803,7 +803,7 @@ b4_error_verbose_if([, yytoken])[));
|
|||||||
yydestruct_ ("Cleanup: discarding lookahead", yytoken, &yylval, &yylloc);
|
yydestruct_ ("Cleanup: discarding lookahead", yytoken, &yylval, &yylloc);
|
||||||
|
|
||||||
/* Do not reclaim the symbols of the rule which action triggered
|
/* Do not reclaim the symbols of the rule which action triggered
|
||||||
this YYABORT or YYACCEPT. */
|
this YYABORT or YYACCEPT. */
|
||||||
yypop_ (yylen);
|
yypop_ (yylen);
|
||||||
while (yystate_stack_.height () != 1)
|
while (yystate_stack_.height () != 1)
|
||||||
{
|
{
|
||||||
@@ -950,7 +950,7 @@ b4_error_verbose_if([, int tok])[)
|
|||||||
|
|
||||||
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
|
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
|
||||||
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
|
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
|
||||||
First, the terminals, then, starting at \a yyntokens_, nonterminals. */
|
First, the terminals, then, starting at \a yyntokens_, nonterminals. */
|
||||||
const char*
|
const char*
|
||||||
const ]b4_parser_class_name[::yytname_[] =
|
const ]b4_parser_class_name[::yytname_[] =
|
||||||
{
|
{
|
||||||
@@ -959,7 +959,7 @@ b4_error_verbose_if([, int tok])[)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if YYDEBUG
|
#if YYDEBUG
|
||||||
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
|
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
|
||||||
const ]b4_parser_class_name[::rhs_number_type
|
const ]b4_parser_class_name[::rhs_number_type
|
||||||
]b4_parser_class_name[::yyrhs_[] =
|
]b4_parser_class_name[::yyrhs_[] =
|
||||||
{
|
{
|
||||||
|
|||||||
41
data/yacc.c
41
data/yacc.c
@@ -305,7 +305,7 @@ b4_syncline([@oline@], [@ofile@])[
|
|||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifdef YYSTACK_ALLOC
|
# ifdef YYSTACK_ALLOC
|
||||||
/* Pacify GCC's `empty if-body' warning. */
|
/* Pacify GCC's `empty if-body' warning. */
|
||||||
# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
|
# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
|
||||||
# ifndef YYSTACK_ALLOC_MAXIMUM
|
# ifndef YYSTACK_ALLOC_MAXIMUM
|
||||||
/* The OS might guarantee only one guard page at the bottom of the stack,
|
/* The OS might guarantee only one guard page at the bottom of the stack,
|
||||||
@@ -411,18 +411,18 @@ union yyalloc
|
|||||||
typedef short int yysigned_char;
|
typedef short int yysigned_char;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* YYFINAL -- State number of the termination state. */
|
/* YYFINAL -- State number of the termination state. */
|
||||||
#define YYFINAL ]b4_final_state_number[
|
#define YYFINAL ]b4_final_state_number[
|
||||||
/* YYLAST -- Last index in YYTABLE. */
|
/* YYLAST -- Last index in YYTABLE. */
|
||||||
#define YYLAST ]b4_last[
|
#define YYLAST ]b4_last[
|
||||||
|
|
||||||
/* YYNTOKENS -- Number of terminals. */
|
/* YYNTOKENS -- Number of terminals. */
|
||||||
#define YYNTOKENS ]b4_tokens_number[
|
#define YYNTOKENS ]b4_tokens_number[
|
||||||
/* YYNNTS -- Number of nonterminals. */
|
/* YYNNTS -- Number of nonterminals. */
|
||||||
#define YYNNTS ]b4_nterms_number[
|
#define YYNNTS ]b4_nterms_number[
|
||||||
/* YYNRULES -- Number of rules. */
|
/* YYNRULES -- Number of rules. */
|
||||||
#define YYNRULES ]b4_rules_number[
|
#define YYNRULES ]b4_rules_number[
|
||||||
/* YYNRULES -- Number of states. */
|
/* YYNRULES -- Number of states. */
|
||||||
#define YYNSTATES ]b4_states_number[
|
#define YYNSTATES ]b4_states_number[
|
||||||
|
|
||||||
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
|
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
|
||||||
@@ -446,7 +446,7 @@ static const ]b4_int_type_for([b4_prhs])[ yyprhs[] =
|
|||||||
]b4_prhs[
|
]b4_prhs[
|
||||||
};
|
};
|
||||||
|
|
||||||
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
|
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
|
||||||
static const ]b4_int_type_for([b4_rhs])[ yyrhs[] =
|
static const ]b4_int_type_for([b4_rhs])[ yyrhs[] =
|
||||||
{
|
{
|
||||||
]b4_rhs[
|
]b4_rhs[
|
||||||
@@ -461,7 +461,7 @@ static const ]b4_int_type_for([b4_rline])[ yyrline[] =
|
|||||||
|
|
||||||
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
|
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
|
||||||
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
|
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
|
||||||
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
|
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
|
||||||
static const char *const yytname[] =
|
static const char *const yytname[] =
|
||||||
{
|
{
|
||||||
]b4_tname[
|
]b4_tname[
|
||||||
@@ -497,7 +497,7 @@ static const ]b4_int_type_for([b4_defact])[ yydefact[] =
|
|||||||
]b4_defact[
|
]b4_defact[
|
||||||
};
|
};
|
||||||
|
|
||||||
/* YYDEFGOTO[NTERM-NUM]. */
|
/* YYDEFGOTO[NTERM-NUM]. */
|
||||||
static const ]b4_int_type_for([b4_defgoto])[ yydefgoto[] =
|
static const ]b4_int_type_for([b4_defgoto])[ yydefgoto[] =
|
||||||
{
|
{
|
||||||
]b4_defgoto[
|
]b4_defgoto[
|
||||||
@@ -666,7 +666,7 @@ do { \
|
|||||||
[[short int *top], [top]])[
|
[[short int *top], [top]])[
|
||||||
{
|
{
|
||||||
YYFPRINTF (stderr, "Stack now");
|
YYFPRINTF (stderr, "Stack now");
|
||||||
for (/* Nothing. */; bottom <= top; ++bottom)
|
for (; bottom <= top; ++bottom)
|
||||||
YYFPRINTF (stderr, " %d", *bottom);
|
YYFPRINTF (stderr, " %d", *bottom);
|
||||||
YYFPRINTF (stderr, "\n");
|
YYFPRINTF (stderr, "\n");
|
||||||
}
|
}
|
||||||
@@ -1039,7 +1039,7 @@ b4_c_function_def([yyparse], [int], b4_parse_param)
|
|||||||
YYLTYPE yylsa[YYINITDEPTH];
|
YYLTYPE yylsa[YYINITDEPTH];
|
||||||
YYLTYPE *yyls = yylsa;
|
YYLTYPE *yyls = yylsa;
|
||||||
YYLTYPE *yylsp;
|
YYLTYPE *yylsp;
|
||||||
/* The locations where the error started and ended. */
|
/* The locations where the error started and ended. */
|
||||||
YYLTYPE yyerror_range[2];]])[
|
YYLTYPE yyerror_range[2];]])[
|
||||||
|
|
||||||
#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)]b4_location_if([, yylsp -= (N)])[)
|
#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)]b4_location_if([, yylsp -= (N)])[)
|
||||||
@@ -1052,7 +1052,7 @@ b4_c_function_def([yyparse], [int], b4_parse_param)
|
|||||||
]b4_location_if([ YYLTYPE yyloc;])[
|
]b4_location_if([ YYLTYPE yyloc;])[
|
||||||
|
|
||||||
/* The number of symbols on the RHS of the reduced rule.
|
/* The number of symbols on the RHS of the reduced rule.
|
||||||
Keep to zero when no symbol should be popped off. */
|
Keep to zero when no symbol should be popped. */
|
||||||
int yylen = 0;
|
int yylen = 0;
|
||||||
|
|
||||||
YYDPRINTF ((stderr, "Starting parse\n"));
|
YYDPRINTF ((stderr, "Starting parse\n"));
|
||||||
@@ -1079,7 +1079,7 @@ b4_c_function_def([yyparse], [int], b4_parse_param)
|
|||||||
m4_ifdef([b4_initial_action], [
|
m4_ifdef([b4_initial_action], [
|
||||||
m4_pushdef([b4_at_dollar], [m4_define([b4_at_dollar_used])yylloc])dnl
|
m4_pushdef([b4_at_dollar], [m4_define([b4_at_dollar_used])yylloc])dnl
|
||||||
m4_pushdef([b4_dollar_dollar], [m4_define([b4_dollar_dollar_used])yylval])dnl
|
m4_pushdef([b4_dollar_dollar], [m4_define([b4_dollar_dollar_used])yylval])dnl
|
||||||
/* User initialization code. */
|
/* User initialization code. */
|
||||||
b4_initial_action
|
b4_initial_action
|
||||||
m4_popdef([b4_dollar_dollar])dnl
|
m4_popdef([b4_dollar_dollar])dnl
|
||||||
m4_popdef([b4_at_dollar])dnl
|
m4_popdef([b4_at_dollar])dnl
|
||||||
@@ -1097,8 +1097,7 @@ m4_ifdef([b4_at_dollar_used], [[ yylsp[0] = yylloc;
|
|||||||
`------------------------------------------------------------*/
|
`------------------------------------------------------------*/
|
||||||
yynewstate:
|
yynewstate:
|
||||||
/* In all cases, when you get here, the value and location stacks
|
/* In all cases, when you get here, the value and location stacks
|
||||||
have just been pushed. so pushing a state here evens the stacks.
|
have just been pushed. So pushing a state here evens the stacks. */
|
||||||
*/
|
|
||||||
yyssp++;
|
yyssp++;
|
||||||
|
|
||||||
yysetstate:
|
yysetstate:
|
||||||
@@ -1111,7 +1110,7 @@ m4_ifdef([b4_at_dollar_used], [[ yylsp[0] = yylloc;
|
|||||||
|
|
||||||
#ifdef yyoverflow
|
#ifdef yyoverflow
|
||||||
{
|
{
|
||||||
/* Give user a chance to reallocate the stack. Use copies of
|
/* Give user a chance to reallocate the stack. Use copies of
|
||||||
these so that the &'s don't force the real ones into
|
these so that the &'s don't force the real ones into
|
||||||
memory. */
|
memory. */
|
||||||
YYSTYPE *yyvs1 = yyvs;
|
YYSTYPE *yyvs1 = yyvs;
|
||||||
@@ -1269,7 +1268,7 @@ yyreduce:
|
|||||||
yyval = yyvsp[1-yylen];
|
yyval = yyvsp[1-yylen];
|
||||||
|
|
||||||
]b4_location_if(
|
]b4_location_if(
|
||||||
[[ /* Default location. */
|
[[ /* Default location. */
|
||||||
YYLLOC_DEFAULT (yyloc, yylsp - yylen, yylen);]])[
|
YYLLOC_DEFAULT (yyloc, yylsp - yylen, yylen);]])[
|
||||||
YY_REDUCE_PRINT (yyn);
|
YY_REDUCE_PRINT (yyn);
|
||||||
switch (yyn)
|
switch (yyn)
|
||||||
@@ -1387,7 +1386,7 @@ yyerrorlab:
|
|||||||
|
|
||||||
]b4_location_if([[ yyerror_range[0] = yylsp[1-yylen];
|
]b4_location_if([[ yyerror_range[0] = yylsp[1-yylen];
|
||||||
]])[ /* Do not reclaim the symbols of the rule which action triggered
|
]])[ /* Do not reclaim the symbols of the rule which action triggered
|
||||||
this YYERROR. */
|
this YYERROR. */
|
||||||
YYPOPSTACK (yylen);
|
YYPOPSTACK (yylen);
|
||||||
yylen = 0;
|
yylen = 0;
|
||||||
YY_STACK_PRINT (yyss, yyssp);
|
YY_STACK_PRINT (yyss, yyssp);
|
||||||
@@ -1434,11 +1433,11 @@ yyerrlab1:
|
|||||||
]b4_location_if([[
|
]b4_location_if([[
|
||||||
yyerror_range[1] = yylloc;
|
yyerror_range[1] = yylloc;
|
||||||
/* Using YYLLOC is tempting, but would change the location of
|
/* Using YYLLOC is tempting, but would change the location of
|
||||||
the look-ahead. YYLOC is available though. */
|
the look-ahead. YYLOC is available though. */
|
||||||
YYLLOC_DEFAULT (yyloc, yyerror_range - 1, 2);
|
YYLLOC_DEFAULT (yyloc, yyerror_range - 1, 2);
|
||||||
*++yylsp = yyloc;]])[
|
*++yylsp = yyloc;]])[
|
||||||
|
|
||||||
/* Shift the error token. */
|
/* Shift the error token. */
|
||||||
YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
|
YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
|
||||||
|
|
||||||
yystate = yyn;
|
yystate = yyn;
|
||||||
@@ -1474,7 +1473,7 @@ yyreturn:
|
|||||||
yydestruct ("Cleanup: discarding lookahead",
|
yydestruct ("Cleanup: discarding lookahead",
|
||||||
yytoken, &yylval]b4_location_if([, &yylloc])[]b4_user_args[);
|
yytoken, &yylval]b4_location_if([, &yylloc])[]b4_user_args[);
|
||||||
/* Do not reclaim the symbols of the rule which action triggered
|
/* Do not reclaim the symbols of the rule which action triggered
|
||||||
this YYABORT or YYACCEPT. */
|
this YYABORT or YYACCEPT. */
|
||||||
YYPOPSTACK (yylen);
|
YYPOPSTACK (yylen);
|
||||||
YY_STACK_PRINT (yyss, yyssp);
|
YY_STACK_PRINT (yyss, yyssp);
|
||||||
while (yyssp != yyss)
|
while (yyssp != yyss)
|
||||||
|
|||||||
@@ -461,7 +461,7 @@ more information on this.
|
|||||||
@cindex @acronym{GLR} parsing
|
@cindex @acronym{GLR} parsing
|
||||||
@cindex generalized @acronym{LR} (@acronym{GLR}) parsing
|
@cindex generalized @acronym{LR} (@acronym{GLR}) parsing
|
||||||
@cindex ambiguous grammars
|
@cindex ambiguous grammars
|
||||||
@cindex non-deterministic parsing
|
@cindex nondeterministic parsing
|
||||||
|
|
||||||
Parsers for @acronym{LALR}(1) grammars are @dfn{deterministic}, meaning
|
Parsers for @acronym{LALR}(1) grammars are @dfn{deterministic}, meaning
|
||||||
roughly that the next grammar rule to apply at any point in the input is
|
roughly that the next grammar rule to apply at any point in the input is
|
||||||
@@ -469,7 +469,7 @@ uniquely determined by the preceding input and a fixed, finite portion
|
|||||||
(called a @dfn{look-ahead}) of the remaining input. A context-free
|
(called a @dfn{look-ahead}) of the remaining input. A context-free
|
||||||
grammar can be @dfn{ambiguous}, meaning that there are multiple ways to
|
grammar can be @dfn{ambiguous}, meaning that there are multiple ways to
|
||||||
apply the grammar rules to get the same inputs. Even unambiguous
|
apply the grammar rules to get the same inputs. Even unambiguous
|
||||||
grammars can be @dfn{non-deterministic}, meaning that no fixed
|
grammars can be @dfn{nondeterministic}, meaning that no fixed
|
||||||
look-ahead always suffices to determine the next grammar rule to apply.
|
look-ahead always suffices to determine the next grammar rule to apply.
|
||||||
With the proper declarations, Bison is also able to parse these more
|
With the proper declarations, Bison is also able to parse these more
|
||||||
general context-free grammars, using a technique known as @acronym{GLR}
|
general context-free grammars, using a technique known as @acronym{GLR}
|
||||||
@@ -2126,7 +2126,7 @@ as @code{sin}, @code{cos}, etc.
|
|||||||
|
|
||||||
It is easy to add new operators to the infix calculator as long as they are
|
It is easy to add new operators to the infix calculator as long as they are
|
||||||
only single-character literals. The lexical analyzer @code{yylex} passes
|
only single-character literals. The lexical analyzer @code{yylex} passes
|
||||||
back all nonnumber characters as tokens, so new grammar rules suffice for
|
back all nonnumeric characters as tokens, so new grammar rules suffice for
|
||||||
adding a new operator. But we want something more flexible: built-in
|
adding a new operator. But we want something more flexible: built-in
|
||||||
functions whose syntax has this form:
|
functions whose syntax has this form:
|
||||||
|
|
||||||
@@ -2411,7 +2411,7 @@ getsym (char const *sym_name)
|
|||||||
|
|
||||||
The function @code{yylex} must now recognize variables, numeric values, and
|
The function @code{yylex} must now recognize variables, numeric values, and
|
||||||
the single-character arithmetic operators. Strings of alphanumeric
|
the single-character arithmetic operators. Strings of alphanumeric
|
||||||
characters with a leading non-digit are recognized as either variables or
|
characters with a leading letter are recognized as either variables or
|
||||||
functions depending on what the symbol table says about them.
|
functions depending on what the symbol table says about them.
|
||||||
|
|
||||||
The string is passed to @code{getsym} for look up in the symbol table. If
|
The string is passed to @code{getsym} for look up in the symbol table. If
|
||||||
@@ -2782,7 +2782,7 @@ into a separate header file @file{@var{name}.tab.h} which you can include
|
|||||||
in the other source files that need it. @xref{Invocation, ,Invoking Bison}.
|
in the other source files that need it. @xref{Invocation, ,Invoking Bison}.
|
||||||
|
|
||||||
If you want to write a grammar that is portable to any Standard C
|
If you want to write a grammar that is portable to any Standard C
|
||||||
host, you must use only non-null character tokens taken from the basic
|
host, you must use only nonnull character tokens taken from the basic
|
||||||
execution character set of Standard C@. This set consists of the ten
|
execution character set of Standard C@. This set consists of the ten
|
||||||
digits, the 52 lower- and upper-case English letters, and the
|
digits, the 52 lower- and upper-case English letters, and the
|
||||||
characters in the following C-language string:
|
characters in the following C-language string:
|
||||||
@@ -3813,7 +3813,7 @@ For instance, if your locations use a file name, you may use
|
|||||||
During error recovery (@pxref{Error Recovery}), symbols already pushed
|
During error recovery (@pxref{Error Recovery}), symbols already pushed
|
||||||
on the stack and tokens coming from the rest of the file are discarded
|
on the stack and tokens coming from the rest of the file are discarded
|
||||||
until the parser falls on its feet. If the parser runs out of memory,
|
until the parser falls on its feet. If the parser runs out of memory,
|
||||||
or if the parsing is cut by @code{YYACCEPT} or @code{YYABORT}, all the
|
or if it returns via @code{YYABORT} or @code{YYACCEPT}, all the
|
||||||
symbols on the stack must be discarded. Even if the parser succeeds, it
|
symbols on the stack must be discarded. Even if the parser succeeds, it
|
||||||
must discard the start symbol.
|
must discard the start symbol.
|
||||||
|
|
||||||
@@ -3862,16 +3862,18 @@ stacked symbols popped during the first phase of error recovery,
|
|||||||
incoming terminals during the second phase of error recovery,
|
incoming terminals during the second phase of error recovery,
|
||||||
@item
|
@item
|
||||||
the current look-ahead and the entire stack (except the current
|
the current look-ahead and the entire stack (except the current
|
||||||
right-hand side symbols) when the parser aborts (either via an explicit
|
right-hand side symbols) when the parser returns immediately, and
|
||||||
call to @code{YYABORT} or @code{YYACCEPT}, or as a consequence of a
|
|
||||||
failed error recovery or of memory exhaustion), and
|
|
||||||
@item
|
@item
|
||||||
the start symbol, when the parser succeeds.
|
the start symbol, when the parser succeeds.
|
||||||
@end itemize
|
@end itemize
|
||||||
|
|
||||||
Note that right-hand size symbols of a rule that explicitly triggers a
|
The parser can @dfn{return immediately} because of an explicit call to
|
||||||
syntax error via @code{YYERROR} are not reclaimed. As a thumb rule,
|
@code{YYABORT} or @code{YYACCEPT}, or failed error recovery, or memory
|
||||||
destructors are invoked only when you do not have other means to manage
|
exhaustion.
|
||||||
|
|
||||||
|
Right-hand size symbols of a rule that explicitly triggers a syntax
|
||||||
|
error via @code{YYERROR} are not discarded automatically. As a rule
|
||||||
|
of thumb, destructors are invoked only when user actions cannot manage
|
||||||
the memory.
|
the memory.
|
||||||
|
|
||||||
@node Expect Decl
|
@node Expect Decl
|
||||||
@@ -3959,8 +3961,8 @@ may override this restriction with the @code{%start} declaration as follows:
|
|||||||
A @dfn{reentrant} program is one which does not alter in the course of
|
A @dfn{reentrant} program is one which does not alter in the course of
|
||||||
execution; in other words, it consists entirely of @dfn{pure} (read-only)
|
execution; in other words, it consists entirely of @dfn{pure} (read-only)
|
||||||
code. Reentrancy is important whenever asynchronous execution is possible;
|
code. Reentrancy is important whenever asynchronous execution is possible;
|
||||||
for example, a non-reentrant program may not be safe to call from a signal
|
for example, a nonreentrant program may not be safe to call from a signal
|
||||||
handler. In systems with multiple threads of control, a non-reentrant
|
handler. In systems with multiple threads of control, a nonreentrant
|
||||||
program must be called only within interlocks.
|
program must be called only within interlocks.
|
||||||
|
|
||||||
Normally, Bison generates a parser which is not reentrant. This is
|
Normally, Bison generates a parser which is not reentrant. This is
|
||||||
@@ -4450,7 +4452,7 @@ The @code{yytname} table is generated only if you use the
|
|||||||
@subsection Semantic Values of Tokens
|
@subsection Semantic Values of Tokens
|
||||||
|
|
||||||
@vindex yylval
|
@vindex yylval
|
||||||
In an ordinary (non-reentrant) parser, the semantic value of the token must
|
In an ordinary (nonreentrant) parser, the semantic value of the token must
|
||||||
be stored into the global variable @code{yylval}. When you are using
|
be stored into the global variable @code{yylval}. When you are using
|
||||||
just one data type for semantic values, @code{yylval} has that type.
|
just one data type for semantic values, @code{yylval} has that type.
|
||||||
Thus, if the type is @code{int} (the default), you might write this in
|
Thus, if the type is @code{int} (the default), you might write this in
|
||||||
@@ -5610,7 +5612,7 @@ pp.@: 615--649 @uref{http://doi.acm.org/10.1145/69622.357187}.
|
|||||||
@cindex @acronym{GLR} parsing
|
@cindex @acronym{GLR} parsing
|
||||||
@cindex generalized @acronym{LR} (@acronym{GLR}) parsing
|
@cindex generalized @acronym{LR} (@acronym{GLR}) parsing
|
||||||
@cindex ambiguous grammars
|
@cindex ambiguous grammars
|
||||||
@cindex non-deterministic parsing
|
@cindex nondeterministic parsing
|
||||||
|
|
||||||
Bison produces @emph{deterministic} parsers that choose uniquely
|
Bison produces @emph{deterministic} parsers that choose uniquely
|
||||||
when to reduce and which reduction to apply
|
when to reduce and which reduction to apply
|
||||||
@@ -5675,10 +5677,10 @@ quadratic worst-case time, and any general (possibly ambiguous)
|
|||||||
context-free grammar in cubic worst-case time. However, Bison currently
|
context-free grammar in cubic worst-case time. However, Bison currently
|
||||||
uses a simpler data structure that requires time proportional to the
|
uses a simpler data structure that requires time proportional to the
|
||||||
length of the input times the maximum number of stacks required for any
|
length of the input times the maximum number of stacks required for any
|
||||||
prefix of the input. Thus, really ambiguous or non-deterministic
|
prefix of the input. Thus, really ambiguous or nondeterministic
|
||||||
grammars can require exponential time and space to process. Such badly
|
grammars can require exponential time and space to process. Such badly
|
||||||
behaving examples, however, are not generally of practical interest.
|
behaving examples, however, are not generally of practical interest.
|
||||||
Usually, non-determinism in a grammar is local---the parser is ``in
|
Usually, nondeterminism in a grammar is local---the parser is ``in
|
||||||
doubt'' only for a few tokens at a time. Therefore, the current data
|
doubt'' only for a few tokens at a time. Therefore, the current data
|
||||||
structure should generally be adequate. On @acronym{LALR}(1) portions of a
|
structure should generally be adequate. On @acronym{LALR}(1) portions of a
|
||||||
grammar, in particular, it is only slightly slower than with the default
|
grammar, in particular, it is only slightly slower than with the default
|
||||||
@@ -7037,7 +7039,7 @@ The output files @file{@var{output}.hh} and @file{@var{output}.cc}
|
|||||||
declare and define the parser class in the namespace @code{yy}. The
|
declare and define the parser class in the namespace @code{yy}. The
|
||||||
class name defaults to @code{parser}, but may be changed using
|
class name defaults to @code{parser}, but may be changed using
|
||||||
@samp{%define "parser_class_name" "@var{name}"}. The interface of
|
@samp{%define "parser_class_name" "@var{name}"}. The interface of
|
||||||
this class is detailled below. It can be extended using the
|
this class is detailed below. It can be extended using the
|
||||||
@code{%parse-param} feature: its semantics is slightly changed since
|
@code{%parse-param} feature: its semantics is slightly changed since
|
||||||
it describes an additional member of the parser class, and an
|
it describes an additional member of the parser class, and an
|
||||||
additional argument for its constructor.
|
additional argument for its constructor.
|
||||||
@@ -7065,7 +7067,7 @@ Get or set the stream used for tracing the parsing. It defaults to
|
|||||||
@deftypemethod {parser} {debug_level_type} debug_level ()
|
@deftypemethod {parser} {debug_level_type} debug_level ()
|
||||||
@deftypemethodx {parser} {void} set_debug_level (debug_level @var{l})
|
@deftypemethodx {parser} {void} set_debug_level (debug_level @var{l})
|
||||||
Get or set the tracing level. Currently its value is either 0, no trace,
|
Get or set the tracing level. Currently its value is either 0, no trace,
|
||||||
or non-zero, full tracing.
|
or nonzero, full tracing.
|
||||||
@end deftypemethod
|
@end deftypemethod
|
||||||
|
|
||||||
@deftypemethod {parser} {void} error (const location_type& @var{l}, const std::string& @var{m})
|
@deftypemethod {parser} {void} error (const location_type& @var{l}, const std::string& @var{m})
|
||||||
@@ -7116,7 +7118,7 @@ actually easier to interface with.
|
|||||||
@subsection Calc++ --- C++ Calculator
|
@subsection Calc++ --- C++ Calculator
|
||||||
|
|
||||||
Of course the grammar is dedicated to arithmetics, a single
|
Of course the grammar is dedicated to arithmetics, a single
|
||||||
expression, possibily preceded by variable assignments. An
|
expression, possibly preceded by variable assignments. An
|
||||||
environment containing possibly predefined variables such as
|
environment containing possibly predefined variables such as
|
||||||
@code{one} and @code{two}, is exchanged with the parser. An example
|
@code{one} and @code{two}, is exchanged with the parser. An example
|
||||||
of valid input follows.
|
of valid input follows.
|
||||||
@@ -7411,7 +7413,7 @@ The grammar itself is straightforward.
|
|||||||
unit: assignments exp @{ driver.result = $2; @};
|
unit: assignments exp @{ driver.result = $2; @};
|
||||||
|
|
||||||
assignments: assignments assignment @{@}
|
assignments: assignments assignment @{@}
|
||||||
| /* Nothing. */ @{@};
|
| /* Nothing. */ @{@};
|
||||||
|
|
||||||
assignment: "identifier" ":=" exp @{ driver.variables[*$1] = $3; @};
|
assignment: "identifier" ":=" exp @{ driver.variables[*$1] = $3; @};
|
||||||
|
|
||||||
@@ -7480,7 +7482,7 @@ blank [ \t]
|
|||||||
@end example
|
@end example
|
||||||
|
|
||||||
@noindent
|
@noindent
|
||||||
The following paragraph suffices to track locations acurately. Each
|
The following paragraph suffices to track locations accurately. Each
|
||||||
time @code{yylex} is invoked, the begin position is moved onto the end
|
time @code{yylex} is invoked, the begin position is moved onto the end
|
||||||
position. Then when a pattern is matched, the end position is
|
position. Then when a pattern is matched, the end position is
|
||||||
advanced of its width. In case it matched ends of lines, the end
|
advanced of its width. In case it matched ends of lines, the end
|
||||||
@@ -7505,7 +7507,7 @@ preceding tokens. Comments would be treated equally.
|
|||||||
The rules are simple, just note the use of the driver to report errors.
|
The rules are simple, just note the use of the driver to report errors.
|
||||||
It is convenient to use a typedef to shorten
|
It is convenient to use a typedef to shorten
|
||||||
@code{yy::calcxx_parser::token::identifier} into
|
@code{yy::calcxx_parser::token::identifier} into
|
||||||
@code{token::identifier} for isntance.
|
@code{token::identifier} for instance.
|
||||||
|
|
||||||
@comment file: calc++-scanner.ll
|
@comment file: calc++-scanner.ll
|
||||||
@example
|
@example
|
||||||
@@ -7949,7 +7951,7 @@ parser file. @xref{Decl Summary}.
|
|||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
@deffn {Directive} %nonassoc
|
@deffn {Directive} %nonassoc
|
||||||
Bison declaration to assign non-associativity to token(s).
|
Bison declaration to assign nonassociativity to token(s).
|
||||||
@xref{Precedence Decl, ,Operator Precedence}.
|
@xref{Precedence Decl, ,Operator Precedence}.
|
||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
|
|||||||
@@ -231,7 +231,7 @@ yyerror (ERROR_PARAMETERS)
|
|||||||
static Node *
|
static Node *
|
||||||
new_nterm (char const *form, Node *child0, Node *child1, Node *child2)
|
new_nterm (char const *form, Node *child0, Node *child1, Node *child2)
|
||||||
{
|
{
|
||||||
Node *node = malloc (sizeof (Node));
|
Node *node = (Node *) malloc (sizeof (Node));
|
||||||
node->nterm.type = 1;
|
node->nterm.type = 1;
|
||||||
node->nterm.parents = 0;
|
node->nterm.parents = 0;
|
||||||
node->nterm.form = form;
|
node->nterm.form = form;
|
||||||
@@ -250,7 +250,7 @@ new_nterm (char const *form, Node *child0, Node *child1, Node *child2)
|
|||||||
static Node *
|
static Node *
|
||||||
new_term (char *text)
|
new_term (char *text)
|
||||||
{
|
{
|
||||||
Node *node = malloc (sizeof (Node));
|
Node *node = (Node *) malloc (sizeof (Node));
|
||||||
node->term.type = 0;
|
node->term.type = 0;
|
||||||
node->term.parents = 0;
|
node->term.parents = 0;
|
||||||
node->term.text = text;
|
node->term.text = text;
|
||||||
@@ -286,7 +286,7 @@ node_to_string (Node *node)
|
|||||||
char *buffer;
|
char *buffer;
|
||||||
if (!node)
|
if (!node)
|
||||||
{
|
{
|
||||||
buffer = malloc (1);
|
buffer = (char *) malloc (1);
|
||||||
buffer[0] = 0;
|
buffer[0] = 0;
|
||||||
}
|
}
|
||||||
else if (node->node_info.type == 1)
|
else if (node->node_info.type == 1)
|
||||||
@@ -294,8 +294,8 @@ node_to_string (Node *node)
|
|||||||
child0 = node_to_string (node->nterm.children[0]);
|
child0 = node_to_string (node->nterm.children[0]);
|
||||||
child1 = node_to_string (node->nterm.children[1]);
|
child1 = node_to_string (node->nterm.children[1]);
|
||||||
child2 = node_to_string (node->nterm.children[2]);
|
child2 = node_to_string (node->nterm.children[2]);
|
||||||
buffer = malloc (strlen (node->nterm.form) + strlen (child0)
|
buffer = (char *) malloc (strlen (node->nterm.form) + strlen (child0)
|
||||||
+ strlen (child1) + strlen (child2) + 1);
|
+ strlen (child1) + strlen (child2) + 1);
|
||||||
sprintf (buffer, node->nterm.form, child0, child1, child2);
|
sprintf (buffer, node->nterm.form, child0, child1, child2);
|
||||||
free (child0);
|
free (child0);
|
||||||
free (child1);
|
free (child1);
|
||||||
|
|||||||
Reference in New Issue
Block a user