]> ruin.nu Git - proglang.git/blobdiff - syntax.cf
removed NoType and EDefault and added assert
[proglang.git] / syntax.cf
index 7b84054391014ef81d22f0f03d8e8866af3049ce..26408246305de004f448085d22bb717adca8736b 100644 (file)
--- a/syntax.cf
+++ b/syntax.cf
@@ -1,14 +1,27 @@
 
 -- ordinary rules
 
+
+True.    Bool ::= "true" ;
+False.   Bool ::= "false" ;
+
+TInt.   Type  ::= "int" ;
+TBool.  Type  ::= "bool" ;
+
 Program.  Stms ::= [Stm] ;
 
 
-SExp.     Stm      ::= Exp ";" ;
-SBlock.   Stm      ::= "{" [Stm] "}" ;
-SDecl.   Stm      ::= Type Ident "=" Exp ";" ;
-decl.    Stm      ::= Type Ident ";" ;
-define decl t v = SDecl t  v EDefault ;
+SExp.      Stm      ::= Exp ";" ;
+SBlock.    Stm      ::= "{" [Stm] "}" ;
+declIntE.  Stm      ::= "int" Ident "=" Exp ";" ;
+declBoolE. Stm      ::= "bool" Ident "=" Exp ";" ;
+define declIntE x e = SDecl TInt x e;
+define declBoolE x e = SDecl TBool x e;
+declInt. Stm ::= "int" Ident ";" ;
+declBool. Stm ::= "bool" Ident ";" ;
+define declInt x  = SDecl TInt x (EInt 0);
+define declBool x = SDecl TBool x (EBool False);
+
 
 SWhile.   Stm      ::= "while" "(" Exp ")" Stm ;
 SIf.     Stm      ::= "if" "(" Exp ")" Stm "else" Stm ;
@@ -74,21 +87,17 @@ _. Op ::= Op2;
 _. Op ::= Op0;
 
 
-True.    Bool ::= "true" ;
-False.   Bool ::= "false" ;
-
-TInt.   Type  ::= "int" ;
-TBool.  Type  ::= "bool" ;
-
 -- pragmas
 
-internal ExpT. Exp ::= Type Exp ;
-internal SNoop. Stm ::= ;
-internal EDefault. Exp ::= ;
+-- internal ExpT. Exp ::= Type Exp ;
+-- internal EDefault. Exp ::= ;
 internal BiOpExp. Exp ::= Exp Op Exp ;
-internal NoType. Type ::= ;
+-- internal NoType. Type ::= ;
 internal EPost. Exp ::= Ident Op1 ;
 
+internal SNoop. Stm ::= ;
+internal SDecl. Stm ::= Type Ident "=" Exp ";" ;
+
 comment "/*" "*/" ;
 comment "//" ;