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 01:30
How will you cite information that is common knowledge in your research paper?
Answers: 1
question
Computers and Technology, 22.06.2019 06:20
In what kind of attack can attackers make use of millions of computers under their control in an attack against a single server or network availability confidentiality integrity identity automated attack software? those who wrongfully disclose individually identifiable health information can be fined up to what amount per calendar year? single most expensive malicious attack hipaa what are script kiddies? advanced persistent threat security manager security engineer what level of security access should a computer user have to do their job what process describes using technology as a basis for controlling the access and usage of sensitive data? cybercriminal
Answers: 1
question
Computers and Technology, 22.06.2019 14:00
Which database model is best used for data warehouse and data mining
Answers: 3
question
Computers and Technology, 22.06.2019 20:00
What is used to analyze and summarize your data without graphical support
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, 26.01.2021 16:40
question
Social Studies, 26.01.2021 16:40
question
Mathematics, 26.01.2021 16:40