]> git.donarmstrong.com Git - lilypond.git/blob - src/lexerinit.cc
cc69a4a6bbf484f539593db84c41efbe3322f6b4
[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 Input_file::Input_file(String s)
26 {
27     name = s;
28     line = 1;
29     String pf(s);
30     if (pf=="")
31         is = &cin;
32     else {
33         pf =find_file(pf);
34         if (pf=="") {
35             String e("can\'t open `"  + s+"\'");
36             error(e);
37         }
38         is = new ifstream(  pf);
39     }
40     cout << "["<<pf<<flush;
41 }
42
43 Input_file::~Input_file()
44 {
45   if (is != &cin)
46       delete is;
47   cout << "]" << flush;  
48 }