]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/lily-lexer.hh
Merge branch 'master' into lilypond/translation
[lilypond.git] / lily / include / lily-lexer.hh
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 1997--2011 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
29 bool busy_parsing ();
30 void kill_lexer ();
31 void set_lexer ();
32
33 struct Chord_repetition
34 {
35   Chord_repetition ()
36   {
37     last_chord_ = SCM_EOL;
38     repetition_function_ = SCM_EOL;
39     repetition_symbol_ = SCM_EOL;
40   }
41
42   SCM repetition_symbol_;
43   SCM repetition_function_;
44   SCM last_chord_;
45 };
46
47 class Lily_lexer : public Includable_lexer
48 {
49   DECLARE_SMOBS (Lily_lexer);
50
51 private:
52   int lookup_keyword (string);
53   int scan_bare_word (string);
54   SCM scan_markup_word (string);
55   int scan_escaped_word (string);
56   int identifier_type (SCM);
57   char escaped_char (char) const;
58
59   Lily_parser *parser_;
60   Keyword_table *keytable_;
61   SCM scopes_;
62   SCM start_module_;
63   int hidden_state_;
64 public:
65   vector<int> extra_token_types_;
66   void *lexval_;
67   Input *lexloc_;
68   bool is_main_input_;
69
70   Sources *sources_;
71
72   /* Scheme hash tables with (oct name acc)  values, and symbol keys.  */
73   SCM chordmodifier_tab_;
74   SCM pitchname_tab_stack_;
75
76   Chord_repetition chord_repetition_;
77
78   int error_level_;
79   Input last_input_;
80
81   Lily_lexer (Sources *, Lily_parser *);
82   Lily_lexer (Lily_lexer const &, Lily_parser *);
83   int yylex ();
84
85   void add_lexed_char (int);
86
87   void prepare_for_next_token ();
88   int try_special_identifiers (SCM *, SCM);
89   Input here_input () const;
90
91   void add_scope (SCM);
92   SCM set_current_scope ();
93   bool has_scope () const;
94   SCM remove_scope ();
95
96   void start_main_input ();
97
98   virtual void new_input (string s, Sources *);
99   virtual void new_input (string s, string d, Sources *);
100
101   SCM keyword_list () const;
102   SCM lookup_identifier (string s);
103   SCM lookup_identifier_symbol (SCM s);
104   void push_extra_token (int token_type);
105   void push_chord_state (SCM tab);
106   void push_figuredbass_state ();
107   void push_lyric_state ();
108   void push_initial_state ();
109   void push_markup_state ();
110   void push_note_state (SCM tab);
111   void pop_state ();
112   void LexerError (char const *);
113   void set_identifier (SCM path, SCM val);
114   int get_state () const;
115   bool is_note_state () const;
116   bool is_chord_state () const;
117   bool is_lyric_state () const;
118   bool is_figure_state () const;
119   bool is_clean () const;
120 };
121
122 #endif /* MY_LILY_LEXER_HH */