From 1a61d0b5a931377348f579b3379cc6ccb129af8e Mon Sep 17 00:00:00 2001 From: Erik Sandberg Date: Wed, 19 Jul 2006 11:38:20 +0000 Subject: [PATCH] * lily/parser.yy, lily/lexer.ll: added some simplifications by Angelo Contardi. --- ChangeLog | 5 +++++ THANKS | 1 + lily/lexer.ll | 57 ++++++++++++++++++-------------------------------- lily/parser.yy | 32 +++++++--------------------- 4 files changed, 34 insertions(+), 61 deletions(-) diff --git a/ChangeLog b/ChangeLog index c00a11abae..e86fe90bb7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-07-19 Erik Sandberg + + * lily/parser.yy, lily/lexer.ll: added some simplifications by + Angelo Contardi. + 2006-07-19 Graham Percival * input/manual/screech-boink.ly: moved to here. diff --git a/THANKS b/THANKS index 4ca18523bd..0fe6f802f2 100644 --- a/THANKS +++ b/THANKS @@ -10,6 +10,7 @@ Mats Bengtsson - Support Guru CONTRIBUTORS +Angelo Contardi David Feuer Erik Sandberg Erlend Aasland diff --git a/lily/lexer.ll b/lily/lexer.ll index 2b887d0046..c6be4382d4 100644 --- a/lily/lexer.ll +++ b/lily/lexer.ll @@ -179,6 +179,12 @@ BOM_UTF8 \357\273\277 } } +{ + \" { + start_quote (); + } +} + \\version{WHITE}* { yy_push_state (version); } @@ -318,13 +324,23 @@ BOM_UTF8 \357\273\277 return SCM_T; } { - \<\< { + \<\< { return DOUBLE_ANGLE_OPEN; } - \>\> { + \>\> { return DOUBLE_ANGLE_CLOSE; } } + +{ + \< { + return ANGLE_OPEN; + } + \> { + return ANGLE_CLOSE; + } +} + { _ { return FIGURE_SPACE; @@ -362,36 +378,9 @@ BOM_UTF8 \357\273\277 yylval.i = String_convert::dec2int (string (YYText () +1)); return E_UNSIGNED; } - \" { - start_quote (); - } } -\" { - start_quote (); -} -{ - \\{ESCAPED} { - *yylval.string += to_string (escaped_char (YYText ()[1])); - } - [^\\"]+ { - *yylval.string += YYText (); - } - \" { - - 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 (); - } -} -{ +{ \\{ESCAPED} { *yylval.string += to_string (escaped_char (YYText ()[1])); } @@ -406,7 +395,7 @@ BOM_UTF8 \357\273\277 string *sp = yylval.string; yylval.scm = scm_makfrom0str (sp->c_str ()); delete sp; - return LYRICS_STRING; + return is_lyric_state () ? LYRICS_STRING : STRING; } . { *yylval.string += YYText (); @@ -465,9 +454,6 @@ BOM_UTF8 \357\273\277 yylval.i = String_convert::dec2int (string (YYText ())); return UNSIGNED; } - \" { - start_quote (); - } - { return CHORD_MINUS; } @@ -490,9 +476,6 @@ BOM_UTF8 \357\273\277 { - \" { - start_quote (); - } \\score { return SCORE; } diff --git a/lily/parser.yy b/lily/parser.yy index 08c0e1e742..5901962c86 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -160,7 +160,7 @@ void set_music_properties (Music *p, SCM a); %token ADDQUOTE "\\addquote" %token ALIAS "\\alias" %token ALTERNATIVE "\\alternative" -%token BOOK "\book" +%token BOOK "\\book" %token CHANGE "\\change" %token CHORDMODE "\\chordmode" %token CHORDS "\\chords" @@ -223,8 +223,10 @@ void set_music_properties (Music *p, SCM a); %token CHORD_COLON ":" %token CHORD_MINUS "-" %token CHORD_SLASH "/" -%token DOUBLE_ANGLE_CLOSE ">>" +%token ANGLE_OPEN "<" +%token ANGLE_CLOSE ">" %token DOUBLE_ANGLE_OPEN "<<" +%token DOUBLE_ANGLE_CLOSE ">>" %token E_BACKSLASH "\\" %token E_ANGLE_CLOSE "\\>" %token E_CHAR "\\C[haracter]" @@ -348,7 +350,6 @@ If we give names, Bison complains. %type simple_music_property_def %type string_number_event %type tempo_event -%type toplevel_music %type output_def_body %type output_def_head @@ -477,7 +478,7 @@ toplevel_expression: scm_call_2 (proc, PARSER->self_scm (), score->self_scm ()); score->unprotect (); } - | toplevel_music { + | composite_music { Music *music = unsmob_music ($1); SCM proc = PARSER->lexer_->lookup_identifier ("toplevel-music-handler"); scm_call_2 (proc, PARSER->self_scm (), music->self_scm ()); @@ -502,11 +503,6 @@ toplevel_expression: } ; -toplevel_music: - composite_music { - } - ; - embedded_scm: SCM_T | SCM_IDENTIFIER @@ -902,7 +898,7 @@ simultaneous_music: SIMULTANEOUS '{' music_list '}'{ $$ = MAKE_SYNTAX ("simultaneous-music", @$, scm_car ($3)); } - | simul_open music_list simul_close { + | DOUBLE_ANGLE_OPEN music_list DOUBLE_ANGLE_CLOSE { $$ = MAKE_SYNTAX ("simultaneous-music", @$, scm_car ($2)); } ; @@ -1331,20 +1327,8 @@ note_chord_element: } ; -chord_open: '<' - ; - -chord_close: '>' - ; - -simul_open: DOUBLE_ANGLE_OPEN - ; - -simul_close: DOUBLE_ANGLE_CLOSE - ; - chord_body: - chord_open chord_body_elements chord_close + ANGLE_OPEN chord_body_elements ANGLE_CLOSE { $$ = MAKE_SYNTAX ("event-chord", @$, scm_reverse_x ($2, SCM_EOL)); } @@ -1766,7 +1750,7 @@ script_abbreviation: | '|' { $$ = scm_makfrom0str ("Bar"); } - | '>' { + | ANGLE_CLOSE { $$ = scm_makfrom0str ("Larger"); } | '.' { -- 2.39.2