}
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;
{
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_fluids
+ (scm_list_2 (ly_lily_module_constant ("%parser"),
+ ly_lily_module_constant ("%location")),
+ scm_list_2 (parser->self_scm (),
+ i.smobbed_copy ()),
+ parse_protect_global ? protected_ly_eval_scm
+ : catch_protected_eval_body, (void *) &ps);
+
scm_remember_upto_here_1 (form);
return ans;
}
;; function has not actually started. A parser clone, in contrast,
;; can run and complete synchronously and shares the module with
;; the current parser.
- (ly:parser-parse-string (ly:parser-clone parser)
+ (ly:parser-parse-string (ly:parser-clone (*parser*))
"\\include \"declarations-init.ly\"")))
-#(note-names-language parser default-language)
+#(note-names-language (*parser*) default-language)
-#(define location #f)
#(define toplevel-scores (list))
#(define toplevel-bookparts (list))
#(define $defaultheader #f)
#(use-modules (ice-9 pretty-print))
$(if (ly:get-option 'include-settings)
- (ly:parser-include-string parser
+ (ly:parser-include-string (*parser*)
(format #f "\\include \"~a\"" (ly:get-option 'include-settings))))
\maininput
(ly:book-add-score! book score))
(reverse! toplevel-scores)))
(set! toplevel-scores (list))
- (book-handler parser book)))
+ (book-handler (*parser*) book)))
((or (pair? toplevel-scores) output-empty-score-list)
(let ((book (apply ly:make-book $defaultpaper
$defaultheader toplevel-scores)))
(set! toplevel-scores (list))
- (book-handler parser book)))))
+ (book-handler (*parser*) book)))))
-#(if (eq? expect-error (ly:parser-has-error? parser))
- (ly:parser-clear-error parser)
+#(if (eq? expect-error (ly:parser-has-error? (*parser*)))
+ (ly:parser-clear-error (*parser*))
(if expect-error
- (ly:parser-error parser (_ "expected error, but none found"))))
+ (ly:parser-error (*parser*) (_ "expected error, but none found"))))
(string-downcase
(car (string-tokenize (utsname:sysname (uname)) char-set:letter)))))
+;; We don't use (srfi srfi-39) (parameter objects) here because that
+;; does not give us a name/handle to the underlying fluids themselves.
+
+(define %parser (make-fluid))
+(define %location (make-fluid))
+;; No public setters: should not get overwritten in action
+(define-public (*parser*) (fluid-ref %parser))
+(define-public (*location*) (fluid-ref %location))
+
+;; It would be nice to convert occurences of parser/location to
+;; (*parser*)/(*location*) using the syncase module but it is utterly
+;; broken in GUILE 1 and would require changing a lot of unrelated
+;; innocuous constructs which just happen to fall apart with
+;; inscrutable error messages.
+
;;
;; Session-handling variables and procedures.
;;
(ly:parser-error parser (_ "error in #{ ... #}")))
result))
(list embedded-lilypond
- 'parser lily-string filename line
+ (list *parser*) lily-string filename line
(cons 'list (reverse! closures))
- 'location)))
+ (list *location*))))
(read-hash-extend #\{ read-lily-expression)