]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/lily-parser.hh
Issue 4550 (2/2) Avoid "using namespace std;" in included files
[lilypond.git] / lily / include / lily-parser.hh
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 1997--2015 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.
29
30    TODO: interface is too complicated
31 */
32 class Lily_parser : public Smob<Lily_parser>
33 {
34   SCM do_yyparse ();
35   static SCM do_yyparse_trampoline (void *parser);
36 public:
37   int print_smob (SCM, scm_print_state *) const;
38   SCM mark_smob () const;
39   static const char type_p_name_[];
40   virtual ~Lily_parser ();
41   Lily_lexer *lexer_;
42   Sources *sources_;
43   Duration default_duration_;
44   int default_tremolo_type_;
45   std::string output_basename_;
46   SCM closures_;
47
48   int fatal_error_;
49   int error_level_;
50   bool ignore_version_b_;
51
52   Lily_parser (Sources *sources);
53   Lily_parser (Lily_parser const &, SCM closures = SCM_EOL,
54                SCM location = SCM_BOOL_F);
55
56   DECLARE_SCHEME_CALLBACK (layout_description, ());
57
58   void clear ();
59   void do_init_file ();
60   void include_string (const std::string &ly_code);
61   void parse_file (const std::string &init, const std::string &name, const std::string &out_name);
62   void parse_string (const std::string &ly_code);
63   SCM parse_string_expression (const std::string &ly_code, const std::string &filename, int line);
64   void parser_error (const std::string&);
65   void parser_error (Input const &, const std::string&);
66   // The following is called as yyerror
67   static void parser_error (Input const *i, Lily_parser *parser, SCM *, const std::string &s);
68   void set_yydebug (bool);
69
70   SCM make_scope () const;
71 };
72
73
74 Output_def *get_layout (Lily_parser *parser);
75 Output_def *get_midi (Lily_parser *parser);
76 Output_def *get_paper (Lily_parser *parser);
77 void init_papers (Lily_parser *parser);
78 void push_paper (Lily_parser *parser, Output_def *paper);
79 void pop_paper (Lily_parser *parser);
80 void set_paper (Lily_parser *parser, Output_def *paper);
81 SCM get_header (Lily_parser *parser);
82
83 #endif /* LILY_PARSER_HH */