From 68e154524d65e630d052a3d031257727fa38d498 Mon Sep 17 00:00:00 2001 From: fred Date: Tue, 26 Mar 2002 22:28:13 +0000 Subject: [PATCH] lilypond-1.3.0 --- lily/includable-lexer.cc | 10 +++++----- lily/lexer.ll | 43 +++++++++++++++++++++++++++++++++------- 2 files changed, 41 insertions(+), 12 deletions(-) diff --git a/lily/includable-lexer.cc b/lily/includable-lexer.cc index 89c7483478..961089bf62 100644 --- a/lily/includable-lexer.cc +++ b/lily/includable-lexer.cc @@ -66,7 +66,7 @@ Includable_lexer::new_input (String s, Sources * global_sources) Whoops. The size argument to yy_create_buffer is not the filelength but a BUFFERSIZE. Maybe this is why reading stdin fucks up. - */ + */ yy_switch_to_buffer (yy_create_buffer (sl->istream_l (), YY_BUF_SIZE)); } @@ -102,10 +102,10 @@ Includable_lexer::close_input () return false; } else - { - yy_switch_to_buffer (state_stack_.pop ()); - return true; - } + { + yy_switch_to_buffer (state_stack_.pop ()); + return true; + } } char const* diff --git a/lily/lexer.ll b/lily/lexer.ll index 42e4996c58..7d2d699ead 100644 --- a/lily/lexer.ll +++ b/lily/lexer.ll @@ -4,7 +4,8 @@ source file of the LilyPond music typesetter - (c) 1996,1997 Han-Wen Nienhuys + (c) 1996--1999 Han-Wen Nienhuys + Jan Nieuwenhuizen */ @@ -24,11 +25,13 @@ #include #include +#include "lily-guile.hh" #include "string.hh" #include "string-convert.hh" #include "my-lily-lexer.hh" #include "array.hh" #include "interval.hh" +#include "lily-guile.hh" #include "parser.hh" #include "debug.hh" #include "main.hh" @@ -206,8 +209,7 @@ HYPHEN -- } {RESTNAME} { const char *s = YYText (); - yylval.string = new String (s); - DEBUG_OUT << "rest:"<< yylval.string; + yylval.scm = ly_ch_C_to_scm (s); return RESTNAME; } R { @@ -231,6 +233,27 @@ HYPHEN -- cerr << _ ("white expected") << endl; exit (1); } +# { //embedded scm + //char const* s = YYText () + 1; + char const* s = here_ch_C (); + int n = 0; + if (main_input_b_ && safe_global_b) { + error (_ ("Can't evaluate Scheme in safe mode")); + return SCM_EOL; + } + yylval.scm = ly_parse_scm (s, &n); + DEBUG_OUT << "Scheme: "; + if (flower_dstream) + ly_display_scm (yylval.scm); + + for (int i=0; i < n; i++) + { + yyinput (); + } + char_count_stack_.top () += n; + + return SCM_T; +} { {ALPHAWORD} { return scan_bare_word (YYText ()); @@ -267,6 +290,11 @@ HYPHEN -- \" { DEBUG_OUT << "quoted string: `" << *yylval.string << "'\n"; yy_pop_state (); + + /* yylval is union. Must remember STRING before setting SCM*/ + String *sp = yylval.string; + yylval.scm = ly_ch_C_to_scm (sp->ch_C ()); + delete sp; return STRING; } . { @@ -305,7 +333,8 @@ HYPHEN -- 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.string = new String (s); + yylval.scm = ly_ch_C_to_scm (YYText()); + DEBUG_OUT << "lyric : `" << s << "'\n"; return STRING; } @@ -457,8 +486,8 @@ My_lily_lexer::scan_escaped_word (String str) String msg (_f ("unknown escaped string: `\\%s'", str)); LexerError (msg.ch_C ()); DEBUG_OUT << "(string)"; - String *sp = new String (str); - yylval.string=sp; + yylval.scm = ly_ch_C_to_scm(str.ch_C()); + return STRING; } @@ -482,7 +511,7 @@ My_lily_lexer::scan_bare_word (String str) } } - yylval.string=new String (str); + yylval.scm = ly_ch_C_to_scm (str.ch_C()); return STRING; } -- 2.39.5