ly_c_init_guile ()
{
Guile_user::module.import ();
+ Syntax::module.boot ();
Lily::module.boot ();
scm_c_call_with_current_module (Lily::module, ly_init_ly_module, 0);
Display::module.import ();
extern Variable type_name;
extern Variable volta_bracket_calc_hook_visibility;
extern Variable write_performances_midis;
+}
+
+namespace Syntax {
+ extern Scm_module module;
+ typedef Module_variable<module> Variable;
extern Variable add_lyrics;
extern Variable argument_error;
Variable type_name ("type-name");
Variable volta_bracket_calc_hook_visibility ("volta-bracket::calc-hook-visibility");
Variable write_performances_midis ("write-performances-midis");
+}
+
+namespace Syntax {
+ Scm_module module ("ly-syntax");
Variable add_lyrics ("add-lyrics");
Variable argument_error ("argument-error");
if (scm_is_false (scm_call_1 (pred, arg)))
{
- Lily::argument_error (scm_length (args),
- pred, arg);
+ Syntax::argument_error (scm_length (args),
+ pred, arg);
SCM val = scm_car (get_signature ());
val = scm_is_pair (val) ? scm_cdr (val) : SCM_BOOL_F;
return with_loc (val, location);
if (scm_is_true (scm_call_1 (pred, res)))
return with_loc (res, location, false);
- return Lily::music_function_call_error (self_scm (), res);
+ return Syntax::music_function_call_error (self_scm (), res);
}
/* Syntactic Sugar. */
#define MAKE_SYNTAX(name, location, ...) \
LOWLEVEL_MAKE_SYNTAX (location, \
- scm_list_n (Lily::name, \
+ scm_list_n (Syntax::name, \
##__VA_ARGS__, SCM_UNDEFINED))
#define START_MAKE_SYNTAX(name, ...) \
- scm_list_n (Lily::name, \
+ scm_list_n (Syntax::name, \
##__VA_ARGS__, SCM_UNDEFINED)
#define FINISH_MAKE_SYNTAX(start, location, ...) \
;;;; You should have received a copy of the GNU General Public License
;;;; along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
-;; TODO: use separate module for syntax
-;; constructors. Also create wrapper around the constructor?
+(define ly-syntax-module (resolve-module '(ly-syntax)))
+
(defmacro define-ly-syntax (args . body)
- `(define ,args ,@body))
+ (if (pair? args)
+ `(module-define! ,ly-syntax-module ',(car args)
+ (lambda ,(cdr args) ,@body))
+ `(module-define! ,ly-syntax-module ',args ,@body)))
;; A ly-syntax constructor can access location data as (*location*).
;; This is mainly used for reporting errors and warnings. This
;; origin of the returned music object; this behaviour is usually
;; desired.
(defmacro define-ly-syntax-loc (args . body)
- `(define ,args
+ `(define-ly-syntax ,args
(let ((m ,(cons 'begin body)))
(set! (ly:music-property m 'origin) (*location*))
m)))
(*location*))
(and (pair? (car sig)) (cdar sig))))
+(define-ly-syntax music-function-call-error music-function-call-error)
+
;; Music function: Apply function and check return value.
;; args are in reverse order, rest may specify additional ones
;;