previous         next         contents

Appendix A: Ml4-Syntax

This is the syntax of Ml4 by means of a slightly enlarged EBNF. The $i sign has been adapted to indicate those terminal identifiers, which can be abbrivated to i characters.
However, this grammar was simplified for human use. (So it is no good idea to try to generate a Ml4 parser from it.)

Ml4Trans =
{ Ml4Unit } .
Ml4Unit =
Ml4Module
| Ml4Pre Ml4Rule [ "INIT" Ml4SrcExp ].
Ml4Pre =
[ "$6IMPORTS" id { "," id } ";" ]
[ "TYPE" Ml4TypeDecl "$3TYPEND" ";" ]
[ "VAR" Ml4Vars ";" ].
Ml4Module =
"MODULE" id Ml4Pre Ml4Rule { Ml4Rule } [ "INIT" Ml4SrcExp ] "END" id.
Ml4TypeDecl =
{ id "=" Ml4Type ";" } .
Ml4Type =
( "$4BOOLEAN"| "$3INTEGER" | "REAL" | "SYM"
| "TXT" | "$3RECORD" Ml4FieldList { ";" Ml4FieldList } "END"
| "FLEX" [( "1" | "2" )] "OF" Ml4Type | "$3ARRAY" num "OF" Ml4Type
| Ml4QualId
| id ).
Ml4FieldList =
id { "," id } ":" Ml4Type .
Ml4Rule =
id [ "(" Ml4FParams ")" ] "=" [ "GLOBVAR" Ml4GlobVars ] [ "VAR" Ml4Vars ] [ "LOCAL" Ml4Locals ]
Ml4SrcExp ["=>" Ml4Expr ] { "->" Ml4TrgExp } "." .
Ml4FParams =
Ml4FParam { ";" Ml4FParam } .
Ml4FParam =
id { "," id } ":" Ml4Type [ ":=" Ml4Expr ] .
Ml4GlobVars =
{ ( "USE" | "DCL" ) Ml4VarDecl } .
Ml4Vars =
{ [ "VAR" ] Ml4VarDecl} .
Ml4VarDecl =
id { "," id } ":" Ml4Type ";" .
Ml4Locals =
Ml4StrVar "<-" Ml4StrVar { "," Ml4StrVar "<-" Ml4StrVar } ";".
Ml4StrVar =
( Ml4VarUse | str ).
Ml4Control=
"/" [ Ml4Expr ] "/".
Ml4SrcExp =
[ Ml4Control] Ml4SrcFact { "|" Ml4SrcFact } .
Ml4SrcElem =
( "{" [ "/" [ id ] [ "=" Ml4Expr ] [ ".." Ml4Expr ] "/" ] Ml4SrcExp "}"
| "[" [ Ml4Control ] Ml4SrcExp "]" | "(" Ml4SrcExp ")" | "<" Ml4SrcExp ">"
| str | "!!" | "!" Ml4Expr | Ml4Call
| Ml4VarUse [ ":=" Ml4Expr ]
| ( id ":" id | id )
[ "(" ( id ":=" Ml4VarUse | Ml4Expr | ) { "," ( id ":=" Ml4VarUse | Ml4Expr | ) } ")" ]
["[" Ml4Expr [ "," Ml4Expr ] "]" ]
| "$" )
{ ";" } .
Ml4SrcFact =
{ Ml4SrcElem } .
Ml4Expr =
[ "+" | "-" ] Ml4Fact
{ ( "+" | "-" | "*" | "DIV" | "MOD" | "&" | "OR" ) Ml4Fact }
[ ( "=" | "#" | "<="| ">=" | "<" | ">" ) [ "+" | "-" ] Ml4Fact
{ ( "+" | "-" | "*" | "DIV" | "MOD" | "&" | "OR" ) Ml4Fact } ].
Ml4Fact =
( "(" Ml4Expr ")" | Ml4Call | Ml4VarUse | num | str | "TRUE" | "FALSE" | "NOT" Ml4Fact ).
Ml4VarUse =
( < id [( "_0" | "_" [num] } ) > ] [ < "[" > Ml4Expr [ "," Ml4Expr ] "]" ]
| ( Ml4QualId | id ) [ Ml4VarUseX ] ).
Ml4VarUseX =
( "." id
| < "[" > Ml4Expr{ "," Ml4Expr} "]" ) [ Ml4VarUseX] .
Ml4Call =
( id | Ml4QualId ) [ "(" [ Ml4Expr { "," Ml4Expr } ] ")" ].
Ml4QualId =
id "." id .
Ml4TrgExp =
[ Ml4Control ] Ml4TrgFact { "|" Ml4TrgFact } .
Ml4TrgFact =
{ Ml4TrgElem } .
Ml4TrgElem =
( str
| "{" [ "/" [ id ] [ "=" Ml4Expr ] [ ".." Ml4Expr ] "/" ] Ml4TrgExp "}"
| "[" [ Ml4Control ] Ml4TrgExp "]"
| "(" "!" Ml4Expr ";" Ml4TrgFact [ "|" Ml4TrgFact ] ")"
| "(" Ml4TrgExp ")"
| "<" Ml4TrgExp ">"
| "SOURCETEXT"
| Ml4Expr )
{ ";" } .


    previous         next         contents


© J. Lampe 1997-2010