Reviewers: Trevor Daniels,
http://codereview.appspot.com/6460064/diff/4001/lily/lily-parser.cc
File lily/lily-parser.cc (right):
http://codereview.appspot.com/6460064/diff/4001/lily/lily-parser.cc#newcode160
lily/lily-parser.cc:160: // TODO: use $parser
On 2012/08/10 06:58:57, Trevor Daniels wrote:
Either this comment should be removed, or the
earlier one should be left in. Sorry, I don't
understand enough of this to know which.
There is not enough context to figure out what the author of the comment
was aiming for. That's why I took the other comment out. Will remove
this one as well but not submit a separate review.
Description:
When cloning a lexer/parser, don't copy the scopes.
Please review this at http://codereview.appspot.com/6460064/
Affected files:
M lily/lily-lexer.cc
M lily/lily-parser.cc
Index: lily/lily-lexer.cc
diff --git a/lily/lily-lexer.cc b/lily/lily-lexer.cc
index
71533da70097be00cee89644726d26e5d2e21d7e..39aeb78dd14c0fe9cd9bce93f50cb365f748e5c3
100644
--- a/lily/lily-lexer.cc
+++ b/lily/lily-lexer.cc
@@ -113,27 +113,16 @@ Lily_lexer::Lily_lexer (Lily_lexer const &src,
Lily_parser *parser)
chordmodifier_tab_ = src.chordmodifier_tab_;
pitchname_tab_stack_ = src.pitchname_tab_stack_;
sources_ = src.sources_;
+ scopes_ = src.scopes_;
start_module_ = SCM_EOL;
error_level_ = 0;
is_main_input_ = src.is_main_input_;
- scopes_ = SCM_EOL;
extra_tokens_ = SCM_EOL;
smobify_self ();
- SCM scopes = SCM_EOL;
- SCM *tail = &scopes;
- for (SCM s = src.scopes_; scm_is_pair (s); s = scm_cdr (s))
- {
- SCM newmod = ly_make_module (false);
- ly_module_copy (newmod, scm_car (s));
- *tail = scm_cons (newmod, SCM_EOL);
- tail = SCM_CDRLOC (*tail);
- }
-
- scopes_ = scopes;
push_note_state (SCM_EOL);
}
Index: lily/lily-parser.cc
diff --git a/lily/lily-parser.cc b/lily/lily-parser.cc
index
cec4893d8db0b9cab96c0404e34cecf088bf28c7..4120e8419794e8ee546336c7e4bedac21af18453
100644
--- a/lily/lily-parser.cc
+++ b/lily/lily-parser.cc
@@ -139,16 +139,15 @@ Lily_parser::parse_file (string init, string name,
string out_name)
void
Lily_parser::parse_string (string ly_code)
{
- // TODO: use $parser
- lexer_->set_identifier (ly_symbol2scm ("parser"),
- self_scm ());
-
lexer_->main_input_name_ = "<string>";
lexer_->is_main_input_ = true;
lexer_->new_input (lexer_->main_input_name_, ly_code, sources_);
SCM mod = lexer_->set_current_scope ();
+ SCM parser = lexer_->lookup_identifier_symbol (ly_symbol2scm ("parser"));
+ lexer_->set_identifier (ly_symbol2scm ("parser"), self_scm ());
do_yyparse ();
+ lexer_->set_identifier (ly_symbol2scm ("parser"), parser);
scm_set_current_module (mod);
error_level_ = error_level_ | lexer_->error_level_;
@@ -159,8 +158,6 @@ Lily_parser::parse_string_expression (string ly_code,
string filename,
int line)
{
// TODO: use $parser
- lexer_->set_identifier (ly_symbol2scm ("parser"),
- self_scm ());
lexer_->main_input_name_ = filename;
lexer_->is_main_input_ = true;
@@ -170,11 +167,14 @@ Lily_parser::parse_string_expression (string ly_code,
string filename,
lexer_->get_source_file ()->set_line (0, line);
}
SCM mod = lexer_->set_current_scope ();
+ SCM parser = lexer_->lookup_identifier_symbol (ly_symbol2scm ("parser"));
+ lexer_->set_identifier (ly_symbol2scm ("parser"), self_scm ());
lexer_->push_extra_token (EMBEDDED_LILY);
do_yyparse ();
SCM result = lexer_->lookup_identifier_symbol (ly_symbol2scm
("parseStringResult"));
// parseStringResult is set in the grammar rule for embedded_lilypond
+ lexer_->set_identifier (ly_symbol2scm ("parser"), parser);
scm_set_current_module (mod);
error_level_ = error_level_ | lexer_->error_level_;
_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-devel