]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/lexer.ll
* buildscripts/analyse-cxx-log.py: new file. Read compile log to
[lilypond.git] / lily / lexer.ll
index bb9ee2271a641e89f5e966272216dfba1172b0b7..92bbdc5e623c9d2a05ecc0130c8c5b8e6e87e08e 100644 (file)
@@ -4,7 +4,7 @@
 
   source file of the LilyPond music typesetter
 
-  (c) 1996--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1996--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
            Jan Nieuwenhuizen <janneke@gnu.org>
 */
 
  */
 
 
-#include <stdio.h>
-#include <ctype.h>
-#include <errno.h>
+
+#include <cstdio>
+#include <cctype>
+#include <cerrno>
 
 /* Flex >= 2.5.29 fix; FlexLexer.h's multiple include bracing breaks
    when building the actual lexer.  */
@@ -32,7 +33,6 @@
 #define LEXER_CC
 
 #include <iostream>
-
 using namespace std;
 
 #include "music-function.hh"
@@ -112,7 +112,7 @@ SCM (* scm_parse_error_handler) (void *);
 %x markup
 %x notes
 %x quote
-%x renameinput
+%x sourcefilename
 %x version
 
 A              [a-zA-Z]
@@ -153,7 +153,7 @@ BOM_UTF8    \357\273\277
 <INITIAL,chords,lyrics,figures,notes>{BOM_UTF8} {
   if (this->lexloc->line_number () != 1 || this->lexloc->column_number () != 0)
     {
-      LexerError (_ ("stray UTF-8 BOM encountered").to_str0 ());
+      LexerError (_ ("stray UTF-8 BOM encountered").c_str ());
       exit (1);
     }
   if (be_verbose_global)
@@ -180,8 +180,8 @@ BOM_UTF8    \357\273\277
 <INITIAL,chords,lyrics,notes,figures>\\version{WHITE}* {
        yy_push_state (version);
 }
-<INITIAL,chords,lyrics,notes,figures>\\renameinput{WHITE}*     {
-       yy_push_state (renameinput);
+<INITIAL,chords,lyrics,notes,figures>\\sourcefilename{WHITE}*  {
+       yy_push_state (sourcefilename);
 }
 <version>\"[^"]*\"     { /* got the version number */
        String s (YYText () + 1);
@@ -195,25 +195,25 @@ BOM_UTF8  \357\273\277
        scm_module_define (top_scope, ly_symbol2scm ("version-seen?"), SCM_BOOL_T);
 
 }
-<renameinput>\"[^"]*\"     {
+<sourcefilename>\"[^"]*\"     {
        String s (YYText () + 1);
        s = s.left_string (s.index_last ('\"'));
 
        yy_pop_state ();
        this->here_input().get_source_file ()->name_ = s;
-       message (_f ("Renaming input to: `%s'", s.to_str0 ()));
+       message (_f ("Renaming input to: `%s'", s.c_str ()));
        progress_indication ("\n");
        scm_module_define (scm_car (scopes_),
                     ly_symbol2scm ("input-file-name"),
-                    scm_makfrom0str (s.to_str0 ()));
+                    scm_makfrom0str (s.c_str ()));
 
 }
 <version>.     {
-       LexerError (_ ("quoted string expected after \\version").to_str0 ());
+       LexerError (_ ("quoted string expected after \\version").c_str ());
        yy_pop_state ();
 }
-<renameinput>.         {
-       LexerError (_ ("quoted string expected after \\renameinput").to_str0 ());
+<sourcefilename>>.     {
+       LexerError (_ ("quoted string expected after \\sourcefilename").c_str ());
        yy_pop_state ();
 }
 <longcomment>{
@@ -226,7 +226,7 @@ BOM_UTF8    \357\273\277
                yy_pop_state ();
        }
        <<EOF>>         {
-               LexerError (_ ("EOF found inside a comment").to_str0 ());
+               LexerError (_ ("EOF found inside a comment").c_str ());
                is_main_input_ = false;
                if (! close_input ()) 
                  yyterminate (); // can't move this, since it actually rets a YY_NULL
@@ -267,7 +267,7 @@ BOM_UTF8    \357\273\277
        } else { 
            String msg (_f ("wrong or undefined identifier: `%s'", s ));
 
-           LexerError (msg.to_str0 ());
+           LexerError (msg.c_str ());
            SCM err = scm_current_error_port ();
            scm_puts ("This value was found in the table: ", err);
            scm_display (sid, err);
@@ -379,7 +379,7 @@ BOM_UTF8    \357\273\277
 
                /* yylval is union. Must remember STRING before setting SCM*/
                String *sp = yylval.string;
-               yylval.scm = scm_makfrom0str (sp->to_str0 ());
+               yylval.scm = scm_makfrom0str (sp->c_str ());
                delete sp;
                return STRING;
        }
@@ -400,7 +400,7 @@ BOM_UTF8    \357\273\277
 
                /* yylval is union. Must remember STRING before setting SCM*/
                String *sp = yylval.string;
-               yylval.scm = scm_makfrom0str (sp->to_str0 ());
+               yylval.scm = scm_makfrom0str (sp->c_str ());
                delete sp;
                return LYRICS_STRING;
        }
@@ -437,7 +437,7 @@ BOM_UTF8    \357\273\277
                if (c == '{' ||  c == '}') // brace open is for not confusing dumb tools.
                        here_input ().warning (
                                _ ("Brace found at end of lyric.  Did you forget a space?"));
-               yylval.scm = scm_makfrom0str (s.to_str0 ());
+               yylval.scm = scm_makfrom0str (s.c_str ());
 
 
                return LYRICS_STRING;
@@ -518,7 +518,7 @@ BOM_UTF8    \357\273\277
                        else if (tag == ly_symbol2scm ("scheme0-scheme1-scheme2"))
                                return MARKUP_HEAD_SCM0_SCM1_SCM2;
                        else {
-                               programming_error ("no parser tag defined for this signature"); 
+                               programming_error ("no parser tag defined for this markup signature"); 
                                ly_display_scm (s);
                                assert(false);
                        }
@@ -536,7 +536,7 @@ BOM_UTF8    \357\273\277
                if (c == '{' ||  c == '}')
                        here_input ().warning (
                                _ ("Brace found at end of markup.  Did you forget a space?"));
-               yylval.scm = scm_makfrom0str (s.to_str0 ());
+               yylval.scm = scm_makfrom0str (s.c_str ());
 
 
                return STRING;
@@ -570,6 +570,7 @@ BOM_UTF8    \357\273\277
        Real r;
        int cnv = sscanf (YYText (), "%lf", &r);
        assert (cnv == 1);
+       (void) cnv;
 
        yylval.scm = scm_from_double (r);
        return REAL;
@@ -611,6 +612,8 @@ BOM_UTF8    \357\273\277
        return E_CLOSE;
     case '[':
        return E_BRACKET_OPEN;
+    case '+':
+       return E_PLUS;
     case ']':
        return E_BRACKET_CLOSE;
     case '~':
@@ -625,7 +628,7 @@ BOM_UTF8    \357\273\277
 
 <*>.           {
        String msg = _f ("invalid character: `%c'", YYText ()[0]);
-       LexerError (msg.to_str0 ());
+       LexerError (msg.c_str ());
        return YYText ()[0];
 }
 
@@ -690,7 +693,7 @@ Lily_lexer::scan_escaped_word (String str)
 {
        // use more SCM for this.
 
-//     SCM sym = ly_symbol2scm (str.to_str0 ());
+//     SCM sym = ly_symbol2scm (str.c_str ());
 
        int i = lookup_keyword (str);
        if (i == MARKUP && is_lyric_state ())
@@ -712,9 +715,9 @@ Lily_lexer::scan_escaped_word (String str)
        }
 
        String msg (_f ("unknown escaped string: `\\%s'", str));        
-       LexerError (msg.to_str0 ());
+       LexerError (msg.c_str ());
 
-       yylval.scm = scm_makfrom0str (str.to_str0 ());
+       yylval.scm = scm_makfrom0str (str.c_str ());
 
        return STRING;
 }
@@ -722,7 +725,7 @@ Lily_lexer::scan_escaped_word (String str)
 int
 Lily_lexer::scan_bare_word (String str)
 {
-       SCM sym = ly_symbol2scm (str.to_str0 ());
+       SCM sym = ly_symbol2scm (str.c_str ());
        if ((YYSTATE == notes) || (YYSTATE == chords)) {
                SCM handle = SCM_BOOL_F;
                if (scm_is_pair (pitchname_tab_stack_))
@@ -742,7 +745,7 @@ Lily_lexer::scan_bare_word (String str)
                }
        }
 
-       yylval.scm = scm_makfrom0str (str.to_str0 ());
+       yylval.scm = scm_makfrom0str (str.c_str ());
        return STRING;
 }
 
@@ -860,31 +863,11 @@ scan_fraction (String frac)
        return scm_cons (scm_from_int (n), scm_from_int (d));
 }
 
-// Breaks for flex 2.5.31
-#if 0
-/* avoid silly flex induced gcc warnings */
-static void yy_push_state (int) {;}
-static void yy_pop_state () {;}
-static int yy_top_state () { return 0; }
-
-static void
-avoid_silly_flex_induced_gcc_warnings ()
-{
-       (void)yy_start_stack_ptr;
-       (void)yy_start_stack_depth;
-       (void)yy_start_stack;
-       yy_push_state (0);
-       yy_pop_state ();
-       yy_top_state ();
-       avoid_silly_flex_induced_gcc_warnings ();
-}
-#endif
-
 SCM
 lookup_markup_command (String s)
 {
        SCM proc = ly_lily_module_constant ("lookup-markup-command");
-       return scm_call_1 (proc, scm_makfrom0str (s.to_str0 ()));
+       return scm_call_1 (proc, scm_makfrom0str (s.c_str ()));
 }
 
 
@@ -920,6 +903,10 @@ music_function_type (SCM func)
        {
                return MUSIC_FUNCTION_SCM_SCM_MUSIC;
        }
+       else if (type == ly_symbol2scm ("scm-scm-scm"))
+       {
+               return MUSIC_FUNCTION_SCM_SCM_SCM;
+       }
        else if (type == ly_symbol2scm ("markup"))
        {
                return MUSIC_FUNCTION_MARKUP;
@@ -952,3 +939,35 @@ music_function_type (SCM func)
 
        return MUSIC_FUNCTION_SCM;
 }
+
+/* Shut up lexer warnings.  */
+#if YY_STACK_USED
+
+static void
+yy_push_state (int)
+{
+}
+
+static void
+yy_pop_state ()
+{
+}
+
+static int
+yy_top_state ()
+{
+  return 0;
+}
+
+static void
+silence_lexer_warnings ()
+{
+   (void) yy_start_stack_ptr;
+   (void) yy_start_stack_depth;
+   (void) yy_start_stack;
+   (void) yy_push_state;
+   (void) yy_pop_state;
+   (void) yy_top_state;
+   (void) silence_lexer_warnings;
+}
+#endif