]> ruin.nu Git - proglang.git/blobdiff - syntax.cf
updated syntax to use define
[proglang.git] / syntax.cf
index 7e4740eaed3a448c6a2f8c3f7bc6dea7721c95ed..a0e69538f58bb9a72899ec801b68366d11e3f808 100644 (file)
--- a/syntax.cf
+++ b/syntax.cf
@@ -1,21 +1,23 @@
 
 -- ordinary rules
 
-BTrue. BoolT ::= "true" ;
-BFalse. BoolT ::= "false" ;
+True. Bool ::= "true" ;
+False. Bool ::= "false" ;
 
-SDecl.    Stm      ::= Typ Var ";" ;
---SAss.     Stm      ::= Ident "=" Exp  ";"  ;
+SDecl.   Stm      ::= Typ Ident "=" Exp ";" ;
+decl.    Stm      ::= Typ Ident ";" ;
+define decl t v = SDecl t  v EDefault ;
 SExp.     Stm      ::= Exp ";" ;
 SBlock.   Stm      ::= "{" [Stm] "}" ;
-SIf.      Stm      ::= "if" "(" Exp ")" Stm ;
-SIfE.     Stm      ::= "if" "(" Exp ")" Stm "else" Stm ;
+if.      Stm      ::= "if" "(" Exp ")" Stm ;
+SIf.     Stm      ::= "if" "(" Exp ")" Stm "else" Stm ;
+define if e s = SIf e s SNoop ;
 SWhile.   Stm      ::= "while" "(" Exp ")" Stm ;
 -- SFor.     Stm      ::= "for" "(" Stm Exp ";" Exp ")" Stm ;
 SPrint.   Stm      ::= "print" Exp ";" ;
 
-VVar.     Var      ::= Ident ;
-VAss.     Var      ::= Ident "=" Exp;
+-- VVar.     Var      ::= Ident ;
+-- VAss.     Var      ::= Ident "=" Exp;
 
 ELt.      Exp     ::= Exp1 "<" Exp1 ;
 EELt.     Exp     ::= Exp1 "<=" Exp1 ;
@@ -29,10 +31,11 @@ ETimes.   Exp2    ::= Exp2 "*" Exp3 ;
 EDiv.     Exp2    ::= Exp2 "/" Exp3 ;
 EIncr.    Exp3    ::= Ident "++" ;
 EDecr.    Exp3    ::= Ident "--" ;
-EVar.     Exp3    ::= Var ;
+EVar.     Exp3    ::= Ident ;
+EAss.     Exp3    ::= Ident "=" Exp;
 EInt.     Exp3    ::= Integer ;
 ENeg.     Exp3    ::= "-" Exp3 ;
-EBool.    Exp3    ::= BoolT ;
+EBool.    Exp3    ::= Bool ;
 EReadI.   Exp3    ::= "readInt" ;
 EReadB.   Exp3    ::= "readBool" ;
 
@@ -53,6 +56,8 @@ TBool.  Typ  ::= "bool" ;
 -- pragmas
 
 internal ExpT. Exp ::= Typ Exp ;
+internal SNoop. Stm ::= ;
+internal EDefault. Exp ::= ;
 
 comment "/*" "*/" ;
 comment "//" ;