]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/lexer.ll
patch::: 1.3.59.uu2.jcn1
[lilypond.git] / lily / lexer.ll
index 7c09d492e9c9cc4494b3cea5cbb4e3a939e813a6..23692d60d74c93cc9041d9c20594094494ad5cf6 100644 (file)
@@ -4,7 +4,7 @@
 
   source file of the LilyPond music typesetter
 
-  (c) 1996--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1996--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
            Jan Nieuwenhuizen <janneke@gnu.org>
 */
 
@@ -37,8 +37,8 @@
 #include "main.hh"
 #include "musical-request.hh"
 #include "identifier.hh"
-#include "mudela-version.hh"
 #include "version.hh"
+#include "mudela-version.hh"
 
 void strip_trailing_white (String&);
 void strip_leading_white (String&);
@@ -339,7 +339,7 @@ HYPHEN              --
                return STRING;
        }
        . {
-               return yylval.c = YYText ()[0];
+               return YYText ()[0];
        }
 }
 <chords>{
@@ -359,11 +359,17 @@ HYPHEN            --
        -  {
                return CHORD_MINUS;
        }
+       :  {
+               return CHORD_COLON;
+       }
+       \/\+ {
+               return CHORD_BASS;
+       }
        \^  {
                return CHORD_CARET;
        }
        . {
-               return yylval.c = YYText ()[0];
+               return YYText ()[0];
        }
 }
 
@@ -408,12 +414,12 @@ HYPHEN            --
 }
 
 <INITIAL,notes>.       {
-       return yylval.c = YYText ()[0];
+       return YYText ()[0];
 }
 
 <INITIAL,lyrics,notes>\\. {
     char c= YYText ()[1];
-    yylval.c = c;
+
     switch (c) {
     case '>':
        return E_BIGGER;
@@ -461,31 +467,33 @@ My_lily_lexer::pop_state ()
 int
 My_lily_lexer::scan_escaped_word (String str)
 {
-       DEBUG_OUT << "\\word: `" << str<<"'\n";
+       // use more SCM for this.
+
+       SCM sym = ly_symbol2scm (str.ch_C());
+
        int l = lookup_keyword (str);
        if (l != -1) {
-               DEBUG_OUT << "(keyword)\n";
                return l;
        }
        Identifier * id = lookup_identifier (str);
        if (id) {
-               DEBUG_OUT << "(identifier)\n";
                yylval.id = id;
                return id->token_code_i_;
        }
        if ((YYSTATE != notes) && (YYSTATE != chords)) {
-               if (notename_b (str)) {
-                       yylval.pitch = new Musical_pitch (lookup_notename (str));
+               SCM pitch = scm_hashq_ref (pitchname_tab_, sym, SCM_BOOL_F);
+               
+               if (pitch != SCM_BOOL_F)
+               {
+                       yylval.pitch = new Musical_pitch (pitch);
                        yylval.pitch->set_spot (Input (source_file_l (), 
                          here_ch_C ()));
                        return NOTENAME_PITCH;
                }
        }
-       if (flower_dstream)
-               print_declarations (true);
        String msg (_f ("unknown escaped string: `\\%s'", str));        
        LexerError (msg.ch_C ());
-       DEBUG_OUT << "(string)";
+
        yylval.scm = ly_str02scm(str.ch_C());
 
        return STRING;
@@ -494,17 +502,17 @@ My_lily_lexer::scan_escaped_word (String str)
 int
 My_lily_lexer::scan_bare_word (String str)
 {
-       DEBUG_OUT << "word: `" << str<< "'\n";  
+       SCM sym = ly_symbol2scm (str.ch_C ());
        if ((YYSTATE == notes) || (YYSTATE == chords)) {
-               if (notename_b (str)) {
-                   DEBUG_OUT << "(notename)\n";
-                   yylval.pitch = new Musical_pitch (lookup_notename (str));
+               SCM pitch = scm_hashq_ref (pitchname_tab_, sym, SCM_BOOL_F);
+               if (pitch != SCM_BOOL_F) {
+                   yylval.pitch = new Musical_pitch (pitch);
                    yylval.pitch->set_spot (Input (source_file_l (), 
                      here_ch_C ()));
                     return (YYSTATE == notes) ? NOTENAME_PITCH : TONICNAME_PITCH;
-               } else if (chordmodifier_b (str)) {
-                   DEBUG_OUT << "(chordmodifier)\n";
-                   yylval.pitch = new Musical_pitch (lookup_chordmodifier (str));
+               } else if ((pitch = scm_hashq_ref (chordmodifier_tab_, sym, SCM_BOOL_F))!= SCM_BOOL_F)
+               {
+                   yylval.pitch = new Musical_pitch (pitch);
                    yylval.pitch->set_spot (Input (source_file_l (), 
                      here_ch_C ()));
                    return CHORDMODIFIER_PITCH;