Parse local variables
This commit is contained in:
@@ -158,9 +158,9 @@ expression globalTable (AST.ProductExpression lhs rhs)
|
||||
expression globalTable (AST.DivisionExpression lhs rhs)
|
||||
= expression globalTable lhs
|
||||
>> expression globalTable rhs
|
||||
{- expression globalTable (AST.VariableExpression variableExpression) =
|
||||
expression globalTable (AST.VariableExpression variableExpression) =
|
||||
variableAccess globalTable variableExpression
|
||||
-}
|
||||
|
||||
statement :: SymbolTable -> AST.Statement -> NameAnalysis ()
|
||||
statement _ AST.EmptyStatement = pure ()
|
||||
statement globalTable (AST.CallStatement name arguments)
|
||||
@@ -172,9 +172,9 @@ statement globalTable (AST.IfStatement ifCondition ifStatement elseStatement)
|
||||
= condition globalTable ifCondition
|
||||
>> statement globalTable ifStatement
|
||||
>> maybe (pure ()) (statement globalTable) elseStatement
|
||||
-- statement globalTable (AST.AssignmentStatement lvalue rvalue)
|
||||
-- = variableAccess globalTable lvalue
|
||||
-- >> expression globalTable rvalue
|
||||
statement globalTable (AST.AssignmentStatement lvalue rvalue)
|
||||
= variableAccess globalTable lvalue
|
||||
>> expression globalTable rvalue
|
||||
--statement globalTable (AST.WhileStatement whileCondition loop)
|
||||
-- = condition globalTable whileCondition
|
||||
-- >> statement globalTable loop
|
||||
@@ -198,13 +198,13 @@ condition globalTable (AST.LessOrEqualCondition lhs rhs)
|
||||
condition globalTable (AST.GreaterOrEqualCondition lhs rhs)
|
||||
= expression globalTable lhs
|
||||
>> expression globalTable rhs
|
||||
{-
|
||||
|
||||
variableAccess :: SymbolTable -> AST.VariableAccess -> NameAnalysis ()
|
||||
variableAccess globalTable (AST.ArrayAccess arrayExpression indexExpression)
|
||||
= variableAccess globalTable arrayExpression
|
||||
>> expression globalTable indexExpression
|
||||
variableAccess globalTable (AST.VariableAccess identifier) =
|
||||
checkSymbol globalTable identifier
|
||||
{- variableAccess globalTable (AST.ArrayAccess arrayExpression indexExpression)
|
||||
= variableAccess globalTable arrayExpression
|
||||
>> expression globalTable indexExpression
|
||||
|
||||
enter :: Identifier -> Info -> SymbolTable -> NameAnalysis SymbolTable
|
||||
enter identifier info table
|
||||
@@ -216,9 +216,4 @@ identifierAlreadyDefinedError = NameAnalysis
|
||||
. lift
|
||||
. throwE
|
||||
. IdentifierAlreadyDefinedError
|
||||
|
||||
variableDeclaration :: AST.VariableDeclaration -> NameAnalysis (Identifier, Info)
|
||||
variableDeclaration (AST.VariableDeclaration identifier typeExpression)
|
||||
= (identifier,) . VariableInfo False
|
||||
<$> dataType typeExpression
|
||||
-}
|
||||
|
||||
Reference in New Issue
Block a user