X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fparse-scm.cc;h=576591dc97265e2a77dd93bcfa7c61b7ee48ecba;hb=90e4d7057f3857da049dfda3d130017d4719bd6b;hp=a8505fdec617c4d03243c02e42ef10ce9aef37c2;hpb=e7aa6c445f463844dbaa52d38ea4aac2882b5601;p=lilypond.git diff --git a/lily/parse-scm.cc b/lily/parse-scm.cc index a8505fdec6..576591dc97 100644 --- a/lily/parse-scm.cc +++ b/lily/parse-scm.cc @@ -1,7 +1,7 @@ /* This file is part of LilyPond, the GNU music typesetter. - Copyright (C) 2004--2014 Han-Wen Nienhuys + Copyright (C) 2004--2015 Han-Wen Nienhuys LilyPond is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ using namespace std; #include "main.hh" #include "paper-book.hh" #include "source-file.hh" +#include "lily-imports.hh" /* Pass string to scm parser, read one expression. Return result value and #chars read. @@ -92,17 +93,11 @@ internal_ly_eval_scm (Parse_start *ps) if (ps->safe_) { static SCM module = SCM_BOOL_F; - if (module == SCM_BOOL_F) + if (scm_is_false (module)) { - SCM function = ly_lily_module_constant ("make-safe-lilypond-module"); - module = scm_gc_protect_object (scm_call_0 (function)); + module = scm_gc_protect_object (Lily::make_safe_lilypond_module ()); } - // We define the parser so trusted Scheme functions can - // access the real namespace underlying the parser. - if (ps->parser_) - scm_module_define (module, ly_symbol2scm ("parser"), - ps->parser_->self_scm ()); return scm_eval (ps->form_, module); } return scm_primitive_eval (ps->form_); @@ -125,7 +120,8 @@ parse_handler (void *data, SCM /*tag*/, SCM args) { Parse_start *ps = (Parse_start *) data; - ps->location_.error (_ ("GUILE signaled an error for the expression beginning here")); + ps->location_.non_fatal_error + (_ ("GUILE signaled an error for the expression beginning here")); if (scm_ilength (args) > 2) scm_display_error_message (scm_cadr (args), scm_caddr (args), scm_current_error_port ()); @@ -146,15 +142,15 @@ protected_ly_parse_scm (Parse_start *ps) } SCM -protected_ly_eval_scm (Parse_start *ps) +protected_ly_eval_scm (void *ps) { /* Catch #t : catch all Scheme level errors. */ return scm_internal_catch (SCM_BOOL_T, catch_protected_eval_body, - (void *) ps, - &parse_handler, (void *) ps); + ps, + &parse_handler, ps); } bool parse_protect_global = true; @@ -178,8 +174,12 @@ ly_eval_scm (SCM form, Input i, bool safe, Lily_parser *parser) { Parse_start ps (form, i, safe, parser); - SCM ans = parse_protect_global ? protected_ly_eval_scm (&ps) - : internal_ly_eval_scm (&ps); + SCM ans = scm_c_with_fluid + (Lily::f_location, + i.smobbed_copy (), + parse_protect_global ? protected_ly_eval_scm + : catch_protected_eval_body, (void *) &ps); + scm_remember_upto_here_1 (form); return ans; }