]> git.donarmstrong.com Git - lilypond.git/commitdiff
patch::: 1.2.15.jcn4
authorJan Nieuwenhuizen <janneke@gnu.org>
Wed, 20 Oct 1999 15:15:07 +0000 (17:15 +0200)
committerJan Nieuwenhuizen <janneke@gnu.org>
Wed, 20 Oct 1999 15:15:07 +0000 (17:15 +0200)
pl 15.jcn4
- direct #... to scm parser  (Tanks to Gary Houston)

CHANGES
VERSION
input/test/embedded-scm.ly [new file with mode: 0644]
lily/include/lily-guile.hh
lily/lexer.ll
lily/lily-guile.cc
lily/my-lily-lexer.cc
lily/my-lily-parser.cc
lily/parser.yy
ly/accordion-defs.ly
ly/script.ly

diff --git a/CHANGES b/CHANGES
index fd5211f724fb2ea36025230b9547c150b1b809fb..3c38ef3ad1cbe7c0fd530c2a39bfcb0afeebecf3 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+pl 15.jcn4
+       - direct #... to scm parser  (Tanks to Gary Houston)
+
 pl 15.jcn3
        - bf: smob fix?
        - mutopia/doc target 'local-web':
diff --git a/VERSION b/VERSION
index 2898e1d987f698b294c0ab48a8e22e13ee29c00b..bac0e1065b825d6a6f381b4278d2be4588b2b655 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond
 MAJOR_VERSION=1
 MINOR_VERSION=2
 PATCH_LEVEL=15
-MY_PATCH_LEVEL=jcn3
+MY_PATCH_LEVEL=jcn4
 
 # use the above to send patches: MY_PATCH_LEVEL is always empty for a
 # released version.
diff --git a/input/test/embedded-scm.ly b/input/test/embedded-scm.ly
new file mode 100644 (file)
index 0000000..d530c85
--- /dev/null
@@ -0,0 +1,4 @@
+#(begin (newline)(display "hello world")(newline))\score{
+       \notes\relative c'{ c }
+}
+
index 90773ac8d1da641a8929aba0bba05df1c05acc2d..55719cb91bd40d2194570207695fb0d2ff5a4971 100644 (file)
@@ -24,6 +24,7 @@ SCM ly_set_scm (String name , SCM val);
 SCM ly_append (SCM a, SCM b);
 SCM ly_eval (SCM a);
 SCM ly_func_o (char const* name);
+SCM ly_parse_scm (char const* s, int* n);
 SCM ly_quote_scm (SCM s);
 void ly_display_scm (SCM s);
 String ly_scm2string (SCM s);
index 42e4996c580bfd0e4d995864ea7d6bd836943947..a59d10de16b8a379ee3ee4fe4f44caae925afebe 100644 (file)
@@ -4,7 +4,8 @@
 
   source file of the LilyPond music typesetter
 
-  (c) 1996,1997 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1996--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+           Jan Nieuwenhuizen <janneke@gnu.org>
 */
 
 
@@ -29,6 +30,7 @@
 #include "my-lily-lexer.hh"
 #include "array.hh"
 #include "interval.hh"
+#include "lily-guile.hh"
 #include "parser.hh"
 #include "debug.hh"
 #include "main.hh"
@@ -231,6 +233,33 @@ HYPHEN             --
        cerr << _ ("white expected") << endl;
        exit (1);
 }
+<INITIAL,chords,lyrics,notes># { //embedded scm
+       //char const* s = YYText () + 1;
+       char* s = (char*)YYText () + 1;
+       int n = 0;
+       if (!main_input_b_ && safe_global_b) {
+               error (_ ("Can't evaluate Scheme in safe mode"));
+               return SCM_EOL;
+       }
+       /*
+         urg: replace 0 char with original value
+        */
+       *s = (char)yyinput ();
+       yylval.scm = ly_parse_scm (s, &n);
+       
+       if (!n)
+               unput (*s);
+       else
+               n--;
+       /*
+         urg, this
+               yyin->seekg (n, ios::cur);
+         doesn't work, is there no other way?
+        */
+       for (int i=0; i < n; i++)
+               yyinput ();
+       return SCM_T;
+}
 <notes>{
        {ALPHAWORD}     {
                return scan_bare_word (YYText ());
index 311397cdd857a66669592b0a828b0928a4a4b218..ded411da835fb6726da646beb71e6e48c969f5c9 100644 (file)
@@ -33,6 +33,41 @@ ly_ch_C_eval_scm (char const*c)
   return gh_eval_str ((char*)c);
 }
 
+  
+/*
+  Pass string to scm parser, evaluate one expression.
+  Return result value and #chars read.
+
+  Thanks to Gary Houston <ghouston@freewire.co.uk>
+
+  Need guile-1.3.4 (>1.3 anyway) for ftell on str ports -- jcn
+*/
+SCM
+ly_parse_scm (char const* s, int* n)
+{
+  SCM str = gh_str02scm ((char*)s);
+  SCM port = scm_mkstrport (SCM_INUM0, str, SCM_OPN | SCM_RDNG,
+                            "scm_eval_0str");
+  SCM from = scm_ftell (port);
+
+  SCM form;
+  SCM answer = SCM_UNSPECIFIED;
+
+  /* Read expression from port */
+  if (!SCM_EOF_OBJECT_P (form = scm_read (port)))
+    answer = scm_eval_x (form);
+
+  SCM to = scm_ftell (port);
+  *n = gh_scm2int (to) - gh_scm2int (from);
+
+  /* Don't close the port here; if we re-enter this function via a
+     continuation, then the next time we enter it, we'll get an error.
+     It's a string port anyway, so there's no advantage to closing it
+     early.  */
+
+  return answer;
+}
+
 /*
   scm_m_quote doesn't use any env, but needs one for a good signature in GUILE.
 */
index 49d84d6335efbb3619cc61a937be719042924de3..d58d5a49b793bf9541f558b60db847f4bd3960fd 100644 (file)
@@ -11,6 +11,7 @@
 #include "notename-table.hh"
 #include "interval.hh"
 #include "identifier.hh"
+#include "lily-guile.hh"
 #include "parser.hh"
 #include "keyword.hh"
 #include "my-lily-lexer.hh"
@@ -64,8 +65,6 @@ static Keyword_ent the_key_tab[]={
   {"repeat", REPEAT},
   {"repetitions", REPETITIONS},
   {"addlyrics", ADDLYRICS},
-  {"scm", SCM_T},
-  {"scmfile", SCMFILE},
   {"score", SCORE},
   {"script", SCRIPT},
   {"shape", SHAPE},
index aaae6a6d943136588b8d678b5794c1f4114584f9..11ae2eeda45ac03929a2b17894f45bf7b3e8e4c8 100644 (file)
@@ -14,6 +14,7 @@
 #include "music-list.hh"
 #include "musical-request.hh"
 #include "command-request.hh"
+#include "lily-guile.hh"
 #include "parser.hh"
 #include "scope.hh"
 #include "file-results.hh"
index 4d84041f3866a08ff32d687678451aacae4409fe..c57599860d7bef87674faef54510edee24f3e4eb 100644 (file)
@@ -5,7 +5,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1997 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c)  1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
            Jan Nieuwenhuizen <janneke@gnu.org>
 */
 
@@ -99,6 +99,7 @@ print_mudela_versions (ostream &os)
     Real real;
     Request * request;
     Scalar *scalar;
+    SCM scm;
 
     String *string;
     Tempo_req *tempo;
@@ -170,7 +171,6 @@ yylex (YYSTYPE *s,  void * v_l)
 %token REPETITIONS
 %token ADDLYRICS
 %token SCM_T
-%token SCMFILE
 %token SCORE
 %token SCRIPT
 %token SHAPE
@@ -208,6 +208,7 @@ yylex (YYSTYPE *s,  void * v_l)
 %token <real>  REAL
 %token <string>        DURATION RESTNAME
 %token <string>        STRING
+%token <scm>   SCM_T
 %token <i>     UNSIGNED
 
 
@@ -239,6 +240,7 @@ yylex (YYSTYPE *s,  void * v_l)
 %type <duration>       duration_length
 
 %type <scalar>  scalar
+%type <scm>  embedded_scm
 %type <music>  Music Sequential_music Simultaneous_music Music_sequence
 %type <music>  relative_music re_rhythmed_music
 %type <music>  property_def translator_change
@@ -300,21 +302,14 @@ toplevel_expression:
                        Midi_def_identifier ($1, MIDI_IDENTIFIER);
                THIS->lexer_p_->set_identifier ("$defaultmidi", id)
        }
-       | embedded_scm { 
-       }
+       | embedded_scm {
+               // junk value
+       }       
        ;
 
 embedded_scm:
-       SCMFILE STRING semicolon {
-               read_lily_scm_file (*$2);
-               delete $2;
-       }
-       | SCM_T STRING semicolon {
-               if (THIS->lexer_p_->main_input_b_ && safe_global_b)
-                       error (_("Can't evaluate Scheme in safe mode"));
-               gh_eval_str ($2->ch_l ());
-               delete $2;
-       };
+       SCM_T
+       ;
 
 
 chordmodifiers_block:
index b4051d111a8e5059271082d6437b6980424e052f..1c90a9c16f88c6db8d0e810cbf54d994eab7a43b 100644 (file)
@@ -6,7 +6,7 @@
 % 16' = S
 %
 
-\scmfile "accordion-script.scm";
+#(primitive-load-path "accordion-script.scm")
 
 accDiscant = \script "accDiscant"
 accDiscantF = \script "accDiscantF"
index 38f89853d243975e4f7e23f06cfc9e5bef20d61b..430f31d9edbc82ceda7a033e63f3d9b3fc9cfb68 100644 (file)
@@ -1,5 +1,5 @@
 
-\scmfile "script.scm";
+#(primitive-load-path "script.scm")
 
 "dash-hat" = "marcato"
 "dash-plus" = "stopped"
@@ -44,4 +44,4 @@ prallmordent = \script "prallmordent"
 upprall = \script "upprall"
 downprall = \script "downprall"
 segno = \script "segno"
-coda = \script "coda"
\ No newline at end of file
+coda = \script "coda"