X-Git-Url: https://ruin.nu/git/?p=proglang.git;a=blobdiff_plain;f=syntax.cf;h=d09a25c33849d524632a0b352994da59b2cf60b6;hp=8bb36219c11d1b7daeeeeaf9065a534d37f8345b;hb=4f21d932178a490040cf5e054f3ba9d006579368;hpb=9597d94cbb1b328c27883c8421b1fef3211fb698 diff --git a/syntax.cf b/syntax.cf index 8bb3621..d09a25c 100644 --- a/syntax.cf +++ b/syntax.cf @@ -17,11 +17,12 @@ SWhile. Stm ::= "while" "(" Exp ")" Stm ; SPrint. Stm ::= "print" Exp ";" ; EAss. Exp ::= Ident "=" Exp; -BExp. Exp ::= Exp1 BOp Exp1 ; +compExp. Exp ::= Exp1 Op0 Exp1 ; +define compExp e1 o e2 = BiOpExp e1 o e2 ; op1. Exp1 ::= Exp1 Op1 Exp2 ; -define op1 e1 o e2 = OpExp e1 o e2 ; +define op1 e1 o e2 = BiOpExp e1 o e2 ; op2. Exp2 ::= Exp2 Op2 Exp3 ; -define op2 e1 o e2 = OpExp e1 o e2 ; +define op2 e1 o e2 = BiOpExp e1 o e2 ; postIncr. Exp3 ::= Ident "++" ; define postIncr i = EPost i Plus ; postDecr. Exp3 ::= Ident "--" ; @@ -29,6 +30,7 @@ define postDecr i = EPost i Minus ; EVar. Exp3 ::= Ident ; EInt. Exp3 ::= Integer ; ENeg. Exp3 ::= "-" Exp3 ; +ENot. Exp3 ::= "!" Exp3 ; EBool. Exp3 ::= Bool ; EReadI. Exp3 ::= "readInt" ; EReadB. Exp3 ::= "readBool" ; @@ -43,12 +45,12 @@ terminator Stm "" ; Program. Stms ::= [Stm] ; -Lt. BOp ::= "<" ; -ELt. BOp ::= "<=" ; -Gt. BOp ::= ">" ; -EGt. BOp ::= ">=" ; -Eq. BOp ::= "==" ; -NEq. BOp ::= "!=" ; +Lt. Op0 ::= "<" ; +ELt. Op0 ::= "<=" ; +Gt. Op0 ::= ">" ; +EGt. Op0 ::= ">=" ; +Eq. Op0 ::= "==" ; +NEq. Op0 ::= "!=" ; Plus. Op1 ::= "+" ; Minus. Op1 ::= "-" ; @@ -57,10 +59,11 @@ Div. Op2 ::= "/" ; _. Op ::= Op1; _. Op ::= Op2; +_. Op ::= Op0; -TInt. Type ::= "int" ; +TInt. Type ::= "int" ; TBool. Type ::= "bool" ; -- pragmas @@ -68,7 +71,7 @@ TBool. Type ::= "bool" ; internal ExpT. Exp ::= Type Exp ; internal SNoop. Stm ::= ; internal EDefault. Exp ::= ; -internal OpExp. Exp ::= Exp Op Exp ; +internal BiOpExp. Exp ::= Exp Op Exp ; internal NoType. Type ::= ; internal EPost. Exp ::= Ident Op1 ;