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