Program Id (Identif Ier List) : Mini PASCAL Grammar
Program Id (Identif Ier List) : Mini PASCAL Grammar
program →
program id ( identif ier list ) ;
declarations
subprogram declarations
compound statement
.
declarations →
declarations var identif ier list : type ;
|²
type →
standard type
| array [ num .. num ] of standard type
standard type →
integer
| real
subprogram declarations →
subprogram declarations subprogram declarion ;
|²
subprogram declaration →
subprogram head declarations compound statement
subprogram head →
function id arguments : standard type ;
| procedure id arguments ;
arguments →
( parameter list )
|²
parameter list →
identif ier list : type
| parameter list ; identif ier list : type
compound statement →
begin
optional statements
end
1
optional statements →
statement list
|²
statement list →
statement
| statement list ; statement
statement →
variable assignop expression
| procedure statement
| compound statement
| if expression then statement else statement
| while expression do statement
variable →
id
| id [ expression ]
procedure statement →
id
| id ( expression list )
expression list →
expression
| expression list , expression
expression →
simple expression
| simple expression relop simple expression
simple expression →
term
| sign term
| simple expression addop term
term →
f actor
| term mulop f actor
f actor →
id
| id ( expression list )
| num
| ( expression )
| not f actor
sign →
+|−