Commit 54ca627b authored by Pierre Brandone's avatar Pierre Brandone
Browse files

Resolve "Mention chunks in syntactic specifications"

parent e86860ad
Pipeline #32719 passed with stage
in 1 minute and 1 second
......@@ -7,21 +7,14 @@ exp =
;
dec =
(* Class definition (alternative form). *)
"class" id [ "extends" type-id ] "{" classfields "}"
;
ty =
(* Class definition (canonical form). *)
"class" [ "extends" type-id ] "{" classfields "}"
;
(* Class definition (alternative form). *)
tydec = "class" id [ "extends" type-id ] "{" classfields "}" ;
classfields = { classfield } ;
(* Class definition (canonical form). *)
ty = "class" [ "extends" type-id ] "{" classfields "}" ;
(* Class fields. *)
classfields = { classfield } ;
classfield =
(* Attribute declaration. *)
vardec
......
program =
exp
| decs
| chunks
;
(* === Expressions. === *)
exps = [ exp { ";" exp } ] ;
exp =
(* Literals. *)
"nil"
......@@ -33,36 +35,45 @@ exp =
| "while" exp "do" exp
| "for" id ":=" exp "to" exp "do" exp
| "break"
| "let" decs "in" exps "end"
| "let" chunks "in" exps "end"
;
lvalue = id
lvalue =
id
(* Record field access. *)
| lvalue "." id
(* Array subscript. *)
| lvalue "[" exp "]"
;
exps = [ exp { ";" exp } ] ;
op = "+" | "-" | "*" | "/" | "=" | "<>" | ">" | "<" | ">=" | "<=" | "&" | "|" ;
decs = { dec } ;
dec =
(* Type declaration. *)
"type" id "=" ty
(* Variable declaration. *)
(* === Chunks of declarations. === *)
chunks = { chunk } ;
chunk =
{ tydec }
| { fundec }
| vardec
(* Function declaration. *)
| "function" id "(" tyfields ")" [ ":" type-id ] "=" exp
(* Primitive declaration. *)
| "primitive" id "(" tyfields ")" [ ":" type-id ]
(* Importing a set of declarations. *)
| "import" string
;
(* Variable declaration. *)
vardec = "var" id [ ":" type-id ] ":=" exp ;
(* Type declaration. *)
tydec = "type" id "=" ty ;
(* Types. *)
(* Function declaration. *)
fundec =
"function" id "(" tyfields ")" [ ":" type-id ] "=" exp
| "primitive" id "(" tyfields ")" [ ":" type-id ]
;
(* === Types. === *)
ty =
(* Type alias. *)
type-id
......@@ -71,8 +82,6 @@ ty =
(* Array type definition. *)
| "array" "of" type-id
;
tyfields = [ id ":" type-id { "," id ":" type-id } ] ;
type-id = id ;
op = "+" | "-" | "*" | "/" | "=" | "<>" | ">" | "<" | ">=" | "<=" | "&" | "|" ;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment