1986-03-26 15:11:02 +00:00
|
|
|
/* S T A T E M E N T S */
|
|
|
|
|
1986-03-20 14:52:03 +00:00
|
|
|
{
|
|
|
|
static char *RcsId = "$Header$";
|
1986-04-06 17:42:56 +00:00
|
|
|
|
|
|
|
#include <em_arith.h>
|
|
|
|
#include "LLlex.h"
|
|
|
|
#include "node.h"
|
1986-03-20 14:52:03 +00:00
|
|
|
}
|
|
|
|
|
1986-04-06 17:42:56 +00:00
|
|
|
statement
|
|
|
|
{
|
|
|
|
struct node *nd1, *nd2;
|
|
|
|
} :
|
1986-03-20 14:52:03 +00:00
|
|
|
[
|
|
|
|
/*
|
|
|
|
* This part is not in the reference grammar. The reference grammar
|
|
|
|
* states : assignment | ProcedureCall | ...
|
|
|
|
* but this gives LL(1) conflicts
|
|
|
|
*/
|
1986-04-06 17:42:56 +00:00
|
|
|
designator(&nd1)
|
1986-03-20 14:52:03 +00:00
|
|
|
[
|
1986-04-06 17:42:56 +00:00
|
|
|
ActualParameters(&nd2)?
|
1986-03-20 14:52:03 +00:00
|
|
|
|
|
1986-04-06 17:42:56 +00:00
|
|
|
BECOMES expression(&nd2)
|
1986-03-20 14:52:03 +00:00
|
|
|
]
|
|
|
|
/*
|
|
|
|
* end of changed part
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
IfStatement
|
|
|
|
|
|
|
|
|
CaseStatement
|
|
|
|
|
|
|
|
|
WhileStatement
|
|
|
|
|
|
|
|
|
RepeatStatement
|
|
|
|
|
|
|
|
|
LoopStatement
|
|
|
|
|
|
|
|
|
ForStatement
|
|
|
|
|
|
|
|
|
WithStatement
|
|
|
|
|
|
|
|
|
EXIT
|
|
|
|
|
|
1986-04-06 17:42:56 +00:00
|
|
|
RETURN
|
|
|
|
[
|
|
|
|
expression(&nd1)
|
|
|
|
]?
|
1986-03-20 14:52:03 +00:00
|
|
|
]?
|
|
|
|
;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The next two rules in-line in "Statement", because of an LL(1) conflict
|
|
|
|
|
|
|
|
assignment:
|
|
|
|
designator BECOMES expression
|
|
|
|
;
|
|
|
|
|
|
|
|
ProcedureCall:
|
|
|
|
designator ActualParameters?
|
|
|
|
;
|
|
|
|
*/
|
|
|
|
|
|
|
|
StatementSequence:
|
|
|
|
statement [ ';' statement ]*
|
|
|
|
;
|
|
|
|
|
1986-04-06 17:42:56 +00:00
|
|
|
IfStatement
|
|
|
|
{
|
|
|
|
struct node *nd1;
|
|
|
|
} :
|
|
|
|
IF expression(&nd1) THEN StatementSequence
|
|
|
|
[ ELSIF expression(&nd1) THEN StatementSequence ]*
|
1986-03-20 14:52:03 +00:00
|
|
|
[ ELSE StatementSequence ]?
|
|
|
|
END
|
|
|
|
;
|
|
|
|
|
1986-04-06 17:42:56 +00:00
|
|
|
CaseStatement
|
|
|
|
{
|
|
|
|
struct node *nd;
|
|
|
|
} :
|
|
|
|
CASE expression(&nd) OF case [ '|' case ]*
|
1986-03-20 14:52:03 +00:00
|
|
|
[ ELSE StatementSequence ]?
|
|
|
|
END
|
|
|
|
;
|
|
|
|
|
|
|
|
case:
|
|
|
|
[ CaseLabelList ':' StatementSequence ]?
|
|
|
|
/* This rule is changed in new modula-2 */
|
|
|
|
;
|
|
|
|
|
1986-04-06 17:42:56 +00:00
|
|
|
WhileStatement
|
|
|
|
{
|
|
|
|
struct node *nd;
|
|
|
|
}:
|
|
|
|
WHILE expression(&nd) DO StatementSequence END
|
1986-03-20 14:52:03 +00:00
|
|
|
;
|
|
|
|
|
1986-04-06 17:42:56 +00:00
|
|
|
RepeatStatement
|
|
|
|
{
|
|
|
|
struct node *nd;
|
|
|
|
}:
|
|
|
|
REPEAT StatementSequence UNTIL expression(&nd)
|
1986-03-20 14:52:03 +00:00
|
|
|
;
|
|
|
|
|
1986-04-06 17:42:56 +00:00
|
|
|
ForStatement
|
|
|
|
{
|
|
|
|
struct node *nd1, *nd2, *nd3;
|
|
|
|
}:
|
1986-03-20 14:52:03 +00:00
|
|
|
FOR IDENT
|
1986-04-06 17:42:56 +00:00
|
|
|
BECOMES expression(&nd1)
|
|
|
|
TO expression(&nd2)
|
|
|
|
[ BY ConstExpression(&nd3) ]?
|
1986-03-20 14:52:03 +00:00
|
|
|
DO StatementSequence END
|
|
|
|
;
|
|
|
|
|
|
|
|
LoopStatement:
|
|
|
|
LOOP StatementSequence END
|
|
|
|
;
|
|
|
|
|
1986-04-06 17:42:56 +00:00
|
|
|
WithStatement
|
|
|
|
{
|
|
|
|
struct node *nd;
|
|
|
|
}:
|
|
|
|
WITH designator(&nd) DO StatementSequence END
|
1986-03-20 14:52:03 +00:00
|
|
|
;
|