herry13 / sfp-lang

SFP is a declarative configuration language. This is a repository of SFP compiler based on the formal semantics.
http://homepages.inf.ed.ac.uk/s0978621/nuri
Other
0 stars 0 forks source link

Simplify type system #36

Open herry13 opened 9 years ago

herry13 commented 9 years ago

The following ideas can simplify the type-system:

herry13 commented 9 years ago

This implies to the type-system as well.

main {
  a1 = 1;
  b1 = true;
  c1 = 1.2;
  d1 { }
  a2 = a1; // int (currently: *int)
  b2 = b1; // bool (currently: *bool)
  c2 = c1; // float (currently: *float)
  d2 = d1; // *object
}
herry13 commented 9 years ago

A proposal for the new type syntax:

t        = TBool
         | TInt
         | TFloat
         | TString
         | TNull
         | TUndefined
         | TAny
         | TAction
         | TConstraint

         | TEnum of string * string list
         | TForward of reference * tForward

         | TList t
         | TSchema tSchema
         | TRef tSchema

tSchema  = TObject
         | TRootSchema
         | TUserSchema of string * tSchema

tForward = TLinkForward
         | TRefForward