ack/lang/m2/m2mm/statement.g

138 lines
1.6 KiB
Plaintext
Raw Permalink Normal View History

1987-09-24 13:01:27 +00:00
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*
* Author: Ceriel J.H. Jacobs
*/
/* S T A T E M E N T S */
/* stripped down version from the one in the Modula-2 compiler */
1994-06-24 14:02:31 +00:00
/* $Id$ */
1987-09-24 13:01:27 +00:00
{
#include "idf.h"
#include "LLlex.h"
static int loopcount;
}
statement :
[
/*
* This part is not in the reference grammar. The reference grammar
* states : assignment | ProcedureCall | ...
* but this gives LL(1) conflicts
*/
designator
[
ActualParameters?
|
[ BECOMES
| %erroneous
'=' { error("':=' expected instead of '='");
1987-09-24 13:01:27 +00:00
DOT = BECOMES;
}
]
expression
]
/*
* end of changed part
*/
|
IfStatement
|
CaseStatement
|
WHILE
expression
DO
StatementSequence
END
|
REPEAT
StatementSequence
UNTIL
expression
|
{ loopcount++; }
LOOP
StatementSequence
END
{ loopcount--; }
|
ForStatement
|
WithStatement
|
EXIT
{ if (!loopcount) error("EXIT not in a LOOP"); }
|
ReturnStatement
|
/* empty */
]
;
StatementSequence :
statement
[ %persistent
';'
statement
]*
;
IfStatement :
IF expression
THEN StatementSequence
[
ELSIF expression
THEN StatementSequence
]*
[
ELSE StatementSequence
]?
END
;
CaseStatement :
CASE expression
OF case
[
'|' case
]*
[ ELSE StatementSequence
]?
END
;
case :
[ CaseLabelList ':'
StatementSequence
]?
;
ForStatement :
FOR IDENT BECOMES expression TO expression
[
BY ConstExpression
|
]
DO StatementSequence
END
;
WithStatement :
WITH designator DO StatementSequence
END
;
ReturnStatement :
RETURN
[
expression
|
]
;