Today we are adding the "LET" statement rule to our grammar. LET is essentially an assignment statement similar to that of BASIC. Sample LET statements:

computer science

Description

CECS 524 Lab 6   Adding LET and Comments and BEGIN ... END

 

In Lab 5 we added expression evaluation but didn't do any variables. Today we are adding the "LET" statement rule to our grammar. LET is essentially an assignment statement similar to that of BASIC. Sample LET statements:

 

  1. LET A = 1
  2. LET B = A * 8
  3. LET C = A*B + B/2 - (A+3)

 

Use the same project from Lab 5 and just add to the ANTLR grammar the rules or edit the rules as needed. Your SIL interpreter should be able to run this program after the changes:

 

LET A = 4

LET B = 5

LET C = A * B + 7

PRINT A

PRINT " * "

PRINT B

PRINT " + 7 = "

PRINTLN C

 

which makes this output : 4 * 5 + 7 = 27

 

Submit the grammar to BB Dropbox Lab 6.

 


Related Questions in computer science category