Use rec and sig for records.

This commit is contained in:
bringert
2005-11-29 18:16:33 +00:00
parent 2ebf7da067
commit bb5f9dc312
22 changed files with 364 additions and 358 deletions

View File

@@ -24,7 +24,7 @@ PCons. Pattern ::= "(" CIdent [Pattern] ")" ;
-- constructor patterns must have parantheses.
PVar. Pattern ::= PatternVariable ;
-- Record patterns.
PRec. Pattern ::= "{" [FieldPattern] "}";
PRec. Pattern ::= "rec" "{" [FieldPattern] "}";
-- Patterns matching the constant Type.
PType. Pattern ::= "Type" ;
-- String literal patterns.
@@ -59,11 +59,17 @@ EApp. Exp3 ::= Exp3 Exp4 ;
-- Record field projection.
EProj. Exp4 ::= Exp4 "." CIdent ;
EEmptyRec. Exp5 ::= "{" "}" ;
-- Record types.
ERecType. Exp5 ::= "{" [FieldType] "}" ;
ERecType. Exp5 ::= "sig" "{" [FieldType] "}" ;
FieldType. FieldType ::= CIdent ":" Exp ;
separator FieldType ";" ;
-- Record expressions.
ERec. Exp5 ::= "{" [FieldValue] "}" ;
ERec. Exp5 ::= "rec" "{" [FieldValue] "}" ;
FieldValue.FieldValue ::= CIdent "=" Exp ;
separator FieldValue ";" ;
-- Functions, constructors and local variables.
EVar. Exp5 ::= CIdent ;
-- The constant Type.
@@ -79,24 +85,11 @@ token TMeta ('?' digit+) ;
coercions Exp 5 ;
{-
-- Hack to make lists of function arguments not conflict with
-- application.
[]. [Exp] ::= ;
(:). [Exp] ::= Exp4 [Exp] ;
-}
Case. Case ::= Pattern "->" Exp ;
separator Case ";" ;
FieldType. FieldType ::= CIdent ":" Exp ;
separator nonempty FieldType ";" ;
FieldValue. FieldValue ::= CIdent "=" Exp ;
separator nonempty FieldValue ";" ;
-- Identifiers in core can start with underscore to allow
-- generating unique identifiers easily.
token CIdent ((letter | '_') (letter | digit | '_' | '\'')*) ;