Question: The Program below is written in V language to check for errors, evaluate and print out P and R . START INTEGER M , N
The Program below is written in V language to check for errors, evaluate and print out P and R
START
INTEGER M N K P R H g k m
READ M N K
ASSIGN N M K
READ g H m
P gHlmNk
R MNK
WRITE P
STOP
The Grammar and Production rules:
EE RuleR
EEEEEEEEE R EEEEE REEEEJJABCZalbcz R
Note the following additional conditions in the above program:
e Words in capital letters are Keywords
e Words in small letters are Identifiers. Words in single letters from A Z and a to z are also Identifiers
e are Operators
e Equals and semi colon ; are Symbols
e Any stringline must contain: Keywords, Identifiers, Operators, or Symbols
e Symbols such as: $ &; not allowed and would give Semantic error
e Two operators must not be combined such as: not allowed and would give Syntax error,
same with other operators that are combined, for example
e Semi colon ; at the end of a line not allowed and would give Syntax error
e Numbers to are not allowed and would give Syntax error
e The acceptable keywords are: INTEGER, ASSIGN, READ, WRITE, START, STOP.
e Misspelling in the keywords such as: WRITEE not allowed and would give Lexical error
e Any other character on the keyboard different from all the above will give Syntax error.
e Note that text with yellow background in the above program have errors
Write a Java program that will go through the following stages of compiler to translate the
above program iteratively line by line.
Write a Java program that will go through the following stages of compiler to translate the
above program iteratively all at once.
Note: Only lines and should go through all the seven stages of compiler:
PgHltmNk and R MNK
The other lines should just check for errors and report the error if any
OUR SEVEN STAGES OF COMPILER
Lexical Analysis Scanner
Syntax Analysis Parser
Semantic Analysis Syntactic Analysis
Intermediate Code Representation ICR
Code Generation CG
Code Optimization CO
Target Machine code TMC in Binary
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
