From 8627d767e67258394cd4256740542a36dacd7868 Mon Sep 17 00:00:00 2001 From: David Kastrup Date: Sun, 7 May 2017 23:31:13 +0200 Subject: [PATCH] Replace WORD token in parser and lexer with SYMBOL This is a fixup on issue 5113 since Windows header files already define WORD as a preprocessor token, making Gub fail compilation. --- lily/lexer.ll | 26 +++++++++++++------------- lily/parser.yy | 30 +++++++++++++++--------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/lily/lexer.ll b/lily/lexer.ll index 7abad93058..93184ebe08 100644 --- a/lily/lexer.ll +++ b/lily/lexer.ll @@ -157,8 +157,8 @@ A [a-zA-Z\200-\377] AA {A}|_ N [0-9] ANY_CHAR (.|\n) -WORD {A}([-_]{A}|{A})* -COMMAND \\{WORD} +SYMBOL {A}([-_]{A}|{A})* +COMMAND \\{SYMBOL} /* SPECIAL category is for every letter that needs to get passed to * the parser rather than being redefinable by the user */ SPECIAL [-+*/=<>{}!?_^'',.:] @@ -362,7 +362,7 @@ BOM_UTF8 \357\273\277 /* Flex picks the longest matching pattern including trailing * contexts. Without the backup pattern, r-. does not trigger the - * {RESTNAME} rule but rather the {WORD}/[-_] rule coming later, + * {RESTNAME} rule but rather the {SYMBOL}/[-_] rule coming later, * needed for avoiding backup states. */ @@ -476,8 +476,8 @@ BOM_UTF8 \357\273\277 } { - {WORD}/[-_] | // backup rule - {WORD} { + {SYMBOL}/[-_] | // backup rule + {SYMBOL} { return scan_bare_word (YYText_utf8 ()); } \\\" { @@ -583,7 +583,7 @@ BOM_UTF8 \357\273\277 s = lyric_fudge (s); yylval = ly_string2scm (s); - return WORD; + return SYMBOL; } /* This should really just cover {} */ [{}] { @@ -592,8 +592,8 @@ BOM_UTF8 \357\273\277 } } { - {WORD}/[-_] | // backup rule - {WORD} { + {SYMBOL}/[-_] | // backup rule + {SYMBOL} { return scan_bare_word (YYText_utf8 ()); } \\\" { @@ -702,7 +702,7 @@ BOM_UTF8 \357\273\277 string s (YYText_utf8 ()); yylval = ly_string2scm (s); - return WORD; + return SYMBOL; } [{}] { yylval = SCM_UNSPECIFIED; @@ -756,8 +756,8 @@ BOM_UTF8 \357\273\277 } { - {WORD}/[-_] | // backup rule - {WORD} { + {SYMBOL}/[-_] | // backup rule + {SYMBOL} { return scan_bare_word (YYText_utf8 ()); } \\\" { @@ -927,7 +927,7 @@ Lily_lexer::scan_escaped_word (const string &str) yylval = ly_string2scm (str); - return STRING; // WORD would cause additional processing + return STRING; // SYMBOL would cause additional processing } int @@ -1038,7 +1038,7 @@ Lily_lexer::scan_bare_word (const string &str) return state; } yylval = ly_string2scm (str); - return WORD; + return SYMBOL; } int diff --git a/lily/parser.yy b/lily/parser.yy index 8c9c468ca4..f81dc69e9b 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -375,7 +375,7 @@ If we give names, Bison complains. %token STRING %token SYMBOL_LIST %token TONICNAME_PITCH -%token WORD +%token SYMBOL %left '-' '+' @@ -672,7 +672,7 @@ header_block: */ assignment_id: STRING - | WORD + | SYMBOL ; assignment: @@ -1768,7 +1768,7 @@ symbol_list_element: symbol_list_part_bare: - WORD + SYMBOL { $$ = try_word_variants (Lily::key_list_p, $1); if (SCM_UNBNDP ($$)) { @@ -1934,7 +1934,7 @@ function_arglist_nonbackup_reparse: else MYREPARSE (@4, $2, SCM_ARG, $4); } - | EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup WORD + | EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup SYMBOL { $$ = $3; SCM res = try_word_variants ($2, $4); @@ -2204,7 +2204,7 @@ function_arglist_backup: MYBACKUP (STRING, $4, @4); } } - | EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup WORD + | EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup SYMBOL { SCM res = try_word_variants ($2, $4); if (!SCM_UNBNDP (res)) @@ -2445,7 +2445,7 @@ function_arglist_common_reparse: // know the predicate to be false. MYREPARSE (@3, $1, SCM_ARG, $3); } - | EXPECT_SCM function_arglist_optional WORD + | EXPECT_SCM function_arglist_optional SYMBOL { $$ = $2; SCM res = try_word_variants ($1, $3); @@ -2773,7 +2773,7 @@ context_mod: | context_def_mod STRING { $$ = scm_list_2 ($1, $2); } - | context_def_mod WORD { + | context_def_mod SYMBOL { $$ = scm_list_2 ($1, $2); } | context_def_mod embedded_scm @@ -2918,13 +2918,13 @@ music_property_def: string: STRING - | WORD + | SYMBOL | full_markup ; text: STRING - | WORD + | SYMBOL | full_markup | embedded_scm_bare { @@ -2938,7 +2938,7 @@ text: ; simple_string: STRING - | WORD + | SYMBOL | embedded_scm_bare { if (scm_is_string ($1)) { @@ -2954,7 +2954,7 @@ symbol: STRING { $$ = scm_string_to_symbol ($1); } - | WORD + | SYMBOL { if (!is_regular_identifier ($1, false)) parser->parser_error (@1, (_ ("symbol expected"))); @@ -3341,7 +3341,7 @@ gen_text_def: make_simple_markup ($1)); $$ = t->unprotect (); } - | WORD { + | SYMBOL { // Flag a warning? could be unintentional Music *t = MY_MAKE_MUSIC ("TextScriptEvent", @$); t->set_property ("text", @@ -3488,7 +3488,7 @@ tremolo_type: bass_number: UNSIGNED | STRING - | WORD + | SYMBOL | full_markup | embedded_scm_bare { @@ -3675,7 +3675,7 @@ lyric_element: parser->parser_error (@1, _ ("markup outside of text script or \\lyricmode")); $$ = $1; } - | WORD { + | SYMBOL { if (!parser->lexer_->is_lyric_state ()) parser->parser_error (@1, _f ("not a note name: %s", ly_scm2string ($1))); $$ = $1; @@ -4068,7 +4068,7 @@ simple_markup: STRING { $$ = make_simple_markup ($1); } - | WORD { + | SYMBOL { $$ = make_simple_markup ($1); } | SCORE { -- 2.39.2