public AstPrinterNode Visit(SimpleVarDecl node) { var printer = new AstPrinterNode(node.ToString()); foreach (var ident in node.IdentList) { printer.AddChild(ident.Accept(this)); } printer.AddChild(node.IdentsType.Accept(this)); return(printer); }
public bool Visit(SimpleVarDecl node) { //TODO: get types from functions we got after separate code in type declaration SymType identsType; switch (node.IdentsType) { case ArrayTypeNode arrayTypeNode: arrayTypeNode.Accept(this); identsType = arrayTypeNode.SymType; break; case RecordTypeNode recordTypeNode: recordTypeNode.Accept(this); identsType = recordTypeNode.SymType; break; case PointerTypeNode pointerTypeNode: identsType = _symStack.CheckTypeDeclared(node.IdentsType.ToString()); break; default: identsType = _symStack.CheckTypeDeclared(node.IdentsType.Token.Value); break; } if (identsType == null) { throw new Exception(string.Format("({0}, {1}) semantic error: type '{2}' is not found", node.IdentsType.Token.Line, node.IdentsType.Token.Column, node.IdentsType.ToString())); } foreach (var ident in node.IdentList) { CheckIdentifierDuplicate(ident.Token); _symStack.AddVariable(node.IsLocal, ident.ToString(), identsType); ident.SymType = identsType; } return(true); }