subject

A compiler converts a source language program into a target language program. There are some basic stages in compilation process, including scanning, parsing, semantic analysis, and code generation. For this assignment, you will implement a scanner and parser for a small language with its grammar given in BNF notation. The language literals are enclosed with ' ' in the CFG below. Your task is to implement a scanner and a parser for this simple language. Let's name our language Blazer with .bl as program file extension. Context Free Grammar:
< program > -> < stmt > { < stmt >}'halt'
< stmt > -> ID '=' < expr >
|'read' ID
|'write' < expr >
< expr > -> < term > {('+'|'-') < term > }
< term > -> < factor > {('*'|'/') < factor > }
< factor > -> ID
| INT_CONSTANT
|'(' < expr > ')'

The possible set of tokens, represented with regular expressions, includes:
ASSIGN -> =
PLUS -> +
MINUS -> -
TIMES -> *
DIV -> /
LPAREN -> (
RPAREN -> )
ID -> letter(letter|digit)*
Except read, write, and halt.
INT_CONSTANT -> digit digit*
LETTER ->[a-zA-Z]
DIGIT ->[0-9]

Notes:

1. * means repeat zero or more times.
2. You may find strcmp useful for implementing reserved words/keywords in a language;
3. Programs can be read from file or keyboard, but files are recommended.

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 21:30
Im doing this last minute and literally none of my neighbors or people that my dad works with use excel so if anyone could me make up an example
Answers: 1
question
Computers and Technology, 23.06.2019 06:30
Which option correctly describes a dbms application? a. software used to manage databases b. software used to organize files and folders c. software used to develop specialized images d. software used to create effective presentations
Answers: 1
question
Computers and Technology, 23.06.2019 22:00
Jackson, who works in the finance department of a company, is holding a seminar for other employees on how to file taxes. only three employees sign up to attend the seminar. which device can he use to share his presentation with a group of three employees?
Answers: 1
question
Computers and Technology, 24.06.2019 00:00
Afashion designer wants to increase awareness about her brand. which network can she use and why she can use the blank to blank her products online. answers for the first blank: internet, extranet, or intranet answers for the second blank: market, design, and export
Answers: 1
You know the right answer?
A compiler converts a source language program into a target language program. There are some basic s...
Questions
question
Mathematics, 10.09.2021 01:00
question
Mathematics, 10.09.2021 01:00
question
Mathematics, 10.09.2021 01:00
question
English, 10.09.2021 01:00
question
Mathematics, 10.09.2021 01:00
question
Social Studies, 10.09.2021 01:00
Questions on the website: 13722367