ack/lang/m2/m2mm/expression.g

151 lines
1.5 KiB
Plaintext
Raw 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
*/
/* E X P R E S S I O N S */
/* stripped down version of the one in the Modula-2 compiler */
1994-06-24 14:02:31 +00:00
/* $Id$ */
1987-09-24 13:01:27 +00:00
qualident :
IDENT
[
selector
]*
;
selector :
'.' IDENT
;
ExpList :
expression
[
1988-02-17 17:21:51 +00:00
',' expression
1987-09-24 13:01:27 +00:00
]*
;
ConstExpression :
expression
/*
* Changed rule in new Modula-2.
*/
;
expression :
SimpleExpression
[
/* relation */
[ '=' | '#' | '<' | LESSEQUAL | '>' | GREATEREQUAL | IN ]
SimpleExpression
1988-02-17 17:21:51 +00:00
|
/* empty */
]
1987-09-24 13:01:27 +00:00
;
SimpleExpression :
[
1988-02-17 17:21:51 +00:00
'+'
|
'-'
|
/* empty */
]
1987-09-24 13:01:27 +00:00
term
[
/* AddOperator */
1988-02-17 17:21:51 +00:00
[ '+' | '-' | OR ] term
1987-09-24 13:01:27 +00:00
]*
;
term :
factor
[
/* MulOperator */
1988-02-17 17:21:51 +00:00
[ '*' | '/' | DIV | MOD | AND ] factor
1987-09-24 13:01:27 +00:00
]*
;
factor :
qualident
[
designator_tail?
[
ActualParameters
1988-02-17 17:21:51 +00:00
|
/* empty */
]
1987-09-24 13:01:27 +00:00
|
bare_set
]
|
bare_set
| %default
1988-02-17 17:21:51 +00:00
[ %default
1987-09-24 13:01:27 +00:00
INTEGER
|
REAL
|
STRING
]
|
'(' expression ')'
|
NOT factor
;
bare_set :
'{'
[
element
[
',' element
]*
1988-02-17 17:21:51 +00:00
|
/* empty */
]
1987-09-24 13:01:27 +00:00
'}'
;
ActualParameters :
'(' ExpList? ')'
;
element :
expression
[
1988-02-17 17:21:51 +00:00
UPTO expression
|
/* empty */
]
1987-09-24 13:01:27 +00:00
;
designator :
1988-02-17 17:21:51 +00:00
qualident designator_tail?
1987-09-24 13:01:27 +00:00
;
designator_tail :
visible_designator_tail
[ %persistent
1988-02-17 17:21:51 +00:00
%default
1987-09-24 13:01:27 +00:00
selector
|
visible_designator_tail
]*
;
visible_designator_tail :
'['
expression
[
',' expression
]*
']'
|
'^'
;