]> git.donarmstrong.com Git - lilypond.git/commitdiff
lexer.ll: add $ for immediate export.
authorDavid Kastrup <dak@gnu.org>
Sun, 6 Nov 2011 11:08:45 +0000 (12:08 +0100)
committerDavid Kastrup <dak@gnu.org>
Thu, 10 Nov 2011 20:15:46 +0000 (21:15 +0100)
lily/include/lily-lexer.hh
lily/lexer.ll

index 54e068ee7afb3a8a8e8e3263c070ba13ae75e582..2de3827443c5c0e63f6eeeb66d3af8666175bdc7 100644 (file)
@@ -53,6 +53,7 @@ private:
   int scan_bare_word (string);
   SCM scan_markup_word (string);
   int scan_escaped_word (string);
+  int scan_scm_id (SCM);
   int identifier_type (SCM);
   char escaped_char (char) const;
 
index 5619eea47fa5101e8ecbd48921cd7c54ec4024be..59284d07c39be8b50715bb54f85a847c5fb58e0e 100644 (file)
@@ -383,6 +383,32 @@ BOM_UTF8   \357\273\277
        yylval.scm = sval;
        return SCM_TOKEN;
 }
+
+<INITIAL,chords,figures,lyrics,markup,notes>\$ { //immediate scm
+       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_);
+
+       for (int i = 0; i < n; i++)
+       {
+               yyinput ();
+       }
+       char_count_stack_.back () += n;
+
+       if (sval == SCM_UNDEFINED)
+       {
+               yylval.scm = SCM_UNSPECIFIED;
+               error_level_ = 1;
+
+               LexerError (_ ("bad Scheme expression").c_str ());
+               return SCM_IDENTIFIER;
+       }
+
+       return scan_scm_id (sval);
+}
+
 <INITIAL,notes,lyrics>{ 
        \<\<    {
                return DOUBLE_ANGLE_OPEN;
@@ -598,7 +624,7 @@ BOM_UTF8    \357\273\277
        [{}]    {
                return YYText ()[0];
        }
-       [^#{}\"\\ \t\n\r\f]+ {
+       [^$#{}\"\\ \t\n\r\f]+ {
                string s (YYText ()); 
 
                char c = s[s.length () - 1];
@@ -799,6 +825,20 @@ Lily_lexer::scan_escaped_word (string str)
                return i;
 
        SCM sid = lookup_identifier (str);
+       if (sid != SCM_UNDEFINED)
+               return scan_scm_id (sid);
+
+       string msg (_f ("unknown escaped string: `\\%s'", str));        
+       LexerError (msg.c_str ());
+
+       yylval.scm = ly_string2scm (str);
+
+       return STRING;
+}
+
+int
+Lily_lexer::scan_scm_id (SCM sid)
+{
        if (is_music_function (sid))
        {
                int funtype = SCM_FUNCTION;
@@ -849,19 +889,8 @@ Lily_lexer::scan_escaped_word (string str)
                }
                return funtype;
        }
-
-       if (sid != SCM_UNDEFINED)
-       {
-               yylval.scm = sid;
-               return identifier_type (sid);
-       }
-
-       string msg (_f ("unknown escaped string: `\\%s'", str));        
-       LexerError (msg.c_str ());
-
-       yylval.scm = ly_string2scm (str);
-
-       return STRING;
+       yylval.scm = sid;
+       return identifier_type (sid);
 }
 
 int