Solved CSC 446 Assign #2 Given the following grammar for a subset of Ada: Prog                                 ->          procedure idt Args is

$30.00

Original Work ?

Download Details:

  • Name: A2-Parser-uzgoq5.zip
  • Type: zip
  • Size: 1.88 MB

Category: Tags: , You will Instantly receive a download link upon Payment||Click Original Work Button for Custom work

Description

5/5 - (1 vote)

Given the following grammar for a subset of Ada:

 

Prog                                 ->          procedure idt Args is

DeclarativePart

Procedures

begin

SeqOfStatements

end idt;

 

DeclarativePart           ->          IdentifierList : TypeMark ; DeclarativePart | e

 

IdentifierList                ->          idt |

IdentifierList , idt

 

TypeMark                      ->          integert | realt | chart | const assignop Value

 

Value                               ->          NumericalLiteral

 

Procedures                    ->          Prog Procedures | e

 

Args                                  ->          ( ArgList ) | e

 

ArgList                            ->          Mode IdentifierList : TypeMark MoreArgs

 

MoreArgs                       ->          ; ArgList | e

 

Mode                                ->          in | out | inout | e

 

SeqOfStatments           ->          e

 

 

 

Draw the parse trees for the following programs (PLEASE UNDERLINE ALL TOKENS):

  1. a) procedure one is
    two : integer;
    begin

    end one;

 

  1. b) procedure two is
    three, four : integer;
    procedure five is
    begin

    end five;

begin

end two;

 

  1. c) procedure three is
    four, five : integer;
    procedure six ( in seven : integer ; eight : integer ) is
    begin

end six;
begin

end three;

Hint: You will probably want to use your paper sideways. Save this grammar, as it will be used in the next assignment.