]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/lily-lexer.hh
Issue 2607: Allow immediate Scheme expressions with splicing and multiple values
[lilypond.git] / lily / include / lily-lexer.hh
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 1997--2012 Han-Wen Nienhuys <hanwen@xs4all.nl>
5
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.
10
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.
15
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/>.
18 */
19
20 #ifndef MY_LILY_LEXER_HH
21 #define MY_LILY_LEXER_HH
22
23 #include "includable-lexer.hh"
24
25 #include "input.hh"
26 #include "duration.hh"
27 #include "pitch.hh"
28 #include "parser.hh"
29
30 bool busy_parsing ();
31 void kill_lexer ();
32 void set_lexer ();
33
34 class Lily_lexer : public Includable_lexer
35 {
36   DECLARE_SMOBS (Lily_lexer);
37
38 private:
39   int lookup_keyword (string);
40   int scan_bare_word (string);
41   SCM scan_markup_word (string);
42   int scan_escaped_word (string);
43   int scan_scm_id (SCM);
44   int identifier_type (SCM);
45   char escaped_char (char) const;
46   const char *YYText_utf8 ();
47
48   Lily_parser *parser_;
49   Keyword_table *keytable_;
50   SCM scopes_;
51   SCM start_module_;
52   int hidden_state_;
53   SCM eval_scm (SCM, char extra_token = 0);
54 public:
55   SCM eval_scm_token (SCM sval)  { return eval_scm (sval, '#'); }
56   SCM extra_tokens_;
57   YYSTYPE *lexval_;
58   Input *lexloc_;
59   bool is_main_input_;
60
61   Sources *sources_;
62
63   /* Scheme hash tables with (oct name acc)  values, and symbol keys.  */
64   SCM chordmodifier_tab_;
65   SCM pitchname_tab_stack_;
66
67   int error_level_;
68   Input last_input_;
69
70   Lily_lexer (Sources *, Lily_parser *);
71   Lily_lexer (Lily_lexer const &, Lily_parser *);
72   int yylex ();
73
74   void add_lexed_char (int);
75
76   void prepare_for_next_token ();
77   int try_special_identifiers (SCM *, SCM);
78   Input here_input () const;
79
80   void add_scope (SCM);
81   SCM set_current_scope ();
82   bool has_scope () const;
83   SCM remove_scope ();
84
85   void start_main_input ();
86
87   virtual void new_input (string s, Sources *);
88   virtual void new_input (string s, string d, Sources *);
89
90   bool top_input () { return include_stack_.size () < 2; }
91   SCM keyword_list () const;
92   SCM lookup_identifier (string s);
93   SCM lookup_identifier_symbol (SCM s);
94   void push_extra_token (int token_type, SCM scm = SCM_UNDEFINED);
95   void push_chord_state (SCM tab);
96   void push_figuredbass_state ();
97   void push_lyric_state ();
98   void push_initial_state ();
99   void push_markup_state ();
100   void push_note_state (SCM tab);
101   void pop_state ();
102   void LexerError (char const *);
103   void LexerWarning (char const *);
104   void set_identifier (SCM path, SCM val);
105   int get_state () const;
106   bool is_note_state () const;
107   bool is_chord_state () const;
108   bool is_lyric_state () const;
109   bool is_figure_state () const;
110   bool is_clean () const;
111 };
112
113 #endif /* MY_LILY_LEXER_HH */