Syntax Analyzer-parser / Java
See the full project
Dear Java coder,
This is a practical work from university. In a few words, I need a simple/primitive syntax analyzer and parser.
In detail:
I have a Lexical analyzer (scanner) already coded (!) that reads a file with a custom syntax written (accordingly to the BNF that is written too!). It simply understands what symbols like =, lt;, gt; mean, where identificator or a string ("hello, name") or a function is etc.
Now I need to boost the analyzer up to the Syntax analyzer (parser). It needs to analyze a custom code, report if syntax errors found, what and where are they and create a XML that indicates syntax structure.
The code that needs to be analyzed is very basic. for example:
***
program test;
int testFunction (int param1, int param2)
begin
int param3;
param3 = param1 + param2;
return param3;
end;
main
begin
int a1,a2,a3;
if (!a1)
begin
a3 = testFunction(a1,a2);
end
while (a1 == 3) do
begin
print(a3);
aa = "aa aa";
a1 = (a1 - 3)
end;
end.
***
The XML it should output would look like:
***
lt;programgt;testlt;/programgt;
lt;function type="int"gt;testFunctionlt;/functiongt;
lt;id type="int"gt;param3lt;/idgt;
......
***
The Lexical analyzer is the file attached. Note, that you do not need to rewrite the code from scratch - just boost the current. Every new line should be commented: simple descriptive sentence. You should use only standard Java libraries. The program should compile using "javac".
My preferred work principle: (1) I select a you (2) I get Class files as a test files to test if it works as requested (3) In case it's all fine we proceed with the payment and source files.
Thank you!



