From ce46fff9c21d9827637aeebd6e34b2b8841cc69e Mon Sep 17 00:00:00 2001 From: hanwen Date: Mon, 29 Jul 2002 13:22:48 +0000 Subject: [PATCH] (ly_parse_scm): add line/col/file locations SCM port for parser. --- ChangeLog | 5 +++++ lily/include/lily-guile.hh | 4 ++-- lily/lexer.ll | 2 +- lily/lily-guile.cc | 10 +++++++++- lily/main.cc | 3 ++- 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index acde777abf..2c27e9ef55 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2002-07-29 Han-Wen Nienhuys + + * lily/lily-guile.cc (ly_parse_scm): add line/col/file + locations SCM port for parser. + 2002-07-28 Rune Zedeler * lily/note-spacing.cc (stem_dir_correction) Add property diff --git a/lily/include/lily-guile.hh b/lily/include/lily-guile.hh index a14f2be4aa..e628695860 100644 --- a/lily/include/lily-guile.hh +++ b/lily/include/lily-guile.hh @@ -156,8 +156,8 @@ Interval ly_scm2interval (SCM); Slice int_list_to_slice (SCM l); SCM ly_interval2scm (Drul_array); - -SCM ly_parse_scm (char const* s, int* n); +struct Input; +SCM ly_parse_scm (char const* s, int *, Input); SCM ly_quote_scm (SCM s); SCM ly_type (SCM); bool type_check_assignment (SCM val, SCM sym, SCM type_symbol) ; diff --git a/lily/lexer.ll b/lily/lexer.ll index 295613c172..f6b0a40a4a 100644 --- a/lily/lexer.ll +++ b/lily/lexer.ll @@ -258,7 +258,7 @@ HYPHEN -- yylval.scm = SCM_EOL; return SCM_T; } - yylval.scm = ly_parse_scm (s, &n); + yylval.scm = ly_parse_scm (s, &n, here_input()); for (int i=0; i < n; i++) { diff --git a/lily/lily-guile.cc b/lily/lily-guile.cc index 53028fb926..7f4ceb80b0 100644 --- a/lily/lily-guile.cc +++ b/lily/lily-guile.cc @@ -88,12 +88,20 @@ ly_write2scm (SCM s) Need guile-1.3.4 (>1.3 anyway) for ftell on str ports -- jcn */ +/* + should move this func elsewhere (?) + */ SCM -ly_parse_scm (char const* s, int* n) +ly_parse_scm (char const* s, int* n, Input ip) { SCM str = ly_str02scm (s); SCM port = scm_mkstrport (SCM_INUM0, str, SCM_OPN | SCM_RDNG, "ly_eval_scm_0str"); + + scm_set_port_filename_x (port, scm_makfrom0str (ip.file_string ().str0())); + scm_set_port_line_x (port, gh_int2scm (ip.line_number ())); + scm_set_port_column_x (port, gh_int2scm (ip.column_number())); + SCM from = scm_ftell (port); SCM form; diff --git a/lily/main.cc b/lily/main.cc index c6a45e4e67..2ef9af2f5a 100644 --- a/lily/main.cc +++ b/lily/main.cc @@ -338,7 +338,8 @@ main_prog (void *, int, char **) /* Junk this. We should make real modules iso. just loading files. */ prepend_load_path (String (prefix_directory[i]) + "/scm"); } - + + SCM_RECORD_POSITIONS_P = 1; if (verbose_global_b) dirinfo (stderr); -- 2.39.5