// возвращает MethodDeclarationParameter public override object VisitFormalParameter([NotNull] DoshikParser.FormalParameterContext context) { _compilationContext.SetParsingAntlrContext(context); var parameter = new MethodDeclarationParameter(_currentMethodDeclaration.Parameters); var scope = parameter.Parent.Scope; parameter.IsOutput = context.OUT() != null; var foundType = GetTypeNameVisitor.Apply(_compilationContext, context.typeType()); foundType.ThrowIfNotFound(_compilationContext); var variable = new Variable(parameter) { Type = foundType.DataType, Name = context.parameterName.Text }; if (scope.FindVariableByName(variable.Name, true) != null) { throw _compilationContext.ThrowCompilationError($"parameter { variable.Name } is already defined"); } scope.Variables[variable.Name] = variable; parameter.Variable = variable; return(parameter); }
/// <summary> /// Visit a parse tree produced by <see cref="DoshikParser.formalParameter"/>. /// <para> /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/> /// on <paramref name="context"/>. /// </para> /// </summary> /// <param name="context">The parse tree.</param> /// <return>The visitor result.</return> public virtual Result VisitFormalParameter([NotNull] DoshikParser.FormalParameterContext context) { return(VisitChildren(context)); }
/// <summary> /// Exit a parse tree produced by <see cref="DoshikParser.formalParameter"/>. /// <para>The default implementation does nothing.</para> /// </summary> /// <param name="context">The parse tree.</param> public virtual void ExitFormalParameter([NotNull] DoshikParser.FormalParameterContext context) { }