3 #include "identparent.hh"
4 #include "associter.hh"
11 #include "notename.hh"
12 #include "sourcefile.hh"
13 #include "parseconstruct.hh"
15 static Keyword_ent the_key_tab
[]={
22 "duration", DURATIONCOMMAND
,
23 "geometric", GEOMETRIC
,
30 "multivoice", MULTIVOICE
,
31 "octave", OCTAVECOMMAND
,
44 "symboltables", SYMBOLTABLES
,
45 "notenames", NOTENAMES
,
47 "textstyle", TEXTSTYLE
,
48 "unitspace", UNITSPACE
,
58 My_flex_lexer::ret_notename(int *p
, String text
, int octave_mod
)
61 char const* ch_c_l
= here_ch_c_l();
63 while ( ( *ch_c_l
== ' ' ) || ( *ch_c_l
== '\t' ) || ( *ch_c_l
== '\n' ) )
67 lookup_notename(p
[0], p
[1], text
);
69 mtor
<< "notename: "<< text
<<eol
;
73 warning( String( "notename does not exist: " ) + YYText(), ch_c_l
);
79 My_flex_lexer::My_flex_lexer()
81 keytable
= new Keyword_table(the_key_tab
);
82 the_id_tab
= new Assoc
<String
, Identifier
*>;
89 My_flex_lexer::lookup_keyword(String s
)
91 return keytable
->lookup(s
);
95 My_flex_lexer::lookup_identifier(String s
)
97 if (!the_id_tab
->elt_query(s
))
100 return (*the_id_tab
)[s
];
104 My_flex_lexer::here_ch_c_l()
106 return data_ch_c_l_
? data_ch_c_l_
+ yyin
->tellg() : 0;
110 My_flex_lexer::add_identifier(Identifier
*i
)
112 delete lookup_identifier(i
->name
);
113 (*the_id_tab
)[i
->name
] = i
;
116 My_flex_lexer::~My_flex_lexer()
120 for (Assoc_iter
<String
,Identifier
*> ai(*the_id_tab
); ai
.ok(); ai
++) {
121 mtor
<< "deleting: " << ai
.key()<<'\n';
128 My_flex_lexer::spot()const
130 return include_stack
.top()->name
+ ": " + String( lineno() );
134 My_flex_lexer::LexerError(const char *s
)
136 if (lexer
->include_stack
.empty()) {
137 *mlog
<< "error at EOF" << s
<< '\n';
139 char const* ch_c_l
= here_ch_c_l();
142 while ( ( *ch_c_l
== ' ' ) || ( *ch_c_l
== '\t' ) || ( *ch_c_l
== '\n' ) )
147 warning( s
, ch_c_l
);
151 // set the new input to s, remember old file.
153 My_flex_lexer::new_input(String s
)
155 if (!include_stack
.empty()) {
156 include_stack
.top()->line
= lineno();
157 // should this be saved at all?
158 include_stack
.top()->defined_ch_c_l_
= defined_ch_c_l
;
161 Input_file
*newin
= new Input_file(s
);
162 include_stack
.push(newin
);
163 switch_streams(newin
->is
);
164 if ( newin
->sourcefile_l_
)
165 data_ch_c_l_
= newin
->sourcefile_l_
->ch_c_l();
172 // pop the inputstack.
174 My_flex_lexer::close_input()
176 Input_file
*old
= include_stack
.pop();
178 if (include_stack
.empty()) {
181 Input_file
*i
= include_stack
.top();
182 switch_streams(i
->is
);
184 defined_ch_c_l
= i
->defined_ch_c_l_
;