Rewrite the set of productions in extended backus-naur form

Assignment Help Programming Languages
Reference no: EM131309093

PROJECT ON GRAMMARS

 

Course: IST 230/CMPSC 360

 

Deadline: see the calendar in Canvas for the deadline

 

Objective: To acquire a comprehensive understanding of the application of grammars and formal language theory to computing languages.

 

Given: Consider the following set of productions:

 

P01:

FN

FN-HEAD   FN-BODY

P02:

FN-HEAD

TYPE   id   (  PARAM-LIST   )

P03:

TYPE

char

P04:

TYPE

int

P05:

TYPE

real

P06:

PARAM-LIST

TYPE   id

P07:

PARAM-LIST

PARAM-LIST   ,   TYPE   id

P08:

FN-BODY

{   VAR-DECL   STMT   return   (   EXPRESN   )   ;   }

P09:

VAR-DECL

ë

P10:

VAR-DECL

TYPE   ID-LIST   ;

P11:

VAR-DECL

VAR-DECL   TYPE   ID-LIST   ;

P12:

ID-LIST

id

P13:

ID-LIST

ID-LIST   ,  id

P14:

STMT

ë

P15:

STMT

SIMPLE-STMT

P16:

STMT

SELECT-STMT

P17:

STMT

REPEAT-STMT

P18:

STMT

SEQUENCE-STMT

P19:

SIMPLE-STMT

ASSIGN-STMT

P20:

SIMPLE-STMT

FN-CALL-STMT

P21:

ASSIGN-STMT

var   =   EXPRESN   ;

P22:

EXPRESN

ARITH-EXP

P23:

EXPRESN

BOOL-EXP

P24:

ARITH-EXP

TERM

P25:

ARITH-EXP

ARITH-EXP   ADD-OP   TERM

P26:

ADD-OP

+

P27:

ADD-OP

-

P28:

TERM

FAC

P29:

TERM

TERM   MUL-OP   FAC

P30:

MUL-OP

*

P31:

MUL-OP

/

P32:

FAC

(   ARITH-EXP   )

P33:

FAC

OPD

P34:

OPD

var

P35:

OPD

const

P36:

BOOL-EXP

RELN-EXP

P37:

BOOL-EXP

LOGIC-EXP

P38:

RELN-EXP

OPD   RELN-OPR   OPD

P39:

RELN-OPR

==

P40:

RELN-OPR

!=

P41:

RELN-OPR

P42:

RELN-OPR

<=

P43:

RELN-OPR

P44:

RELN-OPR

>=

P45:

LOGIC-EXP

OPD   LOGIC-OPR   OPD

P46:

LOGIC-EXP

LOGIC-OPR   OPD

P47:

LOGIC-OPR

and

P48:

LOGIC-OPR

or

P49:

LOGIC-OPR

not

P50:

FN-CALL-STMT

id   (  ARG-LIST   )   ;

P51:

ARG-LIST

ë

P52:

ARG-LIST

id

P53:

ARG-LIST

ARG-LIST   ,   id

P54:

SELECT-STMT

if   CONDITION   STMT   else   STMT

P55:

CONDITION

(   BOOL-EXP   )

P56:

REPEAT-STMT

DO-STMT

P57:

REPEAT-STMT

WHILE-STMT

P58:

DO-STMT

do   {   STMT   }   while   CONDITION   ;

P59:

WHILE-STMT

while   CONDITION   do   {   STMT   }   ;

P60:

SEQUENCE-STMT

STMT   STMT

Instructions:

 

1. Rewrite the set of productions above in Extended Backus-Naur Form (EBNF).

 

2.  Using a Push Down Automaton (PDA), determine if the following function is valid code according to the given set of productions.

 

int Max ( int x, int y )
{
int z ;

 

if ( x >y )
z = x ;
else
z = y ;

 

return ( z ) ;
}

 

3.  Validate your answer in (2) by illustrating it with a derivation tree

 

Deliverable: Submit a paper Times New Roman font, 12 pt., double-space lines). The project must contain an introduction which includes the purpose of the project.

 

1)

 

BNF:

 

1. <FN> ::= <FN-HEAD> <FN-BODY>
2. <FN-HEAD> ::= <TYPE> ( <PARAM-LIST)> )
3. <TYPE> ::= "char" | "int" | "real"
4. <PARAM-LIST> ::= <PARAM-LIST> , <TYPE> | <TYPE>
5. <FN-BODY> ::={ <VAR-DECL> <STMT> return ( <EXPRESN> ) ; }
6. <VAR-DECL> ::= "" | <TYPE> <ID-LIST> | <VAR-DECL> <TYPE> < ID-LIST>
7. <ID-LIST> ::= <id> | <ID-LIST> | <id>
8. <STMT> ::= "" | <SIMPLE-STMT> | <SELECT-STMT> | <REPEAT-STMT> | SEQUENCE - STMT
9. <SIMPLE-STMT> ::= <ASSIGN-STMT> | <FN-CALL-STMT>
10. <ASSIGN-STMT> ::= "var" = <EXPRESN ;>
11. <EXPRESN> ::= <ARITH-EXP> | <BOOL-EXP>
12. <ARITH-EXP> ::== <TERM> | <ARITH-EXP> | <ADD OP> | <TERM>
13. <ADD-OP> ::= "+" | "-"
14. <TERM> ::= <FAC> | <TERM> <MUL-OP> <FAC>
15. <MUL-OP> ::= "*" | "/"
16. <FAC> ::= ( <ARITH-EXP> ) | <OPD>
17. <OPD> ::= "var" | "const"
18. <BOOL-EXP> ::== <RELN-EXP> | <LOGIC-EXP>
19. <RELN-EXP> ::= <OPD> <RELN-OPR> <OPD>
20. <RELN-OPR> ::= "==" | "!=" | "<" | "<=" | ">" | ">="
21. <LOGIC-EXP> ::= <OPD> | <LOGIC-OPR> | <OPD> | <LOGIC-OPR> | <OPD>
22. <LOGIC-OPR> ::= "and" | "or" | "not"
23. <FN-CALL-STMT> ::= "id" ( <ARG-LIST> ) ;
24. <ARG-LIST> ::= "" | "id" | <ARG-LIST> "id"
25. <SELECTION-STMT> ::= if <CONDITION> <STMT> else <STMT>
26. <CONDITION> ::= <(BOOL-EXP)>
27. <REPEAT-STMT> ::= <DO-STMT> | <WHILE-STMT>
28. <DO-STMT> ::= do { <STMT> } while <CONDITION>;
29. <WHILE-STMT> ::= while <CONDITION> do { <STMT> }
30. <SEQUENCE-STMT> ::= <STMT> <STMT>

 

EBNF:

 

1. <FN> ::= <FN-HEAD> <FN-BODY>
2. <FN-HEAD> ::= <TYPE> ( <PARAM-LIST)>* )
3. <TYPE> ::= "char" | "int" | "real"
4. <PARAM-LIST> ::= <PARAM-LIST> , <TYPE>+ | <TYPE>+
5. <FN-BODY> ::= { <VAR-DECL>* <STMT> return ( <EXPRESN> ) ; }
6. <VAR-DECL> ::= "" | <TYPE> <ID-LIST>* | <VAR-DECL>* <TYPE> < ID-LIST>*
7. <ID-LIST> ::= "id" | <ID-LIST>* , "id"
8. <STMT> ::= "" | <SIMPLE-STMT> | <SELECT-STMT> | <REPEAT-STMT> | <SEQUENCE - STMT>
9. <SIMPLE-STMT> ::= <ASSIGN-STMT> | <FN-CALL-STMT>
10. <ASSIGN-STMT> ::= "var" = <EXPRESN> ;
11. <EXPRESN> ::= <ARITH-EXP*> | <BOOL-EXP>
12. <ARITH-EXP> ::== <TERM>* | <ARITH-EXP>* <ADD OP> <TERM>*
13. <ADD-OP> ::= "+" | "-"
14. <TERM> ::= <FAC> | <TERM>* <MUL-OP> <FAC>
15. <MUL-OP> ::= "*" | "/"
16. <FAC> ::= ( <ARITH-EXP>* ) | <OPD>
17. <OPD> ::= "var" | "const"
18. <BOOL-EXP> ::== <RELN-EXP> | <LOGIC-EXP>
19. <RELN-EXP> ::= <OPD> <RELN-OPR> <OPD>
20. <RELN-OPR> ::= "==" | "!=" | "<" | "<=" | ">" | ">="
21. <LOGIC-EXP> ::= <OPD> <LOGIC-OPR> <OPD> | <LOGIC-OPR> <OPD>
22. <LOGIC-OPR> ::= "and" | "or" | "not"
23. <FN-CALL-STMT> ::= "id" ( <ARG-LIST>* ) ;
24. <ARG-LIST> ::= "" | "id" | <ARG-LIST>* "id"
25. <SELECTION-STMT> ::= if <CONDITION> <STMT> else <STMT>
26. <CONDITION> ::= <(BOOL-EXP)>
27. <REPEAT-STMT> ::= <DO-STMT> | <WHILE-STMT>
28. <DO-STMT> ::= do { <STMT> } while <CONDITION>;
29. <WHILE-STMT> ::= while <CONDITION> do { <STMT> }
30. <SEQUENCE-STMT> ::= <STMT> <STMT>

Reference no: EM131309093

Questions Cloud

Write an attack script or a program to display the secret : CE4062-CZ4062: COMPUTER SECURITY (SYSTEM SECURITY) ASSIGNMENT. Your first task is to write an attack script or a program to display the secret of any of the following users: alice, charlie, dennis, eve, or fong. The attack program takes one argumen..
Prepare cover letter to introduce the questionnaire prepared : Prepare a cover letter to introduce the questionnaire prepared for Exercise. The letter should encourage readers to complete the questionnaire and return it quickly in the stamped, addressed envelope.
First time to manage a large business meeting : You have been asked for the first time to manage a large business meeting. The corporate executives will attend, and if they like the way you organize the event, there will be some great recommendations.
What is the government spending multiplier : If government purchases and taxes are increased by $100 billion simultaneously, what will the effect be on equilibrium output (income)?
Rewrite the set of productions in extended backus-naur form : Course: IST 230/CMPSC 360- Rewrite the set of productions above in Extended Backus-Naur Form (EBNF).  Using a Push Down Automaton (PDA), determine if the following function is valid code according to the given set of productions.
Determining the knowledge of functionalism : How could a knowledge of functionalism help you to see the problems before they happen? Where would conflict arise? Who might work at undermining your event? What icons would make the event memorable?
Presents an exhaustive list of ice cream flavors : Write a question that presents an exhaustive list of ice cream flavors. You also want to know how much people are willing to pay for a single scoop of ice cream and a double scoop of ice cream.
What is the balanced-budget multiplier : Evaluate the following statement: For an economy to be in equilibrium, planned investment spending plus government purchases must equal saving plus net taxes.
How did the roman way of waging war contrast with the greek : How did the Roman way of waging war contrast with the Greek way? What was accomplished by strategic bombing during World War II? What costs were borne by the nations that employed it?

Reviews

Write a Review

Programming Languages Questions & Answers

  What will the exp days column contain

If expiration_date contains a value that's equivalent to November 2, 2008 and the SYSDATE function returns a value that's equivalent to December 17, 2008, what will the exp_days column contain when this code is executed

  Program that checks whether two given strings are circular

Detecting this condition is important in the study of genomic sequences. Write a program that checks whether two given strings s and t are circular

  Write program to prints question do you want to continue

Write a program which prints question"do you want to continue?"and reads user input. if user input is"y", "yes", "ok", "sure", or "why not?" , print out "ok".

  Write application to count number of both odd-even integers

Write application to count number of both odd and even integers of several positive integers. Fisrt value entered specifies number of values to input from user.

  Write down public static method using public interface

Using only public interface of UnorderedLinkedList class, write down a method: public static void reverse(UnorderedLinkedList staff) that reverses the entries in a linked list.

  Program to run at end of semester to produce grade summary

Write the program for instructor to run at the end of the semester to produce grade summary for one student, as shown in box below.

  Write a program using the rand function

Write a program using the rand() function and a large array to find the standard deviation, variance and mean as well as the min and max values of the array.

  Program in c# that simulates the operation of the turtle

Write a program in C# that simulates the operation of the turtle and implements a computerized sketchpad. Write several turtle graphics programs that draw interesting shapes to use for testing your program.

  Write program which asks user for the url of a pdf file

Write a program which asks the user for the URL of a PDF file, checks that the URL starts with "http://" and ends with "pdf" or "PDF", downloads it with wget, and displays it with display.

  Create script which checks day of the week

Create a script which checks day of the week, and takes one of two actions (step 2 or 3) depending on the day. If day is Monday through Friday, print (send to stdout) name of the day.

  Program to read the records until end of file

Zip code, county and number of boxes. The program should read the records until end of file is encountered and produce enough mailing labels for each order.

  Different class maintain programming programs are organized

It allows different classes to maintain programming so that programs are kept more organized. Object orientation also allows a programmer to use the same objects in different programs. Response?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd