Put the file next to your sources and run it after the build process to fix the error. The script is easy, it opens the file, changes the line from “class istream ” to “#include ”, inserts “using namespace std ” next. Lines.insert(i + 1, 'using namespace std \n') When I started fixing the error, I was doing it by hand, but I got bored of the process so I wrote a small Python script to do this for me:Īssuming that the output file of the lex file is called lex.yy.cc: f = open('lex.yy.cc') Now when you compile the solution your lex file will be passed the the flex tool. Select “Custom Build Tool” in the Tool drop down list.Įnter in the Command Line field: flex lex.l Assuming that your lex file is called lex.l The first problem: Binding NetBeans with Flexįrom NetBeans –> Projects Side Tab –> right click on the lex file –> Properties: (You might not face this problem, then you’re a lucky programmer). When using building the file you’ll find that it contains errors regarding the usage of istream. The second problem was that when the code file is generated it contains errors: #ifdef _cplusplus The lex file must be passed to the flex tool to generate a C++ code file. The first problem I faced when starting the project was to tell NetBeans how to handle the lex file: ![]() The lexer is implemented using GNU Flex while the parser is implemented using GNU Bison. The first two phases of implementing a compiler are: building a lexer (tokenizer) and building a parser. The compiler would be implemented in C++. I like using NetBeans for developing applications, it supports lots of languages and tools like C, C++, Java, Python, Ruby and more. In my faculty – Informatics Engineering, Damascus University -, in the 4th year of Software Engineering Department, we have to build a compiler :shock.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |