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 02:00
Alocal reaction will occur at the site of the exposure such as irritation or damage to the skin eye or local reaction will occur at the site of the exposure such as irritation or damage to the skin ireland lounges
Answers: 3
question
Computers and Technology, 23.06.2019 11:00
This chapter lists many ways in which becoming computer literate is beneficial. think about what your life will be like once you’re started in your career. what areas of computing will be most important for you to understand? how would an understanding of computer hardware and software you in working from home, working with groups in other countries and contributing your talents.
Answers: 1
question
Computers and Technology, 23.06.2019 14:00
How are stop motion special effects in animated films created
Answers: 1
question
Computers and Technology, 23.06.2019 17:00
The camera still is bad even with the new iphone xr and especially in low light it is even worst because you can see the pixels more if its in low light. if all you apple customers want apple to fix this then lets fill there feedback with complaints about the can apple do to fix this issue?
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
Social Studies, 24.08.2019 22:30
question
Mathematics, 24.08.2019 22:30
Questions on the website: 13722362