lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: lexer.ll: Allow include file names to be specified as Scheme express


From: dak
Subject: Re: lexer.ll: Allow include file names to be specified as Scheme expression (issue 5369104)
Date: Wed, 16 Nov 2011 10:26:17 +0000

Reviewers: J_lowe,

Message:
Previous patch set was done with a different base, so the diffs stopped
making sense.  Removed it.  Just the current patch set against staging
(hopefully soon master) remains.

Description:
lexer.ll: Allow include file names to be specified as Scheme expression

Fixes a regression reported on the mailing lists.

<http://permalink.gmane.org/gmane.comp.gnu.lilypond.general/67675>

Please review this at http://codereview.appspot.com/5369104/

Affected files:
  M lily/lexer.ll


Index: lily/lexer.ll
diff --git a/lily/lexer.ll b/lily/lexer.ll
index 1a79dbdec85fe943fa7137c0f5ec3931ad18ce4c..32fa5f2b6876cf9bec0fed5ba2a2b2576504180e 100644
--- a/lily/lexer.ll
+++ b/lily/lexer.ll
@@ -311,7 +311,7 @@ BOM_UTF8    \357\273\277
 <INITIAL,chords,lyrics,figures,notes>\\include           {
        yy_push_state (incl);
 }
-<incl>\"[^"]*\"   { /* got the include file name */
+<incl>\"[^""]*\"   { /* got the include file name */
        string s (YYText ()+1);
        s = s.substr (0, s.rfind ('"'));

@@ -328,7 +328,7 @@ BOM_UTF8    \357\273\277
        if (scm_is_string (sid)) {
                new_input (ly_scm2string (sid), sources_);
                yy_pop_state ();
-       } else {
+       } else {
            string msg (_f ("wrong or undefined identifier: `%s'", s ));

            LexerError (msg.c_str ());
@@ -337,7 +337,34 @@ BOM_UTF8   \357\273\277
            scm_display (sid, err);
          }
 }
-<incl,version,sourcefilename>\"[^"]*   { // backup rule
+<incl>(\$|#) { // scm for the filename
+       int n = 0;
+       Input hi = here_input();
+       hi.step_forward ();
+       SCM sval = ly_parse_scm (hi.start (), &n, hi,
+               be_safe_global && is_main_input_, parser_);
+       sval = eval_scm (sval);
+
+       for (int i = 0; i < n; i++)
+       {
+               yyinput ();
+       }
+       char_count_stack_.back () += n;
+
+       if (scm_is_string (sval)) {
+               new_input (ly_scm2string (sval), sources_);
+               yy_pop_state ();
+       } else {
+               LexerError (_ ("string expected after \\include").c_str ());
+               if (sval != SCM_UNDEFINED) {
+                       SCM err = scm_current_error_port ();
+                       scm_puts ("This value was found instead: ", err);
+                       scm_display (sval, err);
+               }
+       }
+}
+
+<incl,version,sourcefilename>\"[^""]*   { // backup rule
        error (_ ("end quote missing"));
        exit (1);
 }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]