Syntax of Galileo


The syntax is built upon the characters, lexical elements, keywords, predefined identifiers and operators.


Phrase ::=
   [Exp | "let" Decl | Command] ";".

Command ::=
   "load" String | "quit" | "outputoff" | "outputon" | ":" TypeIde.

SimpleExp ::=
   Ide |
   Number |
   String |
   "{" "}" ":" "seq" Type |
   "{" {Exp /";"} "}" |
   "[" {Ide ":=" Exp / ("and" | ";") } "]" |
   "(|" Ide [ ":=" Exp] "|)" |
   Exp, Exp |
   "(" {Exp /";"}1 ")".

Exp ::=
   SimpleExp |
   "assert" Exp ["elsefail" Exp] |
   Exp "(" {Exp /","} ")" |
   Exp "[" {Type / ";"} "]" |
   Exp "[" {Type / ";"} "]" "(" {Exp /","} ")" |
   Exp ":" Type |
   PrefixOp Exp |
   Exp InfixOp Exp |
   Ide "In" Exp |
   "exit" |
   "fail" |
   "failwith" Exp |
   "if" Exp "then" Exp "else" Exp |
   "while" Exp "do" Exp |
   "use" Decl "in" Exp |
   "case" Exp "when" "(|" {Ide ":=" Ide "." Exp /"or"}1 "|)" |
   Exp "iffails" Exp |
   Exp "casefails" Exp Exp |
   "fun" "("{ Ide ":" Type /","} ")" ":" Type "is" Exp |
   "fun" "[" { Ide ["<:" Type] /";"} "]"
         "("{ Ide ":" Type /","} ")" ":" Type "is" Exp |
   "select" Exp "from" Exp |
   "get" Exp |
   "some" Exp "with" Exp |
   "each" Exp "with" Exp |
   Exp"."Ide |
   Exp"!"Ide |
   "super."Ide |
   Exp "isalso" Ide |
   Exp "isexactly" Ide |
   Exp "As" Ide |
   "loop" Exp "do" Exp |
   Exp ".*" Exp |
   Exp "groupby" "[" {Ide ":=" Exp / ("and" | ";") } "]" |
   Exp ("extend" | "extend*") "[" {Ide [":" Type] ":=" 
                                  ( Exp  | 
                                   "meth" "("{Ide ":" Type /","} ")"
                                           ":" Type "is" Exp ) /";"}
                              "]" |
   Exp ("project" | "project*") "[" {Ide [":" Type]  /";"} "]" |
   Exp ("times" | "times*") Exp |
   Exp ("rename" | "rename*") "(" {Ide[{"."Ide}] "=>" Ide /";"} ")".

Decl ::=
   ValBind |
   Decl "and" Decl |
   "rec" Decl |
   "type" TypeBind |
   Decl "ext" Decl.
   
ValBind ::=
   ["private"] Ide ":=" ( Exp | "derived" Exp) |
   Ide "class" AbsTypeBind ["key" "(" {Ide / "," } ")" ] |
   Ide "subset" "of" Ide "class" SubAbsTypeBind
         ["key" "(" {Ide /"," } ")" ].

TypeBind ::=
   Ide ":=" Type | AbsTypeBind | SubAbsTypeBind.
   
AbsTypeBind ::=
   Ide "<->" [Type | ExtRecordType] 
             [BeforeMK] [BeforeIn] [BeforeDrop]

SubAbsTypeBind ::=   
   Ide "<->" "is" Ide ["and" ExtRecordType]
             [BeforeMK] [BeforeIn] [BeforeDrop]

Type ::=
   "seq" Type |
   "var" Type |
   "optional" Type |
   "["{Ide ":" Type /";"} "]" |
   "(|" {Ide ":" Type /"or"} "|)" |
   Ide |
   {Type /"#"}2 |
   Type "->" Type |
   "all" "["{Ide ["<:" Type] /";"} "]" Type "->" Type |
   "<" {Type /","} ">" "view" "[" {Ide [":" Type]/";"}"]".
   
ExtRecordType ::=
    "["{["private"] Ide (":" Type | 
                        ":=" (Exp | 
                              "meth" "("{Ide ":" Type /","} ")"
                                           ":" Type "is" Exp )
                             ) /";"} "]".
BeforeMK   ::=  "before" "mk" "(" Ide ")" {"if" Exp "do" Exp}1.

BeforeIn   ::=  "before" "in" "(" Ide ["," Ide ] ")" {"if" Exp "do" Exp}1.

BeforeDrop ::=  "before" "drop" "(" Ide ")" {"if" Exp "do" Exp}1.


Back Back to the Main Page