logo Use SA10RAM to get 10%* Discount.
Order Now logo

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Lee BohlGeneral article writing
(5/5)

599 Answers

Hire Me
expert
Denis GibbssScience
(5/5)

551 Answers

Hire Me
expert
Tanushri MehtaGeneral article writing
(5/5)

598 Answers

Hire Me
expert
Violeta BaoMarketing
(5/5)

712 Answers

Hire Me
Computer Science

For this phase, you will use Lex tool for writing the scanner and Yacc tool for writing the parser for a programming language called AA.

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

CSC340:Programming Languages and Compilers

1     AA Language

For this phase, you will use Lex tool for writing the scanner and Yacc tool for writing the parser for a programming language called AA.

1.    The Scanner and the Lexemes:

  • Keywords: int, double, if, read, print, while,START,END.

•       Operators:

  • Arithmetic: + , - , * , /

–   Logic:    &&,||,!

–   Relational:    ==, <>, <, <=, >,>=

  • Assignment: =
  • Punctuation elements: (),,,{}

Precedence and associativity

The table below shows all AA operators from highest to lowest precedence, along with their associativity.

 

Table 1: precedence and associativity table

Operator

Description

Associativity

!

Unary Logical NOT

right to left

∗/

Multiplication/Division

left to right

+−

Addition/ Subtraction

left to right

<, <=, >,>=

Relational

left to right

=<>

Equality

left to right

&&

Logical AND

left to right

||

Logical OR

left to right

=

Assignment

right to left

 

 

 

Identifiers: should start with capital letter and can include small, capital letters, underscores, or digits.

  • Comment: is sequence of any characters between double hash ##..... ##

Literals: INT LITERAL e.g. 12345, STRING LITERAL e.g. "Hello"and DBL LITERAL e.g. 3.14.

2.    The Parser and the Grammar:

When YACC finds input that doesn’t match the grammar, it automatically termi- nates with the message ’Syntax error’. You will need to implement an error routine (yyerror) that also prints out the line number before this termination, and a main method that read AA code from a file. Print an appropriate message in case of no syntax error. Build your parser using the grammar below:

2    Deliverable and rules

 Write the Lex and Yacc file for AA language as described above. Once you built your parser, you should be able to parse AA programs. If you want to test your code, consider the following program.

This program should be compiled and have no errors. Note that this program does not cover all functionalities that could be tested based on the given specification. Test your code thoroughly. If the input program is in different syntax than the given grammar, your parser should report an error.

You must deliver one zip including:

  • A soft copy of a lex file ”phase1.l”
  • A soft copy of a YACC file ”phase1.y”

Deadline is: Saturday March 14th, 2020 (11:59 pm).

Related Questions

. The fundamental operations of create, read, update, and delete (CRUD) in either Python or Java

CS 340 Milestone One Guidelines and Rubric  Overview: For this assignment, you will implement the fundamental operations of create, read, update,

. Develop a program to emulate a purchase transaction at a retail store. This  program will have two classes, a LineItem class and a Transaction class

Retail Transaction Programming Project  Project Requirements:  Develop a program to emulate a purchase transaction at a retail store. This

. The following program contains five errors. Identify the errors and fix them

7COM1028   Secure Systems Programming   Referral Coursework: Secure

. Accepts the following from a user: Item Name Item Quantity Item Price Allows the user to create a file to store the sales receipt contents

Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip

. The final project will encompass developing a web service using a software stack and implementing an industry-standard interface. Regardless of whether you choose to pursue application development goals as a pure developer or as a software engineer

CS 340 Final Project Guidelines and Rubric  Overview The final project will encompass developing a web service using a software stack and impleme

Get Free Quote!

262 Experts Online