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 14:20
Consider a byte-addressable computer with 16mb of main memory, a cache capable of storing a total of 64kb of data and block size of 32 bytes. (a) how many bits in the memory address? (b) how many blocks are in the cache? (c) specify the format of the memory address, including names and sizes, when the cache is: 1. direct-mapped 2. 4-way set associative 3. fully associative
Answers: 2
question
Computers and Technology, 22.06.2019 15:20
This os integrated the processing power of windows nt with the easy-to-use gui of windows 98. windows 2000 windows 3.11 windows for workgroups windowa millennium edition
Answers: 1
question
Computers and Technology, 23.06.2019 18:30
List 3 items that were on kens resume that should have been excluded
Answers: 1
question
Computers and Technology, 24.06.2019 02:00
Read the following scenario, and then answer the question below. you want to send an e-mail to your boss requesting a meeting to discuss a raise. what is the best example of an e-mail to an employer about this meeting? “hey jason. can we chat about getting me more money soon? let me know. peace, meg.” “hello jason. pardon me for sending yet another e-mail today about my need to talk to you about my position and a possible pay increase. i am dying to know when you can talk. sincerely, meg.” “hello jason. i have been with the company for one year and have taken on more responsibilities than outlined in my job description. i would appreciate an opportunity to speak with you about my position. let me know when we can schedule a meeting. you, meg.” “greetings jason! i hope this e-mail finds you well and happy today. i really, really want to talk to you about something important. i am not sure if you have time. i hope you do. get back in touch with me and let me know when we might talk. ever so much for taking the time to read this. sincerely, meg.”
Answers: 3
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, 18.11.2020 22:20
question
Mathematics, 18.11.2020 22:20
question
English, 18.11.2020 22:20
question
Mathematics, 18.11.2020 22:20
question
Advanced Placement (AP), 18.11.2020 22:20
Questions on the website: 13722362