]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/lexer.ll
Merge branch 'issue4032'
[lilypond.git] / lily / lexer.ll
index 51a33fbb4b2a57b446ef954c4af9c1b962f27003..8b0859630ec04dcd0ea9c0a5fd1b3a1d0ad61843 100644 (file)
@@ -2,7 +2,7 @@
 /*
   This file is part of LilyPond, the GNU music typesetter.
 
-  Copyright (C) 1996--2012 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  Copyright (C) 1996--2014 Han-Wen Nienhuys <hanwen@xs4all.nl>
                  Jan Nieuwenhuizen <janneke@gnu.org>
 
   LilyPond is free software: you can redistribute it and/or modify
@@ -330,12 +330,11 @@ BOM_UTF8  \357\273\277
          }
 }
 <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);
+       SCM sval = ly_parse_scm (hi, be_safe_global && is_main_input_, parser_);
+       sval = eval_scm (sval, hi);
+       int n = hi.end () - hi.start ();
 
        for (int i = 0; i < n; i++)
        {
@@ -385,15 +384,14 @@ BOM_UTF8  \357\273\277
        return MULTI_MEASURE_REST;
 }
 <INITIAL,chords,figures,lyrics,markup,notes>#  { //embedded 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_);
+       SCM sval = ly_parse_scm (hi, be_safe_global && is_main_input_, parser_);
 
        if (sval == SCM_UNDEFINED)
                error_level_ = 1;
 
+       int n = hi.end () - hi.start ();
        for (int i = 0; i < n; i++)
        {
                yyinput ();
@@ -405,11 +403,11 @@ BOM_UTF8  \357\273\277
 }
 
 <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_);
+       SCM sval = ly_parse_scm (hi, be_safe_global && is_main_input_, parser_);
+
+       int n = hi.end () - hi.start ();
 
        for (int i = 0; i < n; i++)
        {
@@ -417,7 +415,7 @@ BOM_UTF8    \357\273\277
        }
        char_count_stack_.back () += n;
 
-       sval = eval_scm (sval, '$');
+       sval = eval_scm (sval, hi, '$');
 
        int token = scan_scm_id (sval);
        if (!scm_is_eq (yylval, SCM_UNSPECIFIED))
@@ -829,7 +827,7 @@ Lily_lexer::pop_extra_token ()
                return -1;
 
   /* produce requested token */
-       yylloc = *unsmob_input (scm_caar (extra_tokens_));
+       yylloc = *Input::unsmob (scm_caar (extra_tokens_));
        int type = scm_to_int (scm_cadar (extra_tokens_));
        yylval = scm_cddar (extra_tokens_);
        extra_tokens_ = scm_cdr (extra_tokens_);
@@ -916,7 +914,7 @@ Lily_lexer::scan_escaped_word (const string &str)
                return i;
 
        SCM sid = lookup_identifier (str);
-       if (Music *m = unsmob_music (sid))
+       if (Music *m = Music::unsmob (sid))
        {
                m->set_spot (override_input (here_input ()));
        }
@@ -936,7 +934,7 @@ int
 Lily_lexer::scan_shorthand (const string &str)
 {
        SCM sid = lookup_identifier (str);
-       if (Music *m = unsmob_music (sid))
+       if (Music *m = Music::unsmob (sid))
        {
                m->set_spot (override_input (here_input ()));
        }
@@ -1016,7 +1014,7 @@ Lily_lexer::scan_bare_word (const string &str)
                
                if (scm_is_pair (handle)) {
                        yylval = scm_cdr (handle);
-                       if (unsmob_pitch (yylval))
+                       if (Pitch::unsmob (yylval))
                            return (YYSTATE == notes) ? NOTENAME_PITCH : TONICNAME_PITCH;
                        else if (scm_is_symbol (yylval))
                            return DRUM_PITCH;
@@ -1070,14 +1068,14 @@ Lily_lexer::is_figure_state () const
 // this function is private.
 
 SCM
-Lily_lexer::eval_scm (SCM readerdata, char extra_token)
+Lily_lexer::eval_scm (SCM readerdata, Input hi, char extra_token)
 {
        SCM sval = SCM_UNDEFINED;
 
        if (!SCM_UNBNDP (readerdata))
        {
-               sval = ly_eval_scm (scm_car (readerdata),
-                                   *unsmob_input (scm_cdr (readerdata)),
+               sval = ly_eval_scm (readerdata,
+                                   hi,
                                    be_safe_global && is_main_input_,
                                    parser_);
        }
@@ -1098,9 +1096,9 @@ Lily_lexer::eval_scm (SCM readerdata, char extra_token)
                             p = scm_cdr (p))
                        {
                                SCM v = scm_car (p);
-                               if (Music *m = unsmob_music (v))
+                               if (Music *m = Music::unsmob (v))
                                {
-                                       if (!unsmob_input (m->get_property ("origin")))
+                                       if (!Input::unsmob (m->get_property ("origin")))
                                                m->set_spot (override_input (here_input ()));
                                }
                                        
@@ -1123,9 +1121,9 @@ Lily_lexer::eval_scm (SCM readerdata, char extra_token)
                        sval = SCM_UNSPECIFIED;
        }
 
-       if (Music *m = unsmob_music (sval))
+       if (Music *m = Music::unsmob (sval))
        {
-               if (!unsmob_input (m->get_property ("origin")))
+               if (!Input::unsmob (m->get_property ("origin")))
                        m->set_spot (override_input (here_input ()));
        }