May 2015
Intermediate to advanced
296 pages
5h 10m
English
In this recipe, you will learn how to call the parser function from the main function of our TOY parser.
To invoke a driver program to start parsing, define the driver function as shown in the following:
toy.cpp file:$ vi toy.cpp
Driver function called from the main function, and a parser can now be defined as follows:static void Driver() {
while(1) {
switch(Current_token) {
case EOF_TOKEN : return;
case ';' : next_token(); break;
case DEF_TOKEN : HandleDefn(); break;
default : HandleTopExpression(); break;
}
}
}main() function to run the whole program can be defined as follows:int main(int argc, char* argv[]) { LLVMContext &Context = getGlobalContext(); init_precedence(); file = fopen(argv[1], ...Read now
Unlock full access