X-Git-Url: https://ruin.nu/git/?p=proglang.git;a=blobdiff_plain;f=syntax.cf;h=44a6cb4284db6eb0d08e95ec53423cccab7f8eb8;hp=0347ce56e2982362825fb40f7ec2582f778e9690;hb=d606bc7eda59e30fbb75555b4d4c5da91b7327b9;hpb=99548e772decde168669179c0da03109a9df5356 diff --git a/syntax.cf b/syntax.cf index 0347ce5..44a6cb4 100644 --- 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;