]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 4483: parser.yy: reimplement MAKE_SYNTAX using with_location
authorDavid Kastrup <dak@gnu.org>
Sat, 4 Jul 2015 14:45:49 +0000 (16:45 +0200)
committerDavid Kastrup <dak@gnu.org>
Tue, 14 Jul 2015 05:12:29 +0000 (07:12 +0200)
lily/parser.yy

index ef0962c05eafc9e32e3253a88762c781c0bd110b..25b7cd86c3e95f1ec6da4379b9fb6db3575fca6a 100644 (file)
@@ -187,39 +187,30 @@ Lily_parser::parser_error (Input const *i, Lily_parser *parser, SCM *, const str
                               parser->lexer_->override_input (spot))
 
 /* ES TODO:
-- Don't use lily module, create a new module instead.
 - delay application of the function
 */
 
-static SCM
-syntax_call (void *arg)
-{
-       SCM sarg = reinterpret_cast <SCM> (arg);
-       return scm_apply_0 (scm_car (sarg), scm_cdr (sarg));
-}
-
-#define LOWLEVEL_MAKE_SYNTAX(location, args)                           \
-       scm_c_with_fluid                                                \
-               (Lily::f_location,                                      \
-                parser->lexer_->override_input (location).smobbed_copy (), \
-                syntax_call,                                           \
-                reinterpret_cast <void*> (args))
+#define LOWLEVEL_MAKE_SYNTAX(location, proc, ...)                      \
+       with_location                                                   \
+               (parser->lexer_->override_input (location).smobbed_copy (), \
+                proc,                                                  \
+                ##__VA_ARGS__)
 
 /* Syntactic Sugar. */
 #define MAKE_SYNTAX(name, location, ...)                               \
-       LOWLEVEL_MAKE_SYNTAX (location,                                 \
-                             scm_list_n (Syntax::name,                 \
-                                         ##__VA_ARGS__, SCM_UNDEFINED))
+       LOWLEVEL_MAKE_SYNTAX (location, Syntax::name, ##__VA_ARGS__)
 
 #define START_MAKE_SYNTAX(name, ...)                                   \
-       scm_list_n (Syntax::name,                                       \
-                   ##__VA_ARGS__, SCM_UNDEFINED)
+       scm_list_n (Syntax::name, ##__VA_ARGS__, SCM_UNDEFINED)
 
 #define FINISH_MAKE_SYNTAX(start, location, ...)                       \
-       LOWLEVEL_MAKE_SYNTAX (location,                                 \
-                             scm_append_x                              \
-                             (scm_list_2 (start, scm_list_n            \
-                                          (__VA_ARGS__, SCM_UNDEFINED))))
+       LOWLEVEL_MAKE_SYNTAX                                            \
+               (location,                                              \
+                Guile_user::apply,                                     \
+                scm_car (start),                                       \
+                scm_append_x                                           \
+                (scm_list_2 (scm_cdr (start),                          \
+                             scm_list_n (__VA_ARGS__, SCM_UNDEFINED))))
 
 SCM get_next_unique_context_id ();
 SCM get_next_unique_lyrics_context_id ();