Question: Write a tokenizer for the toy language, see attached photo for the language. 1. The following defines a simple language, in which a program consists
Write a tokenizer for the toy language, see attached photo for the language. 
1. The following defines a simple language, in which a program consists of assignments and cach variable is assumed to he of the integer type. For the sake of simplicity, only opcrators that give integer valucs are included. Write an interprctcr for thc languagc in a languagc of your choicc. Your interpreter should bc able to do thc following for a given program: (1) detect syntax crrors; (2) rcport uninitializcd variables; and (3) perform the assignments if there is no error and print out the values of all the variables after all the assignments are done Progran! Assignnent* Assignnent: Identifier Bxp Exp Exp + Term Exp - Term | Term Term: Term Fact Fact Fact: ExpI - Fact I Fact Literal | Identifier Letter Letter | Digit]* a|... lzla...1z1_ 0 NonzeroDigit Digit* Identifier: Letter: Literal: NonZeroDigit: Digit: Sample inputs and outputs o Input 1 x 001; o Output 1 error o Input 2 x2 = 0; - o Output 2 o Input 3 x=0 y = x; z = (xty); o Output 3 error o Input 4 x = 1. y=2; z ( x+y ) * ( x+-y ) ; o Output 4 1. The following defines a simple language, in which a program consists of assignments and cach variable is assumed to he of the integer type. For the sake of simplicity, only opcrators that give integer valucs are included. Write an interprctcr for thc languagc in a languagc of your choicc. Your interpreter should bc able to do thc following for a given program: (1) detect syntax crrors; (2) rcport uninitializcd variables; and (3) perform the assignments if there is no error and print out the values of all the variables after all the assignments are done Progran! Assignnent* Assignnent: Identifier Bxp Exp Exp + Term Exp - Term | Term Term: Term Fact Fact Fact: ExpI - Fact I Fact Literal | Identifier Letter Letter | Digit]* a|... lzla...1z1_ 0 NonzeroDigit Digit* Identifier: Letter: Literal: NonZeroDigit: Digit: Sample inputs and outputs o Input 1 x 001; o Output 1 error o Input 2 x2 = 0; - o Output 2 o Input 3 x=0 y = x; z = (xty); o Output 3 error o Input 4 x = 1. y=2; z ( x+y ) * ( x+-y ) ; o Output 4
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
