目录
To make this code.
Compilation Steps:
Testing the Parser:
Expected Outcome
Explanation in detail
Why can you omit -ly?
What is the result of omitting -ly?
Open your Makefile
and locate the following line:
$(CC) -o parser $(filter-out $(LFO),$(OBJS)) -lfl -ly
Replace it with:
$(CC) -o parser $(filter-out $(LFO),$(OBJS)) -lfl
Save the changes and run the make
command in your terminal.
UPDATE:It would be a better choice to install the correct libraty function.
sudo apt-get install libbison-dev
To test the parser, you'll need to specify a real file name in place of "self_test" in the following command:
./parser ../Test/self_test.cmm
For example, to test with a file named 2.cmm
, you would run:
./parser ../Test/2.cmm
If everything is set up correctly, you should see successful output indicating that the parser has processed the input file without any issues.
The syntax.tab.c
file is generated by Bison and is part of the parser for your language or data format. This file typically includes all the necessary code to parse the input according to the grammar defined in .y
file. Therefore, it's often self-contained and doesn't require linking against an external yacc or Bison library (liby.a
or liby.so
).
-ly
?The -ly
flag is used to link against the yacc library, which is often not necessary when you're using Bison, especially if you're not using any yacc-specific libraries or features. The Bison-generated code is usually self-contained, meaning it includes everything it needs to function. Therefore, you can often omit the -ly
flag without any issues.
-ly
?If you omit -ly
and your code doesn't depend on any external yacc or Bison libraries, then your program should compile and run just fine. You won't notice any difference in functionality; the parser should work as expected.
If your code does depend on some features provided by the yacc library, then omitting -ly
would result in linker errors. However, given that you're already encountering linker errors complaining about not finding -ly
, and you're using Bison, it's likely safe to try omitting it.