* data/lalr1.cc: Adjust the indentation of the labels.

Use it.
This commit is contained in:
Akim Demaille
2004-09-06 14:32:05 +00:00
parent a0e68930d8
commit 52d5733ff0
2 changed files with 25 additions and 16 deletions

View File

@@ -1,3 +1,9 @@
2004-09-06 Akim Demaille <akim@epita.fr>
* data/lalr1.cc: Adjust the indentation of the labels.
(Parser::pop): New.
Use it.
2004-09-06 Akim Demaille <akim@epita.fr> 2004-09-06 Akim Demaille <akim@epita.fr>
* data/yacc.cc, data/glr.cc (yydestruct): Accept an additional * data/yacc.cc, data/glr.cc (yydestruct): Accept an additional

View File

@@ -284,6 +284,9 @@ namespace yy
int yytype, int yytype,
SemanticType *yyvaluep, LocationType *yylocationp); SemanticType *yyvaluep, LocationType *yylocationp);
/// Pop \a n symbols the three stacks.
inline void pop (unsigned int n = 1);
/* Constants. */ /* Constants. */
static const int eof_; static const int eof_;
/* LAST_ -- Last index in TABLE_. */ /* LAST_ -- Last index in TABLE_. */
@@ -428,6 +431,14 @@ yy::]b4_parser_class_name[::destruct_ (const char *yymsg,
} }
} }
void
yy::]b4_parser_class_name[::pop (unsigned int n)
{
state_stack_.pop (n);
semantic_stack_.pop (n);
location_stack_.pop (n);
}
int int
yy::]b4_parser_class_name[::parse () yy::]b4_parser_class_name[::parse ()
{ {
@@ -451,13 +462,13 @@ yy::]b4_parser_class_name[::parse ()
YYCDEBUG << "Starting parse" << std::endl; YYCDEBUG << "Starting parse" << std::endl;
/* New state. */ /* New state. */
yynewstate: yynewstate:
state_stack_.push (state_); state_stack_.push (state_);
YYCDEBUG << "Entering state " << state_ << std::endl; YYCDEBUG << "Entering state " << state_ << std::endl;
goto yybackup; goto yybackup;
/* Backup. */ /* Backup. */
yybackup: yybackup:
/* Try to take a decision without look-ahead. */ /* Try to take a decision without look-ahead. */
n_ = pact_[state_]; n_ = pact_[state_];
@@ -532,7 +543,7 @@ yy::]b4_parser_class_name[::parse ()
/*-----------------------------------------------------------. /*-----------------------------------------------------------.
| yydefault -- do the default action for the current state. | | yydefault -- do the default action for the current state. |
`-----------------------------------------------------------*/ `-----------------------------------------------------------*/
yydefault: yydefault:
n_ = defact_[state_]; n_ = defact_[state_];
if (n_ == 0) if (n_ == 0)
goto yyerrlab; goto yyerrlab;
@@ -541,7 +552,7 @@ yy::]b4_parser_class_name[::parse ()
/*-----------------------------. /*-----------------------------.
| yyreduce -- Do a reduction. | | yyreduce -- Do a reduction. |
`-----------------------------*/ `-----------------------------*/
yyreduce: yyreduce:
len_ = r2_[n_]; len_ = r2_[n_];
/* If LEN_ is nonzero, implement the default value of the action: /* If LEN_ is nonzero, implement the default value of the action:
`$$ = $1'. Otherwise, use the top of the stack. `$$ = $1'. Otherwise, use the top of the stack.
@@ -574,9 +585,7 @@ yy::]b4_parser_class_name[::parse ()
]/* Line __line__ of lalr1.cc. */ ]/* Line __line__ of lalr1.cc. */
b4_syncline([@oline@], [@ofile@])[ b4_syncline([@oline@], [@ofile@])[
state_stack_.pop (len_); pop (len_);
semantic_stack_.pop (len_);
location_stack_.pop (len_);
YY_STACK_PRINT (); YY_STACK_PRINT ();
@@ -614,9 +623,7 @@ yyerrlab:
for (;;) for (;;)
{ {
error_start_ = location_stack_[0].begin; error_start_ = location_stack_[0].begin;
state_stack_.pop (); pop ();
semantic_stack_.pop ();
location_stack_.pop ();
if (state_stack_.height () == 1) if (state_stack_.height () == 1)
YYABORT; YYABORT;
destruct_ ("Error: popping", destruct_ ("Error: popping",
@@ -649,10 +656,8 @@ yyerrorlab:
goto yyerrorlab; goto yyerrorlab;
#endif #endif
state_stack_.pop (len_);
semantic_stack_.pop (len_);
error_start_ = location_stack_[len_ - 1].begin; error_start_ = location_stack_[len_ - 1].begin;
location_stack_.pop (len_); pop (len_);
state_ = state_stack_[0]; state_ = state_stack_[0];
goto yyerrlab1; goto yyerrlab1;
@@ -684,9 +689,7 @@ yyerrlab1:
stos_[state_], &semantic_stack_[0], &location_stack_[0]); stos_[state_], &semantic_stack_[0], &location_stack_[0]);
error_start_ = location_stack_[0].begin; error_start_ = location_stack_[0].begin;
state_stack_.pop (); pop ();
semantic_stack_.pop ();
location_stack_.pop ();
state_ = state_stack_[0]; state_ = state_stack_[0];
YY_STACK_PRINT (); YY_STACK_PRINT ();
} }