]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/lily-parser.hh
d6d7a754b8294403c28909cd5d7fe32799e327ea
[lilypond.git] / lily / include / lily-parser.hh
1 /*
2   lily-parser.hh -- declare Lily_parser
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1997--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
8
9 #ifndef LILY_PARSER_HH
10 #define LILY_PARSER_HH
11
12 #include "duration.hh"
13 #include "input.hh"
14 #include "pitch.hh"
15
16 /**
17    State for the parser.  Do not ever add any variables to parse
18    musical content here.  We still have to remove default_duration_.
19
20    TODO: interface is too complicated
21 */
22 class Lily_parser
23 {
24   DECLARE_SMOBS (Lily_parser);
25   friend int yyparse (void *);
26
27   vector<Input> define_spots_;
28
29   char const *here_str0 () const;
30   Simultaneous_music *get_chord (Pitch tonic,
31                                  vector<Pitch> *adds, vector<Pitch> *subs,
32                                  Pitch *inversion, Pitch *bass, Duration d);
33   void set_chord_tremolo (int type);
34   void set_last_duration (Duration const *);
35   void set_last_pitch (Pitch const *);
36
37 public:
38   Lily_lexer *lexer_;
39   Sources *sources_;
40   Duration default_duration_;
41   string output_basename_;
42
43   int fatal_error_;
44   int error_level_;
45   bool ignore_version_b_;
46
47   Lily_parser (Sources *sources);
48   Lily_parser (Lily_parser const &);
49
50   DECLARE_SCHEME_CALLBACK (layout_description, ());
51
52   void clear ();
53   void do_init_file ();
54   void do_yyparse ();
55   void parse_file (string init, string name, string out_name);
56   void parse_string (string ly_code);
57   void parser_error (string);
58   void parser_error (Input const &, string);
59   void set_yydebug (bool);
60
61   SCM make_scope () const; 
62 };
63
64 DECLARE_UNSMOB (Lily_parser, lily_parser);
65
66 SCM ly_parse_file (SCM);
67 SCM ly_parse_string (SCM);
68 // SCM ly_parser_add_book_and_score (SCM, SCM);
69 SCM ly_parser_print_book (SCM, SCM);
70 SCM ly_parser_print_score (SCM, SCM);
71 SCM ly_parser_bookify (SCM, SCM);
72 SCM ly_parser_scorify (SCM, SCM);
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 */