public override object VisitWithArguments(CryslGrammarParser.WithArgumentsContext context) { Dictionary <int, string> argumentValues = new Dictionary <int, string>(); CryptoSignature cryptoSignature = new CryptoSignature(); //ArgumentTypes argumentTypes = new ArgumentTypes(); List <ArgumentTypes> argumentsList = new List <ArgumentTypes>(); foreach (var varName in context.VARNAME()) { //Check for crypto signature identifiers if (varName.Symbol.TokenIndex < context.COLON().Symbol.TokenIndex) { cryptoSignature.Event_Var_Name = varName.GetText(); } //Check for crypto signature methods else if (varName.Symbol.TokenIndex > context.COLON().Symbol.TokenIndex&& (varName.Symbol.TokenIndex < context.OP().Symbol.TokenIndex&& varName.Symbol.TokenIndex < context.CP().Symbol.TokenIndex)) { cryptoSignature.Method_Name = varName.GetText(); cryptoSignature.Is_property = false; } //Check for crypto signature argument values else if (varName.Symbol.TokenIndex > context.OP().Symbol.TokenIndex&& varName.Symbol.TokenIndex < context.CP().Symbol.TokenIndex) { argumentValues.Add(varName.Symbol.TokenIndex, varName.GetText()); } } //Check for optional arguments foreach (var opArguments in context.UNSCORE()) { if (opArguments.Symbol.TokenIndex > context.OP().Symbol.TokenIndex&& opArguments.Symbol.TokenIndex < context.CP().Symbol.TokenIndex) { argumentValues.Add(opArguments.Symbol.TokenIndex, opArguments.GetText()); } } var sortedArgumentsList = from arguments in argumentValues orderby arguments.Key ascending select arguments; foreach (KeyValuePair <int, string> sortedArguments in sortedArgumentsList) { ArgumentTypes argumentTypes = new ArgumentTypes(); argumentTypes.Argument = sortedArguments.Value; argumentsList.Add(argumentTypes); } cryptoSignature.Argument_types = argumentsList; return(cryptoSignature); }
/// <summary> /// Visit a parse tree produced by the <c>WithArguments</c> /// labeled alternative in <see cref="CryslGrammarParser.event"/>. /// <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 VisitWithArguments([NotNull] CryslGrammarParser.WithArgumentsContext context) { return(VisitChildren(context)); }