parser add while loop
This commit is contained in:
parent
5723f6c662
commit
524c667c43
@ -151,6 +151,10 @@ testStatementIfThen = TestCase $
|
||||
testStatementIfThenElse = TestCase $
|
||||
assertEqual "expect empty ifthen" [If (Reference "a") (Block [Block []]) (Just (Block [Block []]))] $
|
||||
parseStatement [IF,LBRACE,IDENTIFIER "a",RBRACE,LBRACKET,RBRACKET,ELSE,LBRACKET,RBRACKET]
|
||||
testStatementWhile = TestCase $
|
||||
assertEqual "expect while" [While (Reference "a") (Block [Block []])] $
|
||||
parseStatement [WHILE,LBRACE,IDENTIFIER "a",RBRACE,LBRACKET,RBRACKET]
|
||||
|
||||
|
||||
|
||||
tests = TestList [
|
||||
@ -194,5 +198,6 @@ tests = TestList [
|
||||
testExpressionPreIncrement,
|
||||
testExpressionPreDecrement,
|
||||
testStatementIfThen,
|
||||
testStatementIfThenElse
|
||||
testStatementIfThenElse,
|
||||
testStatementWhile
|
||||
]
|
@ -203,7 +203,7 @@ localvariabledeclarationstatement : localvariabledeclaration SEMICOLON { $1 }
|
||||
statement : statementwithouttrailingsubstatement{ $1 } -- statement returns a list of statements
|
||||
| ifthenstatement { [$1] }
|
||||
| ifthenelsestatement { [$1] }
|
||||
-- | whilestatement { }
|
||||
| whilestatement { [$1] }
|
||||
|
||||
|
||||
expression : assignmentexpression { $1 }
|
||||
@ -222,7 +222,7 @@ ifthenstatement : IF LBRACE expression RBRACE statement { If $3 (Block $5) No
|
||||
|
||||
ifthenelsestatement : IF LBRACE expression RBRACE statementnoshortif ELSE statement { If $3 (Block $5) (Just (Block $7)) }
|
||||
|
||||
whilestatement : WHILE LBRACE expression RBRACE statement { }
|
||||
whilestatement : WHILE LBRACE expression RBRACE statement { While $3 (Block $5) }
|
||||
|
||||
assignmentexpression : conditionalexpression { $1 }
|
||||
-- | assignment { }
|
||||
|
Loading…
Reference in New Issue
Block a user