]> git.donarmstrong.com Git - lilypond.git/blob - src/lexerinit.cc
release: 0.0.21
[lilypond.git] / src / lexerinit.cc
1 #include <fstream.h>
2 #include "lexer.hh"
3 #include "debug.hh"
4
5 My_flex_lexer *lexer=0;
6
7 int
8 yylex() {
9         return lexer->yylex();
10 }
11
12 void
13 yyerror(const char *s)
14 {
15         lexer->LexerError(s);
16 }
17
18 bool
19 busy_parsing()
20 {
21     return lexer;       
22 }
23
24 void
25 kill_lexer()
26 {
27         delete lexer;
28         lexer = 0;
29 }
30
31 void
32 set_lexer()
33 {
34     if (!lexer) {
35        lexer = new My_flex_lexer;
36        lexer->set_debug( !monitor.silence("Lexer") && check_debug);
37    }            
38 }
39
40 Input_file::Input_file(String s)
41 {
42     name = s;
43     line = 1;
44     if (s=="")
45         is = &cin;
46     else
47         is = new ifstream( s );
48     
49    if ( ! *is) {
50         String e("can\'t open `"  + s+"\'");
51       error(e);
52    }
53    cout << "["<<s<<flush;
54 }
55
56 Input_file::~Input_file()
57 {
58   if (is != &cin)
59       delete is;
60   cout << "]" << flush;  
61 }