Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A very simple toy language: statements separated with 's' empty statement between consecutive ;' is OK last statement can optionally followed by ';' at least

image text in transcribed
A very simple toy language: statements separated with 's' empty statement between consecutive ;' is OK last statement can optionally followed by ';' at least one space between all lexemes tab and newline char are ignored variables: var name (identifier) consists of lower letter only (no digits, spaces, punctuations) following words are reserved and can not be used as variable names: print, if, then examples of legal variables: x, y, apple, hello examples of illlegal variables: x4, Apple, hello_world expressions : sums of positive integers and declared variables a variable must be declared and initialized in prior set_statement before it can be used in an expression example of legal expressions : 6, x + y, 3 + 45 + alpha example of illegal expressions: 6 * 5, 3.2 . 7, 2 * x + y three kinds of statements: set_stmt: varname - exprn print_stmt: print exprn if_stmt: if exprn > exprn then set_stmt output of execution of a program: print statements produce integer (as a string) separated by one space the output should be trimmed so there is no leading and trailing spaces if the program contains an error, just return the string 'ERROR A very simple toy language: statements separated with 's' empty statement between consecutive ;' is OK last statement can optionally followed by ';' at least one space between all lexemes tab and newline char are ignored variables: var name (identifier) consists of lower letter only (no digits, spaces, punctuations) following words are reserved and can not be used as variable names: print, if, then examples of legal variables: x, y, apple, hello examples of illlegal variables: x4, Apple, hello_world expressions : sums of positive integers and declared variables a variable must be declared and initialized in prior set_statement before it can be used in an expression example of legal expressions : 6, x + y, 3 + 45 + alpha example of illegal expressions: 6 * 5, 3.2 . 7, 2 * x + y three kinds of statements: set_stmt: varname - exprn print_stmt: print exprn if_stmt: if exprn > exprn then set_stmt output of execution of a program: print statements produce integer (as a string) separated by one space the output should be trimmed so there is no leading and trailing spaces if the program contains an error, just return the string 'ERROR

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems An Application Oriented Approach Complete Version

Authors: Michael Kifer, Arthur Bernstein, Richard Lewis

2nd Edition

0321268458, 978-0321268457

More Books

Students also viewed these Databases questions

Question

What factors should be considered when estimating a projects NINV?

Answered: 1 week ago