private ILinkable Visit(DeclareAST declareAST) { string id = Visit(declareAST.Id); AST modelTypeAST = declareAST.ModelType; ILinkable linkable = Visit(modelTypeAST) as ILinkable; if (linkable != null) { switch (linkable) { case Model model: model.Name = id; break; case Route route: route.Name = id; break; } TypeSymbol typeSymbol = currentScope.Lookup(linkable.GetTypeName()) as TypeSymbol; ModelSymbol modelSymbol = new ModelSymbol(id, typeSymbol, linkable); if (!currentScope.Insert(modelSymbol, false)) { throw logger.Error(new SemanticException(declareAST.Id.ReferenceToken, $"Duplicated ID {id}")); } return(linkable); } else { throw logger.Error(new SemanticException(modelTypeAST.FindToken(), $"Invalid type")); } }