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 ;...



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 ) ;

    }

Set of Productions:













































































































































































































































































































































































P01:FNFN–HEAD   FN–BODY
P02:FN–HEADTYPE   id
(  PARAM–LIST
)
P03:TYPEchar
P04:TYPEint
P05:TYPEreal
P06:PARAM–LISTTYPE   id
P07:PARAM–LISTPARAM–LIST
,
TYPE   id
P08:FN–BODY
{
VAR–DECL   STMT
return   (
EXPRESN
)   ;   }
P09:VAR–DECLλ
P10:VAR–DECLTYPE   ID–LIST
;
P11:VAR–DECLVAR–DECL   TYPE   ID–LIST
;

P12:ID–LISTid
P13:ID–LISTID–LIST
,  id
P14:STMTλ
P15:STMTSIMPLE–STMT
P16:STMTSELECT–STMT
P17:STMTREPEAT–STMT
P18:STMTSEQUENCE–STMT
P19:SIMPLE–STMTASSIGN–STMT
P20:SIMPLE–STMTFN–CALL–STMT
P21:ASSIGN–STMTvar
=
EXPRESN
;
P22:EXPRESNARITH–EXP
P23:EXPRESNBOOL–EXP
P24:ARITH–EXPTERM
P25:ARITH–EXPARITH–EXP   ADD–OP   TERM
P26:ADD–OP+
P27:ADD–OP
P28:TERMFAC
P29:TERMTERM   MUL–OP   FAC
P30:MUL–OP*
P31:MUL–OP/
P32:FAC
(
ARITH–EXP
)
P33:FACOPD
P34:OPDvar
P35:OPDconst
P36:BOOL–EXPRELN–EXP
P37:BOOL–EXPLOGIC–EXP
P38:RELN–EXPOPD   RELN–OPR   OPD
P39:RELN–OPR==
P40:RELN–OPR!=
P41:RELN–OPR
P42:RELN–OPR<>
P43:RELN–OPR
>
P44:RELN–OPR
>=
P45:LOGIC–EXPOPD   LOGIC–OPR   OPD
P46:LOGIC–EXPLOGIC–OPR   OPD
P47:LOGIC–OPRand
P48:LOGIC–OPRor
P49:LOGIC–OPRnot
P50:FN–CALL–STMTid
(  ARG–LIST
)   ;
P51:ARG–LISTλ
P52:ARG–LISTid
P53:ARG–LISTARG–LIST
,
id
P54:SELECT–STMT
if
CONDITION   STMT
else
STMT
P55:CONDITION
(
BOOL–EXP
)
P56:REPEAT–STMTDO–STMT
P57:REPEAT–STMTWHILE–STMT
P58:DO–STMT
do   {
STMT
}   while
CONDITION
;
P59:WHILE–STMT
while
CONDITION
do   {
STMT
}   ;
P60:SEQUENCE–STMTSTMT   STMT
Jun 06, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here