]> ruin.nu Git - proglang.git/blobdiff - syntax.cf
parsing works
[proglang.git] / syntax.cf
index 0347ce56e2982362825fb40f7ec2582f778e9690..44a6cb4284db6eb0d08e95ec53423cccab7f8eb8 100644 (file)
--- a/syntax.cf
+++ b/syntax.cf
@@ -8,7 +8,7 @@ False.    Bool ::= "false" ;
 TInt.   Type  ::= "int" ;
 TBool.  Type  ::= "bool" ;
 
-Program.  Stms ::= [Stm] ;
+Program.  Program ::= [FuncStm] ;
 
 
 SExp.      Stm      ::= Exp ";" ;
@@ -25,6 +25,8 @@ define if e s = SIf e s SNoop ;
 -- SFor.     Stm      ::= "for" "(" Stm Exp ";" Exp ")" Stm ;
 SPrint.   Stm      ::= "print" Exp ";" ;
 
+SReturn. Stm ::= "return" Exp ";" ;
+
 
 
 EAss.     Exp     ::= Ident "=" Exp;
@@ -54,6 +56,9 @@ ENot.     Exp3    ::= "!" Exp3 ;
 EReadI.   Exp3    ::= "readInt" ;
 EReadB.   Exp3    ::= "readBool" ;
 
+EFunc.    Exp3    ::= Ident "(" [Exp] ")" ;
+
+
 
 coercions Exp 3 ;
 
@@ -63,6 +68,23 @@ coercions Exp 3 ;
 
 terminator Stm "" ;
 
+separator Exp "," ;
+
+Decl. Decl ::= Type Ident ;
+
+separator Decl "," ;
+
+Func. Func ::= Type Ident "(" [Decl] ")" "{" [Stm] "}" ;
+
+separator Func "" ;
+
+S. FuncStm ::= Stm ;
+F. FuncStm ::= Func ;
+
+separator FuncStm "" ;
+
+-- E1. Exps ::= Exp ;
+-- E2. Exps ::= Exp "," Exps ;
 
 Lt.  Op0 ::= "<" ;
 ELt. Op0 ::= "<=" ;
@@ -94,4 +116,4 @@ internal SNoop. Stm ::= ;
 comment "/*" "*/" ;
 comment "//" ;
 
-entrypoints Stms, Exp ;
+entrypoints Program;