]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/lexer.ll
Fix some bugs in the dynamic engraver and PostScript backend
[lilypond.git] / lily / lexer.ll
index 98332a1eb3679fe26fb07d619ed37a2c90f1b9f1..d69dbb5ffde1e825a8356408e829a96749a0979e 100644 (file)
@@ -112,7 +112,6 @@ SCM (* scm_parse_error_handler) (void *);
 %x markup
 %x notes
 %x quote
-%x sourcefileline
 %x sourcefilename
 %x version
 
@@ -180,33 +179,22 @@ BOM_UTF8  \357\273\277
   }
 }
 
-<INITIAL,notes,figures,chords,markup>{
-       \"              {
-               start_quote ();
-       }
-}
-
 <INITIAL,chords,lyrics,notes,figures>\\version{WHITE}* {
        yy_push_state (version);
 }
 <INITIAL,chords,lyrics,notes,figures>\\sourcefilename{WHITE}*  {
        yy_push_state (sourcefilename);
 }
-<INITIAL,chords,lyrics,notes,figures>\\sourcefileline{WHITE}*  {
-       yy_push_state (sourcefileline);
-}
 <version>\"[^"]*\"     { /* got the version number */
        string s (YYText () + 1);
        s = s.substr (0, s.rfind ('\"'));
 
        yy_pop_state ();
-
-       SCM top_scope = scm_car (scm_last_pair (scopes_));
-       scm_module_define (top_scope, ly_symbol2scm ("version-seen"), SCM_BOOL_T);
-
        if (!is_valid_version (s))
                return INVALID;
 
+       SCM top_scope = scm_car (scm_last_pair (scopes_));
+       scm_module_define (top_scope, ly_symbol2scm ("version-seen?"), SCM_BOOL_T);
 
 }
 <sourcefilename>\"[^"]*\"     {
@@ -222,15 +210,6 @@ BOM_UTF8   \357\273\277
                     scm_makfrom0str (s.c_str ()));
 
 }
-
-<sourcefileline>{INT}  {
-       int i;
-       sscanf (YYText (), "%d", &i);
-
-       yy_pop_state ();
-       this->here_input ().get_source_file ()->set_line (here_input ().start (), i);
-}
-
 <version>.     {
        LexerError (_ ("quoted string expected after \\version").c_str ());
        yy_pop_state ();
@@ -239,10 +218,6 @@ BOM_UTF8   \357\273\277
        LexerError (_ ("quoted string expected after \\sourcefilename").c_str ());
        yy_pop_state ();
 }
-<sourcefileline>.      {
-       LexerError (_ ("integer expected after \\sourcefileline").c_str ());
-       yy_pop_state ();
-}
 <longcomment>{
        [^\%]*          {
        }
@@ -338,26 +313,16 @@ BOM_UTF8  \357\273\277
        }
                
        yylval.scm = sval;
-       return SCM_TOKEN;
+       return SCM_T;
 }
 <INITIAL,notes,lyrics>{ 
-       \<\<    {
+       \<\<   {
                return DOUBLE_ANGLE_OPEN;
        }
-       \>\>    {
+       \>\>   {
                return DOUBLE_ANGLE_CLOSE;
        }
 }
-
-<INITIAL,notes>{
-       \<      {
-               return ANGLE_OPEN;
-       }
-       \>      {
-               return ANGLE_CLOSE;
-       }
-}
-
 <figures>{
        _       {
                return FIGURE_SPACE;
@@ -395,9 +360,36 @@ BOM_UTF8   \357\273\277
                yylval.i = String_convert::dec2int (string (YYText () +1));
                return E_UNSIGNED;
        }
+       \" {
+               start_quote ();
+       }
+}
+
+\"             {
+       start_quote ();
 }
+<quote>{
+       \\{ESCAPED}     {
+               *yylval.string += to_string (escaped_char (YYText ()[1]));
+       }
+       [^\\"]+ {
+               *yylval.string += YYText ();
+       }
+       \"      {
 
-<quote,lyric_quote>{
+               yy_pop_state ();
+
+               /* yylval is union. Must remember STRING before setting SCM*/
+               string *sp = yylval.string;
+               yylval.scm = scm_makfrom0str (sp->c_str ());
+               delete sp;
+               return STRING;
+       }
+       .       {
+               *yylval.string += YYText ();
+       }
+}
+<lyric_quote>{
        \\{ESCAPED}     {
                *yylval.string += to_string (escaped_char (YYText ()[1]));
        }
@@ -412,7 +404,7 @@ BOM_UTF8    \357\273\277
                string *sp = yylval.string;
                yylval.scm = scm_makfrom0str (sp->c_str ());
                delete sp;
-               return is_lyric_state () ? LYRICS_STRING : STRING;
+               return LYRICS_STRING;
        }
        .       {
                *yylval.string += YYText ();
@@ -471,6 +463,9 @@ BOM_UTF8    \357\273\277
                yylval.i = String_convert::dec2int (string (YYText ()));
                return UNSIGNED;
        }
+       \" {
+               start_quote ();
+       }
        -  {
                return CHORD_MINUS;
        }
@@ -493,6 +488,9 @@ BOM_UTF8    \357\273\277
 
 
 <markup>{
+       \" {
+               start_quote ();
+       }
        \\score {
                return SCORE;
        }
@@ -912,7 +910,7 @@ static void init_signature_hash_table ()
        };
 
        for (int i = 0; sigs[i].symbol; i++)
-               scm_hashq_set_x (signature_hash_table, ly_symbol2scm (sigs[i].symbol),
+               scm_hashq_set_x (signature_hash_table, scm_gc_protect_object (ly_symbol2scm (sigs[i].symbol)),
                                 scm_from_int (sigs[i].token_type));
 }