public override int VisitParameter([NotNull] CBluntParser.ParameterContext context) { #if DEBUG Console.WriteLine("VisitParameter"); #endif return(0); }
public override int VisitParameter([NotNull] CBluntParser.ParameterContext context) { #if DEBUG Console.WriteLine("VisitParameter"); #endif if (context.children.Count() > 1) { Visit(context.functioncall()); } else { this.AddText(context.GetChild(0).GetText()); } return(0); }
/// <summary> /// Visit a parse tree produced by <see cref="CBluntParser.parameter"/>. /// <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 VisitParameter([NotNull] CBluntParser.ParameterContext context) { return(VisitChildren(context)); }
string GetParameterType(object context, CBluntParser.ParameterContext parameter) { var assignmentType = ""; if (parameter.STRING() != null) { assignmentType = "text"; } if (parameter.NUMBER() != null) { assignmentType = "number"; } if (parameter.truth() != null) { assignmentType = "bool"; } if (parameter.ID() != null) { var variableName = parameter.ID().GetText(); var assignmentVariableProperties = GetDeclaredVariable(parameter.ID().GetText()); if (assignmentVariableProperties == null) { SyntaxError(context, "Variable " + variableName + " does not exist"); return(""); } // Determine whether the variable we are trying to assign has been initialized // We can assign an initialized variable to an uninitialized, but not an uninitialized variable to an initialized variable if (!assignmentVariableProperties.Initialized) { SyntaxError(context, "Variable " + variableName + " has not been initialized yet"); return(""); } // If all checks passes, grab the assignment type assignmentType = assignmentVariableProperties.Type; } if (parameter.functioncall() != null) { // Visit the functioncall for potential recursive handling. If it returns 1 it means that an error has occured and // checking should stop if (Visit(parameter.functioncall()) == 1) { return(""); } /// TODO: Maybe move the part below this up above the Visit var methodProperties = GetMethodProperties(parameter.functioncall().ID().GetText()); if (methodProperties == null) { SyntaxError(context, "Method with name " + parameter.functioncall().ID().GetText() + " does not exist"); return(""); } assignmentType = methodProperties.Type; } return(assignmentType); }