]> git.donarmstrong.com Git - lilypond.git/commitdiff
don't allow ly:parser-parse-string to continue unless the parser is fresh
authorBenjamin Peterson <benjamin@python.org>
Wed, 11 Aug 2010 19:15:55 +0000 (14:15 -0500)
committerNeil Puttock <n.puttock@gmail.com>
Thu, 26 Aug 2010 22:17:19 +0000 (23:17 +0100)
lily/include/lily-lexer.hh
lily/lily-lexer.cc
lily/lily-parser-scheme.cc

index f2491864ea95552ca832b957cd64fc9c5249cd16..a7d697d482d772c7f17af100713c7768d8bcef70 100644 (file)
@@ -116,6 +116,7 @@ public:
   bool is_chord_state () const;
   bool is_lyric_state () const;
   bool is_figure_state () const;
+  bool is_clean () const;
 };
 
 #endif /* MY_LILY_LEXER_HH */
index 5a34d60bbe5146bcd6a14c4d4b32057bbda2c7af..3b9a3882b19158170de3132cf7088f10b98e9a65 100644 (file)
@@ -391,3 +391,9 @@ Lily_lexer::print_smob (SCM s, SCM port, scm_print_state*)
   scm_puts (" >", port);
   return 1;
 }
+
+bool
+Lily_lexer::is_clean () const
+{
+  return include_stack_.empty ();
+}
index 2b968b46c00c124baef36f283771d31705c6784c..2f9a910ccf917518ca40707403f74122f3e034ec 100644 (file)
@@ -200,7 +200,11 @@ LY_DEFINE (ly_parser_parse_string, "ly:parser-parse-string",
   Lily_parser *parser = unsmob_lily_parser (parser_smob);
   LY_ASSERT_TYPE (scm_is_string, ly_code, 2);
 
-  parser->parse_string (ly_scm2string (ly_code));
+  if (!parser->lexer_->is_clean ())
+    parser->parser_error (_ ("ly:parser-parse-string is only valid with a new parser."
+                            "  Use ly:parser-include-string instead."));
+  else
+    parser->parse_string (ly_scm2string (ly_code));
 
   return SCM_UNSPECIFIED;
 }