Question
The Northcentral University Programming Language (NCU/PL) is a new procedural language. It contains the following basic operations: variable declaration, variable assignment, input, output, if/then statements,
The Northcentral University Programming Language (NCU/PL) is a new procedural language. It contains the following basic operations: variable declaration, variable assignment, input, output, if/then statements, and binary arithmetic/comparison. There are three data types in NCU/PL: 32-bit integers (int), strings of 16-bit Unicode characters (string), and Boolean (bool).
For this assignment, you will use the Java Compiler Compiler (JavaCC) to create a lexical analyzer for NCU/PL.
Download the NCU/PL language development kit (LDK) from the course materials. The BNF grammar for NCU/PL is located in /CS5013 - NCUPL Grammar.pdf. The lexer has been started for you inside /lexer/NCU_PL.jj.
Modify /lexer/NCU_PL.jj so that it will recognize and validate all valid NCU/PL programs.
Generate the source code for your lexer using javacc: java cp javacc.jar javacc NCU_PL.jj
Compile the resulting Java code and the Lexer driver (NCU_PL_Lexer_Driver.java).
Run the lexer against the test NCU/PL programs provided in folder /Test Programs 1: java NCU_PL_Lexer_Driver test-program.ncupl
Debug and revise your JavaCC file as necessary until the lexer driver properly validates all of the provided test programs.
Submit your modified NCU_PL.jj source file. Also include a short (100 150 words) explanation of what the lexer does and does not do. Does it check for semantic correctness? Does it check for logical correctness? Finally, reflect on your experience in creating the lexical analyzer and lessons learned.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started