X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=Parsyntax.y;h=8bf7c6812d4ca3074be5f2e493c57b5359353263;hb=9597d94cbb1b328c27883c8421b1fef3211fb698;hp=6fef6bad9bb89672f5902fd0fdc9a14d732c349a;hpb=e9be0603d9dbd1caa6a0032cad0e39815cb8f38d;p=proglang.git diff --git a/Parsyntax.y b/Parsyntax.y index 6fef6ba..8bf7c68 100644 --- a/Parsyntax.y +++ b/Parsyntax.y @@ -67,11 +67,11 @@ Stm : Type Ident '=' Exp ';' { SDecl $1 $2 $4 } | 'if' '(' Exp ')' Stm 'else' Stm { SIf $3 $5 $7 } | 'while' '(' Exp ')' Stm { SWhile $3 $5 } | 'print' Exp ';' { SPrint $2 } - | Stm ';' { $1 } Exp :: { Exp } Exp : Exp1 BOp Exp1 { BExp $1 $2 $3 } + | Ident '=' Exp { EAss $1 $3 } | Exp1 { $1 } @@ -89,13 +89,16 @@ Exp3 :: { Exp } Exp3 : Ident '++' { postIncr_ $1 } | Ident '--' { postDecr_ $1 } | Ident { EVar $1 } - | Ident '=' Exp { EAss $1 $3 } | Integer { EInt $1 } | '-' Exp3 { ENeg $2 } | Bool { EBool $1 } | 'readInt' { EReadI } | 'readBool' { EReadB } - | '(' Exp ')' { $2 } + | Exp4 { $1 } + + +Exp4 :: { Exp } +Exp4 : '(' Exp ')' { $2 } ListStm :: { [Stm] }