]> git.donarmstrong.com Git - lilypond.git/commitdiff
(LY_DEFINE): move parse-file function
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 11 Apr 2004 15:50:18 +0000 (15:50 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 11 Apr 2004 15:50:18 +0000 (15:50 +0000)
from input-file-results. Remove input-file-results.*

14 files changed:
lily/book.cc
lily/include/input-file-results.hh [deleted file]
lily/include/my-lily-parser.hh
lily/input-file-results.cc
lily/lexer.ll
lily/main.cc
lily/my-lily-lexer.cc
lily/my-lily-parser.cc
lily/paper-def.cc
lily/paper-outputter.cc
lily/paper-score.cc
lily/parser.yy
lily/performance.cc
lily/score.cc

index e35f9d237d5e7d9d835c517c1ac9545a2ce99524..32985c9cca122e57195ac96f1cb93ea1f3fcd485 100644 (file)
@@ -13,7 +13,6 @@
 #include "book.hh"
 #include "global-context.hh"
 #include "ly-module.hh"
-#include "input-file-results.hh"
 #include "main.hh"
 #include "music-iterator.hh"
 #include "music-output-def.hh"
diff --git a/lily/include/input-file-results.hh b/lily/include/input-file-results.hh
deleted file mode 100644 (file)
index cff21cb..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-/*   
-  file-results.hh -- declare functions for processing one input file.
-  
-  source file of the GNU LilyPond music typesetter
-  
-  (c) 1998--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-  
- */
-
-#ifndef FILE_RESULTS_HH
-#define FILE_RESULTS_HH
-
-#include "lily-guile.hh"
-
-
-SCM ly_parse_file (SCM);
-
-#endif /* FILE_RESULTS_HH */
-
index 05393324d58f80e75d778231a6b01eaf13cfb09c..af173c5317e4674da0bf9a9920c8107021754a76 100644 (file)
@@ -82,4 +82,6 @@ private:
   friend int yyparse (void*);
 };
 
+SCM ly_parse_file (SCM);
+
 #endif // MY_LILY_PARSER_HH
index 5049a6bcac770ec43ed52bbd8fae06643e652a0e..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,211 +0,0 @@
-/*
-  input-file-results.cc -- implement some globals
-
-  source file of the GNU LilyPond music typesetter
-
-  (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-*/
-#include "config.h"
-
-#include <errno.h>
-#include <sys/types.h>
-#include <stdio.h>
-
-
-#if HAVE_SYS_STAT_H 
-#include <sys/stat.h>
-#endif
-#include <unistd.h>
-
-
-#include "main.hh"
-#include "score.hh"
-#include "string.hh"
-#include "paper-def.hh"
-#include "warn.hh"
-#include "parray.hh"
-#include "file-path.hh"
-#include "input-file-results.hh"
-#include "my-lily-parser.hh"
-#include "source.hh"
-#include "lily-version.hh"
-#include "scm-hash.hh"
-#include "ly-module.hh"
-
-bool store_locations_global_b;
-
-/*
-  TODO: should merge with My_lily_parser. 
- */
-
-/*
-  no ! suffix since it doesn't modify 1st argument.
- */
-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.
-   */
-  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);
-  store_locations_global_b = is_procedure (val);
-  return SCM_UNSPECIFIED;
-}
-
-void
-write_dependency_file (String fn,
-                      Array<String> targets,
-                      Array<String> deps)
-{
-  const int WRAPWIDTH = 65;
-
-  progress_indication (_f ("dependencies output to `%s'...", fn.to_str0 ()));
-  progress_indication ("\n");
-  FILE * f = fopen  (fn.to_str0 (), "w");
-  if (!f)
-    warning (_f ("can't open file: `%s'", fn));
-
-  fprintf (f, "# Generated automatically by: %s\n", gnu_lilypond_version_string ().to_str0 ());
-  
-  String out;
-  for (int i=0; i < targets.size (); i ++)
-     out += dependency_prefix_global + targets[i] + " ";
-  out +=  ": ";
-
-  for (int i=0; i < deps.size (); i ++)
-    {
-      if (out.length () > WRAPWIDTH)
-       {
-         fprintf (f, "%s\\\n", out.to_str0 ());
-         out = "  ";
-       }
-      String dep = deps[i];
-      if (!dependency_prefix_global.is_empty ())
-       {
-         if (dep.index ('/') < 0)
-           dep = dependency_prefix_global + dep;
-       }
-      out  += " " +  dep;
-    }
-  fprintf (f, "%s\n",  out.to_str0 ());
-}
-
-/* Distill full input file name from command argument.  PATH describes
-   file name with added default extension, ".ly" if none.  "-" is
-   STDIN.  */
-Path
-distill_inname (String str)
-{
-  Path p = split_path (str);
-  if (str.is_empty () || str == "-")
-    p.base = "-";
-  else
-    {
-      String orig_ext = p.ext;
-      char const *extensions[] = {"ly", "", 0};
-      for (int i = 0; extensions[i]; i++)
-       {
-         p.ext = orig_ext;
-         if (*extensions[i] && !p.ext.is_empty ())
-           p.ext += ".";
-         p.ext += extensions[i];
-         if (!global_path.find (p.to_string ()).is_empty ())
-             break;
-       }
-      /* Reshuffle extension */
-      p = split_path (p.to_string ());
-    }
-  return p;
-}
-
-LY_DEFINE(ly_parse_file, "ly:parse-file",
-         1,0,0,
-         (SCM name),
-         "Parse a single @code{.ly} file. If this fails, then throw @code{ly-file-failed} key. "
-         )
-{
-  SCM_ASSERT_TYPE (is_string (name), name, SCM_ARG1, __FUNCTION__, "string");
-  char const *file = SCM_STRING_CHARS(name);
-  
-  String infile (file);
-  Path inpath = distill_inname (infile);
-  
-  /* By default, use base name of input file for output file name */
-  Path outpath = inpath;
-  if (inpath.to_string () != "-")
-    outpath.ext = output_format_global;
-  
-  /* By default, write output to cwd; do not copy directory part
-     of input file name */
-  outpath.root = "";
-  outpath.dir = "";
-  
-  if (!output_name_global.is_empty ())
-    outpath = split_path (output_name_global);
-  
-  String init;
-  if (!init_name_global.is_empty ())
-    init = init_name_global;
-  else
-    init = "init.ly";
-  
-  String in_file = inpath.to_string ();
-  String out_file = outpath.to_string ();
-
-
-  if (init.length () && global_path.find (init).is_empty ())
-    {
-      warning (_f ("can't find init file: `%s'", init));
-      warning (_f ("(search path: `%s')", global_path.to_string ().to_str0 ()));
-      exit (2);
-    }
-
-  if ((in_file != "-") && global_path.find (in_file).is_empty ())
-    {
-      warning (_f ("can't find file: `%s'", in_file));
-      scm_throw (ly_symbol2scm ("ly-file-failed"), scm_list_1 (scm_makfrom0str (in_file.to_str0 ())));
-    }
-  else
-    {
-      Sources sources;
-      sources.set_path (&global_path);
-  
-      progress_indication (_f ("Now processing `%s'", in_file.to_str0 ()));
-      progress_indication ("\n");
-
-      My_lily_parser parser (&sources);
-      parser.parse_file (init, in_file, out_file);
-  
-
-
-#if 0
-      // fixme dependencies
-      if (dependency_global_b)
-       {
-         Path p = split_path (output);
-         p.ext = "dep";
-         write_dependency_file (p.to_string (),
-                                target_strings_,
-                                inclusion_names_);
-       }
-#endif
-  
-      if (parser.error_level_)
-       {
-         /*
-           TODO: pass renamed input file too.
-         */
-         scm_throw (ly_symbol2scm ("ly-file-failed"), scm_list_1 (scm_makfrom0str (in_file.to_str0 ()))); 
-       }
-    }
-  return SCM_UNSPECIFIED;
-}
index 010f5c5284910cb89003f2a8be9858e4d2c3d706..ef282d6b17124833a268efe8ae322f52a037cd07 100644 (file)
@@ -39,7 +39,6 @@ using namespace std;
 #include "string.hh"
 #include "string-convert.hh"
 #include "my-lily-lexer.hh"
-#include "input-file-results.hh"
 #include "interval.hh"
 #include "lily-guile.hh"
 #include "parser.hh"
index 7431bce28df601b951177c7cc1c9351651cb32b3..118551744028e13e81819299634f75eec91c6910 100644 (file)
@@ -26,7 +26,6 @@
 #include "string.hh"
 #include "main.hh"
 #include "file-path.hh"
-#include "input-file-results.hh"
 #include "warn.hh"
 #include "lily-guile.hh"
 #include "paper-def.hh"
  * Global options that can be overridden through command line.
  */
 
-/* Write dependencies file? */
-bool dependency_global_b = false;
-
-/* Prepend to dependencies */
-String dependency_prefix_global;
-
 /* Names of header fields to be dumped to a separate file. */
 Array<String> dump_header_fieldnames_global;
 
@@ -135,10 +128,8 @@ static Long_option_init options_static[] =
     {_i ("FIELD"), "header", 'H',  _i ("write header field to BASENAME.FIELD")},
     {_i ("DIR"), "include", 'I',  _i ("add DIR to search path")},
     {_i ("FILE"), "init", 'i',  _i ("use FILE as init file")},
-    {0, "dependencies", 'M',  _i ("write Makefile dependencies")},
     {0, "no-paper", 'm',  _i ("produce MIDI output only")},
     {_i ("FILE"), "output", 'o',  _i ("write output to FILE")},
-    {_i ("DIR"), "dep-prefix", 'P',  _i ("prepend DIR to dependencies")},
     {0, "safe-mode", 's',  _i ("run in safe mode")},
     {0, "version", 'v',  _i ("print version number")},
     {0, "verbose", 'V', _i ("be verbose")},
@@ -364,9 +355,6 @@ parse_argv (int argc, char **argv)
            }
          output_format_global = option_parser->optional_argument_str0_;
          break;
-       case 'P':
-           dependency_prefix_global = option_parser->optional_argument_str0_;
-         break;
        case 'H':
          dump_header_fieldnames_global
            .push (option_parser->optional_argument_str0_);
@@ -386,9 +374,6 @@ parse_argv (int argc, char **argv)
        case 's':
          safe_global_b = true;
          break;
-       case 'M':
-         dependency_global_b = true;
-         break; 
        case 'm':
          no_paper_global_b = true;
          break;
index dc91e7d96fd4662aabcfedaebb744e81fb1379ec..ae20b4d8efcc851ba269fa1c10ac85e89ea74e34 100644 (file)
@@ -12,7 +12,6 @@
 #include "lily-proto.hh"
 #include "scm-hash.hh"
 #include "interval.hh"
-#include "input-file-results.hh"
 #include "lily-guile.hh"
 #include "parser.hh"
 #include "keyword.hh"
index 097a941bd7c820b07d8c9e41538338c00348b188..a5604a8063d7a59177cf4d815a0c36e759fac49f 100644 (file)
@@ -7,14 +7,25 @@
        Jan Nieuwenhuizen <janneke@gnu.org>
 */
 
-#include "my-lily-parser.hh"
-#include "my-lily-lexer.hh"
-#include "warn.hh"
+#include "file-path.hh"
+#include "lily-version.hh"
+#include "ly-module.hh"
+#include "ly-module.hh"
+#include "main.hh"
 #include "main.hh"
+#include "my-lily-lexer.hh"
+#include "my-lily-parser.hh"
+#include "my-lily-parser.hh"
+#include "paper-def.hh"
+#include "parray.hh"
 #include "parser.hh"
-#include "input-file-results.hh"
-#include "ly-module.hh"
 #include "scm-hash.hh"
+#include "scm-hash.hh"
+#include "score.hh"
+#include "source.hh"
+#include "string.hh"
+#include "warn.hh"
+#include "warn.hh"
 
 My_lily_parser::My_lily_parser (Sources * sources)
 {
@@ -115,3 +126,139 @@ My_lily_parser::here_input () const
   
   return Input (hi.source_file_, bla);
 }
+
+
+/****************************************************************/
+
+
+
+bool store_locations_global_b;
+
+/*
+  TODO: should merge with My_lily_parser. 
+ */
+
+/*
+  no ! suffix since it doesn't modify 1st argument.
+ */
+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.
+   */
+  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);
+  store_locations_global_b = is_procedure (val);
+  return SCM_UNSPECIFIED;
+}
+
+
+/* Distill full input file name from command argument.  PATH describes
+   file name with added default extension, ".ly" if none.  "-" is
+   STDIN.  */
+Path
+distill_inname (String str)
+{
+  Path p = split_path (str);
+  if (str.is_empty () || str == "-")
+    p.base = "-";
+  else
+    {
+      String orig_ext = p.ext;
+      char const *extensions[] = {"ly", "", 0};
+      for (int i = 0; extensions[i]; i++)
+       {
+         p.ext = orig_ext;
+         if (*extensions[i] && !p.ext.is_empty ())
+           p.ext += ".";
+         p.ext += extensions[i];
+         if (!global_path.find (p.to_string ()).is_empty ())
+             break;
+       }
+      /* Reshuffle extension */
+      p = split_path (p.to_string ());
+    }
+  return p;
+}
+
+LY_DEFINE(ly_parse_file, "ly:parse-file",
+         1,0,0,
+         (SCM name),
+         "Parse a single @code{.ly} file. If this fails, then throw @code{ly-file-failed} key. "
+         )
+{
+  SCM_ASSERT_TYPE (is_string (name), name, SCM_ARG1, __FUNCTION__, "string");
+  char const *file = SCM_STRING_CHARS(name);
+  
+  String infile (file);
+  Path inpath = distill_inname (infile);
+  
+  /* By default, use base name of input file for output file name */
+  Path outpath = inpath;
+  if (inpath.to_string () != "-")
+    outpath.ext = output_format_global;
+  
+  /* By default, write output to cwd; do not copy directory part
+     of input file name */
+  outpath.root = "";
+  outpath.dir = "";
+  
+  if (!output_name_global.is_empty ())
+    outpath = split_path (output_name_global);
+  
+  String init;
+  if (!init_name_global.is_empty ())
+    init = init_name_global;
+  else
+    init = "init.ly";
+  
+  String in_file = inpath.to_string ();
+  String out_file = outpath.to_string ();
+
+
+  if (init.length () && global_path.find (init).is_empty ())
+    {
+      warning (_f ("can't find init file: `%s'", init));
+      warning (_f ("(search path: `%s')", global_path.to_string ().to_str0 ()));
+      exit (2);
+    }
+
+  if ((in_file != "-") && global_path.find (in_file).is_empty ())
+    {
+      warning (_f ("can't find file: `%s'", in_file));
+      scm_throw (ly_symbol2scm ("ly-file-failed"), scm_list_1 (scm_makfrom0str (in_file.to_str0 ())));
+    }
+  else
+    {
+      Sources sources;
+      sources.set_path (&global_path);
+  
+      progress_indication (_f ("Now processing `%s'", in_file.to_str0 ()));
+      progress_indication ("\n");
+
+      My_lily_parser parser (&sources);
+      parser.parse_file (init, in_file, out_file);
+  
+
+
+  
+      if (parser.error_level_)
+       {
+         /*
+           TODO: pass renamed input file too.
+         */
+         scm_throw (ly_symbol2scm ("ly-file-failed"), scm_list_1 (scm_makfrom0str (in_file.to_str0 ()))); 
+       }
+    }
+  return SCM_UNSPECIFIED;
+}
+
index 9d95e0ed18baf0e049d72c367256ec3b86e4d0f5..fb2874327c5d164407e73e45912917998a6b3392 100644 (file)
@@ -18,7 +18,6 @@
 #include "scaled-font-metric.hh"
 #include "main.hh"
 #include "scm-hash.hh"
-#include "input-file-results.hh" // urg? header_global
 #include "paper-outputter.hh"
 #include "ly-module.hh"
 
@@ -80,9 +79,6 @@ Paper_def::get_paper_outputter (String outname) const
   progress_indication (_f ("paper output to `%s'...",
                           outname == "-" ? String ("<stdout>") : outname));
 
-  // fixme: dependencies
-  //  add_target_file (outname);
-  
   Paper_outputter * po = new Paper_outputter (outname);
   Path p = split_path (outname);
   p.ext = "";
index 009eb381e147d2863f8075d1c20e04b3bec02d30..98ad110a2c3866a5313e8f328826a138754c8b5f 100644 (file)
@@ -13,7 +13,6 @@
 #include "array.hh"
 #include "dimensions.hh"
 #include "font-metric.hh"
-#include "input-file-results.hh"
 #include "input-smob.hh"
 #include "lily-guile.hh"
 #include "lily-version.hh"
index 3c7311b816f77b26fbe11ccd98bc882bfc6f3bd6..430cd52c57fefa94bbd873fbe1688bf6493f5ddd 100644 (file)
@@ -19,7 +19,6 @@
 #include "scm-hash.hh"
 #include "gourlay-breaking.hh"
 //#include "paper-outputter.hh"
-#include "input-file-results.hh"
 #include "misc.hh"
 #include "all-font-metrics.hh"
 
index 20be2022c368fbee3207548ed273bc91097876b5..b64ed2615feb7b1aa2c9e6620c99e1b1e352af8b 100644 (file)
@@ -30,7 +30,6 @@ TODO:
 #include "dimensions.hh"
 #include "event.hh"
 #include "file-path.hh"
-#include "input-file-results.hh"
 #include "input-smob.hh"
 #include "input.hh"
 #include "lily-guile.hh"
index 2a12ac1c73a1d07206b9216bae4dfcccc9b2d28e..bee85fb5f95a8e7c0d26e5aec9c47302fa7dd0ca 100644 (file)
@@ -19,7 +19,6 @@
 #include "audio-staff.hh"
 #include "performance.hh"
 #include "score.hh"
-#include "input-file-results.hh"
 #include "file-path.hh"
 #include "lily-version.hh"
 
@@ -171,9 +170,6 @@ Performance::process (String out)
   Midi_stream midi_stream (out);
   progress_indication (_f ("MIDI output to `%s'...", out));
 
-  // fixme: dependencies
-  //add_target_file (out);
-
   output (midi_stream);
   progress_indication ("\n");
   return SCM_UNDEFINED;
index bf668c1b0ff6686377597a47295874018f22f06b..811e2f2cfa4962e4d4ddff7e6414c263a27057b6 100644 (file)
@@ -24,7 +24,6 @@
 #include "ly-module.hh"
 #include "paper-book.hh"
 #include "paper-score.hh"
-#include "input-file-results.hh"
 
 
 /*