Question: Objectives; Java programming To describe a language using Context - Free Grammar ( CFG ) To describe an Abstract Syntax Tree ( AST ) for
Objectives; Java programming
To describe a language using ContextFree Grammar CFG
To describe an Abstract Syntax Tree AST for a small language.
To contrast an Abstract Syntax Tree from a Concrete Syntax Tree CST
To demonstrate how Abstract Syntax Trees can be used my compilers to identify and
describe syntactical errors.
Requirements:
Create a ContextFree Grammar
Consider the following operations from boolean relational operators:
Less Than Less Than or Equal
to
Greater than Greater Than or
Equal to
Equal to Not Equal
Using the following as a basis, create a contextfree grammar for the boolean
expressions.
S S S
S S S
S S S
S S S
S S S
S S S
S numerical negative infinity to positive infinity
Replace the s with your answer.
Create a Concrete Syntax Tree
Along with your solution from question add the following to include mathematical
operations in your CFG
S S S
S S S
S S S
S S S
S S
Use this CFG to create a concrete syntax tree for the following expression:
Convert to Abstract Syntax Tree
Using your Concrete Syntax Tree from question create an equivalent abstract syntax
tree.
Explain the error in terms of an AST
Consider the following boolean expression:
With the subtraction operation having no value to subtract from the this is a clear
syntax error.
Draw the Abstract Syntax Tree as far as you can, and stop when you can go no further.
Explain how this process of creating the AST demonstrates how it can leads to better
descriptions of syntax errors.
Abstract Syntax Tree
Explanation of error finding
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
