From: David Kastrup Date: Sun, 6 Nov 2011 11:08:45 +0000 (+0100) Subject: lexer.ll: add $ for immediate export. X-Git-Tag: release/2.15.18-1~6 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=0765b9a3becf2d06e80127cd198ddad25508a505;p=lilypond.git lexer.ll: add $ for immediate export. --- diff --git a/lily/include/lily-lexer.hh b/lily/include/lily-lexer.hh index 54e068ee7a..2de3827443 100644 --- a/lily/include/lily-lexer.hh +++ b/lily/include/lily-lexer.hh @@ -53,6 +53,7 @@ private: int scan_bare_word (string); SCM scan_markup_word (string); int scan_escaped_word (string); + int scan_scm_id (SCM); int identifier_type (SCM); char escaped_char (char) const; diff --git a/lily/lexer.ll b/lily/lexer.ll index 5619eea47f..59284d07c3 100644 --- a/lily/lexer.ll +++ b/lily/lexer.ll @@ -383,6 +383,32 @@ BOM_UTF8 \357\273\277 yylval.scm = sval; return SCM_TOKEN; } + +\$ { //immediate scm + int n = 0; + Input hi = here_input(); + hi.step_forward (); + SCM sval = ly_parse_scm (hi.start (), &n, hi, + be_safe_global && is_main_input_, parser_); + + for (int i = 0; i < n; i++) + { + yyinput (); + } + char_count_stack_.back () += n; + + if (sval == SCM_UNDEFINED) + { + yylval.scm = SCM_UNSPECIFIED; + error_level_ = 1; + + LexerError (_ ("bad Scheme expression").c_str ()); + return SCM_IDENTIFIER; + } + + return scan_scm_id (sval); +} + { \<\< { return DOUBLE_ANGLE_OPEN; @@ -598,7 +624,7 @@ BOM_UTF8 \357\273\277 [{}] { return YYText ()[0]; } - [^#{}\"\\ \t\n\r\f]+ { + [^$#{}\"\\ \t\n\r\f]+ { string s (YYText ()); char c = s[s.length () - 1]; @@ -799,6 +825,20 @@ Lily_lexer::scan_escaped_word (string str) return i; SCM sid = lookup_identifier (str); + if (sid != SCM_UNDEFINED) + return scan_scm_id (sid); + + string msg (_f ("unknown escaped string: `\\%s'", str)); + LexerError (msg.c_str ()); + + yylval.scm = ly_string2scm (str); + + return STRING; +} + +int +Lily_lexer::scan_scm_id (SCM sid) +{ if (is_music_function (sid)) { int funtype = SCM_FUNCTION; @@ -849,19 +889,8 @@ Lily_lexer::scan_escaped_word (string str) } return funtype; } - - if (sid != SCM_UNDEFINED) - { - yylval.scm = sid; - return identifier_type (sid); - } - - string msg (_f ("unknown escaped string: `\\%s'", str)); - LexerError (msg.c_str ()); - - yylval.scm = ly_string2scm (str); - - return STRING; + yylval.scm = sid; + return identifier_type (sid); } int