]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/lily-parser.hh
Admin: run yearly grand-replace.
[lilypond.git] / lily / include / lily-parser.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 LILY_PARSER_HH
21 #define LILY_PARSER_HH
22
23 #include "duration.hh"
24 #include "input.hh"
25 #include "pitch.hh"
26
27 /**
28    State for the parser.  Do not ever add any variables to parse
29    musical content here.  We still have to remove default_duration_.
30
31    TODO: interface is too complicated
32 */
33 class Lily_parser
34 {
35   DECLARE_SMOBS (Lily_parser);
36   friend int yyparse (void *);
37
38   vector<Input> define_spots_;
39
40   char const *here_str0 () const;
41   Simultaneous_music *get_chord (Pitch tonic,
42                                  vector<Pitch> *adds, vector<Pitch> *subs,
43                                  Pitch *inversion, Pitch *bass, Duration d);
44   void set_chord_tremolo (int type);
45   void set_last_duration (Duration const *);
46   void set_last_pitch (Pitch const *);
47
48 public:
49   Lily_lexer *lexer_;
50   Sources *sources_;
51   Duration default_duration_;
52   string output_basename_;
53
54   int fatal_error_;
55   int error_level_;
56   bool ignore_version_b_;
57
58   Lily_parser (Sources *sources);
59   Lily_parser (Lily_parser const &);
60
61   DECLARE_SCHEME_CALLBACK (layout_description, ());
62
63   void clear ();
64   void do_init_file ();
65   void do_yyparse ();
66   void include_string (string ly_code);
67   void parse_file (string init, string name, string out_name);
68   void parse_string (string ly_code);
69   void parser_error (string);
70   void parser_error (Input const &, string);
71   void set_yydebug (bool);
72
73   SCM make_scope () const; 
74 };
75
76 DECLARE_UNSMOB (Lily_parser, lily_parser);
77
78 SCM ly_parse_file (SCM);
79 SCM ly_parse_string (SCM);
80 // SCM ly_parser_add_book_and_score (SCM, SCM);
81 SCM ly_parser_print_book (SCM, SCM);
82 SCM ly_parser_print_score (SCM, SCM);
83 SCM ly_parser_bookify (SCM, SCM);
84 SCM ly_parser_scorify (SCM, SCM);
85
86 Output_def *get_layout (Lily_parser *parser);
87 Output_def *get_midi (Lily_parser *parser);
88 Output_def *get_paper (Lily_parser *parser);
89 void init_papers (Lily_parser *parser);
90 void push_paper (Lily_parser *parser, Output_def *paper);
91 void pop_paper (Lily_parser *parser);
92 void set_paper (Lily_parser *parser, Output_def *paper);
93 SCM get_header (Lily_parser *parser);
94
95 #endif /* LILY_PARSER_HH */