Question: This project consists of developing an interpreter for a minimal form (subset) of the Lua language. This minimal form of Lua has only 1 data

This project consists of developing an interpreter for a minimal form (subset) of the Lua language. This minimal form of Lua has only 1 data type, integer, and the only identifiers are single letters. Lua is not case sensitive. The specification of the grammar is given below.

The interpreter will process a Lua program and build some intermediate data structures. These data structures will then be interpreted to execute the program. All tokens in this language are separated by white space. The parsing algorithm should detect any syntactical or semantic error. The first such error discovered should cause an appropriate error message to be printed, and then the interpreter should terminate. Run-time errors should also be detected with appropriate error messages being printed.

Develop a complete scanner. Write a short report describing the work performed. Include the source program, input and output. You must show the execution of this program by using several relevant source lines as input, the program must show a list of the tokens scanned.

Grammar for the (subset of Lua) language

Syntax Analyzer

function id ( ) end

|

| | | |

if then else end while do end -> id -> repeat until print ( )

le_operator | lt_operator | ge_operator | gt_operator | eq_operator | ne_operator

| |

add_operator | sub_operator | mul_operator | div_operator

Lexical Analyzer

id letter

CS4308 Project 2

literal_integer digit literal_integer | digit assignment_operator = le_operator <= lt_operator <

ge_operator >=

gt_operator > eq_operator = = ne_operator ~= add_operator + sub_operator - mul_operator * div_operator /

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!