int nchars;
Input start_location_;
bool safe_;
+ Lily_parser *parser_;
+
+ Parse_start() {
+ str = 0;
+ nchars = 0;
+ safe_ = false;
+ parser_ = 0;
+ }
};
SCM catch_protected_parse_body (void *);
SCM protected_ly_parse_scm (Parse_start *, bool);
-SCM ly_parse_scm (char const *, int *, Input, bool);
+SCM ly_parse_scm (char const *, int *, Input, bool, Lily_parser *);
#endif /* PARSE_SCM_HH */
Input hi = here_input();
hi.step_forward ();
SCM sval = ly_parse_scm (hi.start (), &n, hi,
- be_safe_global && is_main_input_);
+ be_safe_global && is_main_input_, parser_);
if (sval == SCM_UNDEFINED)
{
#include "international.hh"
#include "lily-lexer.hh"
#include "lily-version.hh"
+#include "ly-module.hh"
#include "main.hh"
#include "output-def.hh"
#include "paper-book.hh"
SCM
Lily_parser::make_scope () const
{
- return ly_make_anonymous_module (be_safe_global);
+ SCM module = ly_make_anonymous_module (be_safe_global);
+ return module;
}
#include <cstdio>
using namespace std;
+#include "lily-parser.hh"
#include "international.hh"
#include "main.hh"
#include "paper-book.hh"
SCM answer = SCM_UNSPECIFIED;
SCM form = scm_read (port);
-
/* Reset read_buf for scm_ftell.
Shouldn't scm_read () do this for us? */
scm_fill_input (port);
SCM function = ly_lily_module_constant ("make-safe-lilypond-module");
module = scm_call_0 (function);
}
+
+ // 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());
answer = scm_eval (form, module);
}
else
/* Try parsing. Upon failure return SCM_UNDEFINED.
FIXME: shouldn't we return SCM_UNSCPECIFIED -- jcn */
SCM
-ly_parse_scm (char const *s, int *n, Input i, bool safe)
+ly_parse_scm (char const *s, int *n, Input i, bool safe, Lily_parser *parser)
{
Parse_start ps;
ps.str = s;
ps.start_location_ = i;
ps.safe_ = safe;
+ ps.parser_ = parser;
SCM ans = parse_protect_global ? protected_ly_parse_scm (&ps)
: internal_ly_parse_scm (&ps);
(define-safe-public (set-global-staff-size sz)
"Set the default staff size, where SZ is thought to be in PT."
(let* ((current-mod (current-module))
- (pap (eval '$defaultpaper current-mod))
+ (parser (eval 'parser current-mod))
+ (pap (ly:parser-lookup parser '$defaultpaper))
(in-layout? (or (module-defined? current-mod 'is-paper)
(module-defined? current-mod 'is-layout)))