]> git.donarmstrong.com Git - lilypond.git/commitdiff
(ly:parser-parse-string): New function.
authorJan Nieuwenhuizen <janneke@gnu.org>
Sat, 24 Apr 2004 21:48:02 +0000 (21:48 +0000)
committerJan Nieuwenhuizen <janneke@gnu.org>
Sat, 24 Apr 2004 21:48:02 +0000 (21:48 +0000)
ChangeLog
lily/ly-module.cc
lily/my-lily-parser.cc
scm/lily.scm

index 6efc1d00548955f6ac24aa8373cc8ff7310b02d9..c4bb55353851762285188283e33ffe95f2f54d37 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2004-04-24  Jan Nieuwenhuizen  <janneke@gnu.org>
+
+       * lily/my-lily-parser.cc (ly:parser-parse-string): New function.
+
 2004-04-21  Jan Nieuwenhuizen  <janneke@gnu.org>
 
        * input/regression/newaddlyrics.ly: Remove lilypond-book kludge.
index 1921c9084e262ebef3f623d68806c575b5150690..e536e9503a8aff2c3813013a59167fc32f09dd7e 100644 (file)
@@ -17,7 +17,7 @@
 static int module_count;
 
 void
-ly_init_anonymous_module (void * data)
+ly_init_anonymous_module (void *data)
 {
   (void) data;
   scm_c_use_module ("lily");
@@ -27,7 +27,7 @@ SCM
 ly_make_anonymous_module ()
 {
   String s = "*anonymous-ly-" + to_string (module_count++) +  "*";
-  SCM mod = scm_c_define_module (s.to_str0(), ly_init_anonymous_module, 0);
+  SCM mod = scm_c_define_module (s.to_str0 (), ly_init_anonymous_module, 0);
   return mod;
 }
 
index 47cbade68e5d89a8e107fae02aeaf565a4c4aca9..5148a238d14bf190d2be13f6d819fbcd6fd9d9fd 100644 (file)
@@ -174,25 +174,22 @@ My_lily_parser::here_input () const
  */
 bool store_locations_global_b;
 
-/*
-  no ! suffix since it doesn't modify 1st argument.
- */
+/* Do not append `!' suffix, since 1st argument is not modified. */
 LY_DEFINE (ly_set_point_and_click, "ly:set-point-and-click", 1, 0, 0,
          (SCM what),
          "Set the options for Point-and-click source specials output. The\n"
 "argument is a symbol.  Possible options are @code{none} (no source specials),\n"
 "@code{line} and @code{line-column}")
 {
-  /*
-    UGH.
-   */
+  /* UGH. */
   SCM val = SCM_BOOL_F;
   if (ly_symbol2scm ("line-column") == what)
     val = scm_c_eval_string ("line-column-location");
   else if (what == ly_symbol2scm ("line"))
     val = scm_c_eval_string ("line-location");
 
-  scm_module_define (global_lily_module, ly_symbol2scm ("point-and-click"), val);
+  scm_module_define (global_lily_module, ly_symbol2scm ("point-and-click"),
+                    val);
   store_locations_global_b = ly_c_procedure_p (val);
   return SCM_UNSPECIFIED;
 }
@@ -282,6 +279,8 @@ LY_DEFINE (ly_parse_file, "ly:parse-file",
       progress_indication ("\n");
 
       My_lily_parser *parser = new My_lily_parser (&sources);
+      scm_module_define (global_lily_module, ly_symbol2scm ("parser"),
+                        parser->self_scm ());
       parser->parse_file (init, in_file, out_file);
 
       bool error = parser->error_level_;
@@ -305,12 +304,35 @@ LY_DEFINE (ly_parse_string, "ly:parse-string",
   Sources sources;
   sources.set_path (&global_path);
   My_lily_parser *parser = new My_lily_parser (&sources);
+  scm_module_define (global_lily_module, ly_symbol2scm ("parser"),
+                    parser->self_scm ());
   parser->parse_string (ly_scm2string (ly_code));
   parser = 0;
   
   return SCM_UNSPECIFIED;
 }
 
+LY_DEFINE (ly_parser_parse_string, "ly:parser-parse-string",
+          2, 0, 0,
+          (SCM parser_smob, SCM ly_code),
+          "Parse the string LY_CODE with PARSER_SMOB."
+          "Upon failure, throw @code{ly-file-failed} key.")
+{
+#if 0
+  SCM_ASSERT_TYPE (ly_c_parser_p (parser), music, SCM_ARG1, __FUNCTION__, "parser");
+#endif
+  SCM_ASSERT_TYPE (ly_c_string_p (ly_code), ly_code, SCM_ARG1, __FUNCTION__, "string");
+
+#if 1
+  My_lily_parser *parser = unsmob_my_lily_parser (parser_smob);
+#else
+  /* New parser, copy vars but no state?  */
+#endif
+  parser->parse_string (ly_scm2string (ly_code));
+  
+  return SCM_UNSPECIFIED;
+}
+
 static Music_output_def*
 get_paper (My_lily_parser *parser)
 {
index 5ca36f86f8ebd8f4d5c982f8f1413002f5330123..f2170726034bea09d3ccadc2e64c90f58e34f69e 100644 (file)
@@ -45,6 +45,8 @@
 
 (define-public point-and-click #f)
 
+(define-public parser #f)
+
 (define-public (lilypond-version)
   (string-join
    (map (lambda (x) (if (symbol? x)