From: Han-Wen Nienhuys Date: Fri, 3 Nov 2006 00:32:37 +0000 (+0100) Subject: add debug-parser and debug-lexer options X-Git-Tag: release/2.10.0-2~34^2~19 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=13031fd9d41919303379c0f631a47d0d0c80f4d3;p=lilypond.git add debug-parser and debug-lexer options --- diff --git a/lily/include/lily-lexer.hh b/lily/include/lily-lexer.hh index 7d51b8a640..b64798823b 100644 --- a/lily/include/lily-lexer.hh +++ b/lily/include/lily-lexer.hh @@ -31,6 +31,7 @@ private: int identifier_type (SCM); char escaped_char (char) const; + Lily_parser *parser_; Keyword_table *keytable_; SCM scopes_; SCM start_module_; @@ -41,7 +42,7 @@ public: void *lexval; Input *lexloc; bool is_main_input_; - + Sources *sources_; /* Scheme hash tables with (oct name acc) values, and symbol keys. */ @@ -51,7 +52,7 @@ public: int error_level_; Input last_input_; - Lily_lexer (Sources *); + Lily_lexer (Sources *, Lily_parser *); Lily_lexer (Lily_lexer const &); int yylex (); diff --git a/lily/lily-lexer.cc b/lily/lily-lexer.cc index b7460bb609..1f39bd2425 100644 --- a/lily/lily-lexer.cc +++ b/lily/lily-lexer.cc @@ -21,6 +21,8 @@ using namespace std; #include "scm-hash.hh" #include "source-file.hh" #include "warn.hh" +#include "program-option.hh" +#include "lily-parser.hh" static Keyword_ent the_key_tab[] = { @@ -80,8 +82,9 @@ static Keyword_ent the_key_tab[] {0, 0} }; -Lily_lexer::Lily_lexer (Sources *sources) +Lily_lexer::Lily_lexer (Sources *sources, Lily_parser *parser) { + parser_ = parser; keytable_ = new Keyword_table (the_key_tab); chordmodifier_tab_ = SCM_EOL; pitchname_tab_stack_ = SCM_EOL; @@ -201,7 +204,10 @@ Lily_lexer::lookup_identifier (string name) void Lily_lexer::start_main_input () { - // yy_flex_debug = 1; + yy_flex_debug = get_program_option ("debug-lexer"); + parser_->set_yydebug (get_program_option ("debug-parser")); + + new_input (main_input_name_, sources_); /* Do not allow \include in --safe-mode */ @@ -304,6 +310,8 @@ Lily_lexer::mark_smob (SCM s) Lily_lexer *lexer = (Lily_lexer *) SCM_CELL_WORD_1 (s); scm_gc_mark (lexer->chordmodifier_tab_); + if (lexer->parser_) + scm_gc_mark (lexer->parser_->self_scm ()); scm_gc_mark (lexer->pitchname_tab_stack_); scm_gc_mark (lexer->start_module_); return lexer->scopes_; diff --git a/lily/lily-parser.cc b/lily/lily-parser.cc index d1c94b0c19..a339e8a8f5 100644 --- a/lily/lily-parser.cc +++ b/lily/lily-parser.cc @@ -36,7 +36,7 @@ Lily_parser::Lily_parser (Sources *sources) smobify_self (); - lexer_ = new Lily_lexer (sources_); + lexer_ = new Lily_lexer (sources_, this); lexer_->unprotect (); } @@ -95,7 +95,6 @@ Lily_parser::parse_file (string init, string name, string out_name) lexer_->main_input_name_ = name; message (_ ("Parsing...")); - // progress_indication ("\n"); set_yydebug (0); @@ -164,9 +163,8 @@ Lily_parser::clear () { while (lexer_->has_scope ()) lexer_->remove_scope (); - - } + lexer_ = 0; } diff --git a/scm/lily.scm b/scm/lily.scm index 282fdb758e..7bd67c0fc6 100644 --- a/scm/lily.scm +++ b/scm/lily.scm @@ -25,6 +25,9 @@ (debug-gc-assert-parsed-dead #f "for memory debugging: ensure that all refs to parsed objects are dead.") + (debug-midi #f "generate human readable MIDI") + (debug-parser #f "debug the bison parser") + (debug-lexer #f "debug the flex lexer") (debug-midi #f "generate human readable MIDI") (delete-intermediate-files #f "delete unusable PostScript files")