Question: Project Description: Design and implement an interpreter that executes the code written in LAO language. The statements in LAO language are: :=REM REM ::= =

 Project Description: Design and implement an interpreter that executes the code
written in LAO language. The statements in LAO language are: :=REM REM
::= = Carithmetic expression> Sprint statement>:= PRINT | PRINT PRINT PRINT :=
READ = IF THEN = ::= a- zA-Z ::= | == |
::= | = :=. ::= =eE = + - :: ::=.gt..It..eq. I.ge..le..ne.

Project Description: Design and implement an interpreter that executes the code written in LAO language. The statements in LAO language are: :=REM REM ::= = Carithmetic expression> Sprint statement>:= PRINT | PRINT PRINT PRINT := READ = IF THEN = ::= a- zA-Z ::= | == | ::= | = :=. ::= =eE = + - :: ::=.gt..It..eq. I.ge..le..ne. .or..and..not. := | 3 integer vs. integer real vs. real real 2.0 .add. 2.0 => 4.0 2.0 .add. 2 real vs. integer real => 4.0 .add. string vs. string string "ab" add. "c" => "abc" string 3. add. "ab" integer vs. string real vs. string => "3ab" string "ab" .add. 3.5 => "ab3.5" integer 2 sub. 2 => integer vs. integer real vs. real 0 real .sub. 2.0 .sub. 2.0 => 0.0 real vs. integer real 2.0 .sub. 2 => 0.0 integer mul. 2 => integer vs. integer real vs. real real .mul. 2.0.mul. 2.0 => 4.0 real vs. integer real 2.0.mul. 2 => 4.0 integer 2 integer vs. integer real vs. real div. 2 => 1 real 2.0 .div. 2.0 .div. => 1.0 real vs. integer real 2.0 .div. 2 => 1.0 .or. 1 The following table describes the associative and precedence of the logical, relational, and arithmetic operators: Operator Associative Precedence (low to high) left to right left to right 2 right to left .eq. ne. left to right It..legt. ge. left to right 5 add. sub. left to right .mul. div. left to right 7 and. not 3 4 6 The two operands of a relational operator will be: o integer vs. integer o real vs. real o real vs. integer string vs. string The interpreter must read from a file the instructions of a program written in LAO. In case of an error in an instruction, the interpreter must stop and show: o the line number of the instruction that provoked the error o the instruction that provoked the error o the type of instruction that provoked the error, what is the error, and possible solution (the interpreter must only show unknown statement if the instruction does not match the beginning of any valid statement in the language LAO) 5 Sample program in LAO language: W = "HOLA" " MUNDO" if 3 .gt. 2 then a = 2 .add. 1.add. 3 .mul. 4 Z - w .add. y print z print print if z .eq. "HOLA MUNDO" then print z CC-0 c2 = 9 C = 4 print print if c.eq. 4 then a = c.add. 3.div. 3 n = 3.0 .add. 2 .mul. c print "n- print This is print print the last a = 3.mul. c .add. 2 part... print "a = print a has to print execute print print "ENTER AN INTEGER NUMBER: taking read b this print file.... print print "YOU ENTERED: print b print print print if b.gt. 7.and. b.le. 9.or. b.eq. 8 then print if b.gt. 7.and. b.le. 9.or. b.eg. 8 then print a

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!