Description
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):
- a) procedure one is
two : integer;
beginend one;
- b) procedure two is
three, four : integer;
procedure five is
beginend five;
begin
end two;
- 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.