4 #include "identparent.hh"
5 #include "assoc-iter.hh"
7 #include "input-file.hh"
13 #include "notename.hh"
14 #include "source-file.hh"
15 #include "parseconstruct.hh"
17 static Keyword_ent the_key_tab
[]={
24 "duration", DURATIONCOMMAND
,
25 "geometric", GEOMETRIC
,
32 "multivoice", MULTIVOICE
,
33 "octave", OCTAVECOMMAND
,
46 "symboltables", SYMBOLTABLES
,
47 "notenames", NOTENAMES
,
50 "textstyle", TEXTSTYLE
,
51 "unitspace", UNITSPACE
,
61 My_flex_lexer::ret_notename(int *p
, String text
, int octave_mod
)
63 text
= text
.lower_str();
64 char const* ch_c_l
= here_ch_c_l();
67 while ( ( *ch_c_l
== ' ' )
68 || ( *ch_c_l
== '\t' ) || ( *ch_c_l
== '\n' ) )
73 lookup_notename(p
[0], p
[1], text
);
75 mtor
<< "notename: "<< text
<<eol
;
79 error( String( "notename does not exist: " ) + YYText(), ch_c_l
);
85 My_flex_lexer::My_flex_lexer()
87 keytable
= new Keyword_table(the_key_tab
);
88 the_id_tab
= new Assoc
<String
, Identifier
*>;
94 My_flex_lexer::lookup_keyword(String s
)
96 return keytable
->lookup(s
);
100 My_flex_lexer::lookup_identifier(String s
)
102 if (!the_id_tab
->elt_query(s
))
105 return (*the_id_tab
)[s
];
109 My_flex_lexer::here_ch_c_l()
111 return include_stack
.top()->sourcefile_l_
->ch_c_l() + yyin
->tellg();
115 My_flex_lexer::add_identifier(Identifier
*i
)
117 delete lookup_identifier(i
->name
);
118 (*the_id_tab
)[i
->name
] = i
;
121 My_flex_lexer::~My_flex_lexer()
125 for (Assoc_iter
<String
,Identifier
*> ai(*the_id_tab
); ai
.ok(); ai
++) {
126 mtor
<< "deleting: " << ai
.key()<<'\n';
132 My_flex_lexer::print_declarations()const
134 for (Assoc_iter
<String
,Identifier
*> ai(*the_id_tab
); ai
.ok(); ai
++) {
140 My_flex_lexer::spot()const
142 return include_stack
.top()->name
+ ": " + String( lineno() );
146 My_flex_lexer::LexerError(const char *s
)
148 if (lexer
->include_stack
.empty()) {
149 *mlog
<< "error at EOF" << s
<< '\n';
151 char const* ch_c_l
= here_ch_c_l();
154 while ( ( *ch_c_l
== ' ' ) || ( *ch_c_l
== '\t' ) || ( *ch_c_l
== '\n' ) )
163 // set the new input to s, remember old file.
165 My_flex_lexer::new_input(String s
)
167 if (!include_stack
.empty()) {
168 include_stack
.top()->line
= lineno();
169 // should this be saved at all?
170 include_stack
.top()->defined_ch_c_l_
= defined_ch_c_l
;
173 Input_file
*newin
= new Input_file(s
);
174 include_stack
.push(newin
);
175 switch_streams(newin
->is
);
180 // pop the inputstack.
182 My_flex_lexer::close_input()
184 Input_file
*old
= include_stack
.pop();
186 if (include_stack
.empty()) {
189 Input_file
*i
= include_stack
.top();
190 switch_streams(i
->is
);
192 defined_ch_c_l
= i
->defined_ch_c_l_
;