Add initial typechecker for AST #2

Merged
mrab merged 121 commits from typedAST into master 2024-06-14 07:53:30 +00:00
2 changed files with 8 additions and 3 deletions
Showing only changes of commit 524c667c43 - Show all commits

View File

@ -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
]

View File

@ -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 { }