public override void Visit(AST_assignment assignment) { assignment.Expression.Accept(this); Variable var = variables.GetValueOrDefault(assignment.Identifier.Name); var.Set(value); }
private AST_assignment Parse_assignment(TokenKind followSet) { IncrementDepth(); AST_assignment assignment; AST_identifier identifier; AST_expression expression = null; identifier = Parse_identifier(Assignment); if (!Match(Assignment)) { Error("':=' expected.", lastReadToken); if (LookAheadToken().Kind != Semicolon) { // Assume an incorrect assignment symbol and skip over it GetNextToken(); } } expression = Parse_expression(Semicolon); assignment = new AST_assignment(identifier, expression); DecrementDepth(); return(assignment); }
public virtual void Visit(AST_assignment assignment) { IncrementDepth(); assignment.Identifier.Accept(this); assignment.Expression.Accept(this); DecrementDepth(); }
override public void Visit(AST_assignment assignment) { base.Visit(assignment); string name = assignment.Identifier.Name; if (variables.ContainsKey(name)) { if (assignment.Expression.DataType == variables.GetValueOrDefault(name).Type.Kind) { if (loopVariables.ContainsKey(name)) { Error("'" + name + "' is a loop variable, assignment not allowed.", assignment.Identifier); } } else { Error("Type mismatch in assignment.", assignment); } } else { Error("Variable '" + name + "' has not been declared.", assignment); } }
public override void Visit(AST_assignment assignment) { assignment.Accept(evaluateVisitor); }