2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 1997--2014 Han-Wen Nienhuys <hanwen@xs4all.nl>
6 LilyPond is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 LilyPond is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef MY_LILY_LEXER_HH
21 #define MY_LILY_LEXER_HH
23 #include "includable-lexer.hh"
26 #include "duration.hh"
34 class Lily_lexer : public Includable_lexer
36 DECLARE_SMOBS (Lily_lexer);
39 int lookup_keyword (const string&);
40 int scan_bare_word (const string&);
41 int scan_escaped_word (const string&);
42 int scan_shorthand (const string&);
43 int scan_scm_id (SCM);
44 int identifier_type (SCM);
45 char escaped_char (char) const;
46 const char *YYText_utf8 ();
49 Keyword_table *keytable_;
52 Input override_input_;
53 SCM eval_scm (SCM, Input, char extra_token = 0);
55 SCM eval_scm_token (SCM sval, Input w)
58 return eval_scm (sval, w, '#');
64 vsize main_input_level_;
68 /* Scheme hash tables with (oct name acc) values, and symbol keys. */
69 SCM chordmodifier_tab_;
70 SCM pitchname_tab_stack_;
75 Lily_lexer (Sources *, Lily_parser *);
76 Lily_lexer (Lily_lexer const &, Lily_parser *, SCM);
79 void add_lexed_char (int);
81 void prepare_for_next_token ();
82 int try_special_identifiers (SCM *, SCM);
83 Input here_input () const;
84 Input const &override_input (Input const &) const;
87 SCM set_current_scope ();
88 bool has_scope () const;
91 void start_main_input ();
93 virtual void new_input (const string &s, Sources *);
94 virtual void new_input (const string &s, string d, Sources *);
96 bool top_input () { return include_stack_.size () < 2; }
97 SCM keyword_list () const;
98 SCM lookup_identifier (const string &s);
99 SCM lookup_identifier_symbol (SCM s);
100 void push_extra_token (Input const &where,
101 int token_type, SCM scm = SCM_UNSPECIFIED);
102 int pop_extra_token ();
103 void push_chord_state (SCM alist);
104 void push_figuredbass_state ();
105 void push_lyric_state ();
106 void push_initial_state ();
107 void push_markup_state ();
108 void push_note_state (SCM alist);
110 void LexerError (char const *);
111 void LexerWarning (char const *);
112 void set_identifier (SCM path, SCM val);
113 int get_state () const;
114 bool is_note_state () const;
115 bool is_chord_state () const;
116 bool is_lyric_state () const;
117 bool is_figure_state () const;
118 bool is_clean () const;
121 #endif /* MY_LILY_LEXER_HH */