From: Keith OHara Date: Wed, 10 Aug 2011 07:57:44 +0000 (-0700) Subject: lexer.ll: remove unused patterns, avoid backing up X-Git-Tag: release/2.15.9-1~9^2~13 X-Git-Url: https://git.donarmstrong.com/lilypond.git?a=commitdiff_plain;h=da949cdcede0ffb559e9e5e2adbae2088ba1f6d6;p=lilypond.git lexer.ll: remove unused patterns, avoid backing up --- diff --git a/lily/lexer.ll b/lily/lexer.ll index 7cda144e26..5743f44964 100644 --- a/lily/lexer.ll +++ b/lily/lexer.ll @@ -135,7 +135,6 @@ PUNCT [?!:'`] ACCENT \\[`'"^] NATIONAL [\001-\006\021-\027\031\036] TEX {AA}|-|{PUNCT}|{ACCENT}|{NATIONAL} -WORD {A}{AN}* DASHED_WORD {A}({AN}|-)* DASHED_KEY_WORD \\{DASHED_WORD} @@ -148,7 +147,6 @@ E_UNSIGNED \\{N}+ FRACTION {N}+\/{N}+ INT -?{UNSIGNED} REAL ({INT}\.{N}*)|(-?\.{N}+) -KEYWORD \\{WORD} WHITE [ \n\t\f\r] HORIZONTALWHITE [ \t] BLACK [^ \n\t\f\r] @@ -165,7 +163,7 @@ BOM_UTF8 \357\273\277 <*>\r { - // windows-suck-suck-suck + // swallow and ignore carriage returns } {ANY_CHAR} { @@ -263,15 +261,15 @@ BOM_UTF8 \357\273\277 this->here_input ().get_source_file ()->set_line (here_input ().start (), i); } -. { +{ANY_CHAR} { LexerError (_ ("quoted string expected after \\version").c_str ()); yy_pop_state (); } -. { +{ANY_CHAR} { LexerError (_ ("quoted string expected after \\sourcefilename").c_str ()); yy_pop_state (); } -. { +{ANY_CHAR} { LexerError (_ ("integer expected after \\sourcefileline").c_str ()); yy_pop_state (); } @@ -284,12 +282,6 @@ BOM_UTF8 \357\273\277 "%"+"}" { yy_pop_state (); } - <> { - LexerError (_ ("EOF found inside a comment").c_str ()); - is_main_input_ = false; // should be safe , can't have \include in --safe. - if (! close_input ()) - yyterminate (); // can't move this, since it actually rets a YY_NULL - } } @@ -313,7 +305,7 @@ BOM_UTF8 \357\273\277 new_input (s, sources_); yy_pop_state (); } -\\{BLACK}*{WHITE} { /* got the include identifier */ +\\{BLACK}*{WHITE}? { /* got the include identifier */ string s = YYText () + 1; strip_trailing_white (s); if (s.length () && (s[s.length () - 1] == ';')) @@ -332,7 +324,7 @@ BOM_UTF8 \357\273\277 scm_display (sid, err); } } -\"[^"]* { // backup rule +\"[^"]* { // backup rule error (_ ("end quote missing")); exit (1); } @@ -419,11 +411,15 @@ BOM_UTF8 \357\273\277 yylval.scm = scan_fraction (YYText ()); return FRACTION; } - {DIGIT} { yylval.i = String_convert::dec2int (string (YYText ())); return DIGIT; } + {UNSIGNED}/\/[^0-9] { // backup rule + yylval.i = String_convert::dec2int (string (YYText ())); + return UNSIGNED; + } + {UNSIGNED}/\/ | // backup rule {UNSIGNED} { yylval.i = String_convert::dec2int (string (YYText ())); return UNSIGNED; @@ -464,6 +460,11 @@ BOM_UTF8 \357\273\277 yylval.scm = scan_fraction (YYText ()); return FRACTION; } + {UNSIGNED}/\/[^0-9] { // backup rule + yylval.i = String_convert::dec2int (string (YYText ())); + return UNSIGNED; + } + {UNSIGNED}/\/ | // backup rule {UNSIGNED} { yylval.i = String_convert::dec2int (string (YYText ())); return UNSIGNED; @@ -504,6 +505,11 @@ BOM_UTF8 \357\273\277 yylval.scm = scan_fraction (YYText ()); return FRACTION; } + {UNSIGNED}/\/[^0-9] { // backup rule + yylval.i = String_convert::dec2int (string (YYText ())); + return UNSIGNED; + } + {UNSIGNED}/\/ | // backup rule {UNSIGNED} { yylval.i = String_convert::dec2int (string (YYText ())); return UNSIGNED; @@ -605,7 +611,14 @@ BOM_UTF8 \357\273\277 } <*><> { - if (is_main_input_) + if (YY_START == longcomment) + { + LexerError (_ ("EOF found inside a comment").c_str ()); + is_main_input_ = false; // should be safe , can't have \include in --safe. + if (!close_input ()) + yyterminate (); // can't move this, since it actually rets a YY_NULL + } + else if (is_main_input_) { /* 2 = init.ly + current file. > because we're before closing, but is_main_input_ should @@ -630,12 +643,7 @@ BOM_UTF8 \357\273\277 } } -{WORD} { - return scan_bare_word (YYText ()); -} -{KEYWORD} { - return scan_escaped_word (YYText () + 1); -} +-{UNSIGNED} | // backup rule {REAL} { Real r; int cnv = sscanf (YYText (), "%lf", &r); @@ -645,6 +653,10 @@ BOM_UTF8 \357\273\277 yylval.scm = scm_from_double (r); return REAL; } +-\. { // backup rule + yylval.scm = scm_from_double (0.0); + return REAL; +} {UNSIGNED} { yylval.i = String_convert::dec2int (string (YYText ()));