HANDBOOK / LANGUAGE REFERENCE MANUAL /

# Syntax Summary

Module = ["'module'" Ident] [UseClause] [ExportClause] Declarations .
UseClause = "'use'" Ident{ "," Ident} .
ExportClause = "'export'" Ident{ "," Ident} .
Declarations = {Declaration} .
Declaration = TypeDecl | PredicateDecl | VariableDecl | TableDecl | RootDef .
TypeDecl = "'type'" Ident [["="] TermSpec{ [","] TermSpec}] .
TermSpec = IdentLC ["("[ParamSpec{ "," ParamSpec}]")"] .
ParamSpec = [Ident ":"] Ident .
VariableDecl = "'var'" Ident ":" Ident .
TableDecl = "'table'" Ident "(" Ident ":" Ident{ "," Ident ":" Ident} ")" .
PredicateDeclaration = Category Ident Signature Rules .
Category = "'nonterm'" | "'token'" | "'action'"
| "'condition'" | "'choice'" | "'sweep'" .
Signature =
["(" [ParamSpec{ "," ParamSpec}] ["->"[ParamSpec{ "," ParamSpec}]]")"] .
Rules = {Head ":" Body "."} | {"'rule'" Head [":"] Body ["."]} .
Head = Ident ["(" [Pattern{ "," Pattern}] ["->" [Expression{ "," Expression}]] ")"] .
Pattern = IdentUC [":" Pattern]
| Functor ["("[Pattern{ "," Pattern}]")"]
| "_" .
Expression = Expr2 | Expression ( "+" | "-" ) Expr2 .
Expr2 = Expr3 | Expr2 ( "*" | "/" ) Expr3 .
Expr3 = IdentUC | Number | String
| Functor ["("[Expression{ "," Expression}]")"]
| ( "+" | "-" ) Expr3 | "(" Expression ")"
Functor = [Ident "'"] IdentLC .
Body = {Member} [CostSpec]
CostSpec = "$" Number .
Member = Ident ["(" [Expression{ "," Expression}] ["->" [Pattern{ "," Pattern}]] ")"]
| ContextDesignator "<-" Expression
| ContextDesignator "->" Pattern
| IdentUC "::" Ident
| String
| "(|" {Member} "||" {Member} {"||" {Member}} "|)"
| "[|" {Member} "|]" .
ContextDesignator = [IdentUC "'"] Ident .
RootDef = "'root'" {Member} .