Initial revision
[lilypond.git] / parser.y
blob23987a273daef7dbde42b74ae066b0b4d4681540
1 %{ // -*-Fundamental-*-
2 #include <iostream.h>
3 //#include "mudobs.hh"
4 #include "lexer.hh"
5 #include "staff.hh"
6 #include "score.hh"
7 #include "keyword.hh"
8 #include "globvars.hh"
9 #include "debug.hh"
10 #include "parseconstruct.hh"
11 #define YYDEBUG 1
17 %union {
18 int i;
19 Real real;
20 Command *command;
21 Identifier *id;
23 Voice *voice;
24 Voice_element *el;
25 Staff *staff;
26 String *string;
27 Score *score;
30 %token VOICE STAFF SCORE TITLE RHYTHMSTAFF BAR NOTENAME
32 %token <id> IDENTIFIER
33 %token <string> PITCH DURATION RESTNAME
34 %token <real> REAL
37 %type <voice> voice_block voice_body voice_elts voice_elts_dollar
38 %type <el> voice_elt
39 %type <command> score_command
40 %type <score> score_block score_body
41 %type <staff> staff_block rhythmstaff_block rhythmstaff_body
45 mudela:
46 score_block {
47 delete the_score;
48 the_score = $1;
53 score_block: SCORE '{' score_body '}' { $$ = $3; }
56 score_body: { $$ = new Score; }
57 | score_body staff_block { $$->add($2); }
58 | score_body score_command { $$->add($2); }
61 staff_block:
62 rhythmstaff_block
65 rhythmstaff_block:
66 RHYTHMSTAFF '{' rhythmstaff_body '}' { $$ = $3; }
69 rhythmstaff_body:
70 /* empty */ { $$ = get_new_rhythmstaff(); }
71 | rhythmstaff_body voice_block { $$->add_voice($2); }
74 voice_block:
75 VOICE '{' voice_body '}' { $$ = $3; }
79 voice_body:
80 REAL voice_elts_dollar { $$ = $2; $$->start = $1; }
81 | voice_elts_dollar { $$ = $1; }
84 voice_elts_dollar:
85 '$' voice_elts '$' { $$ = $2; }
88 voice_elts:
89 /* empty */ {
90 $$ = new Voice;
92 | voice_elts voice_elt {
93 $$->add($2);
97 voice_elt:
98 PITCH DURATION { $$ = get_note_element(*$1, *$2);
101 | RESTNAME DURATION { $$ = get_rest_element(*$1, *$2);
106 score_command:
107 BAR REAL {
108 $$ = get_bar_command($2);
114 void
115 parse_file(String s)
117 *mlog << "Parsing ... ";
118 yydebug = debug_flags & DEBUGPARSER;
119 new_input(s);
120 yyparse();