public ImportStatement(Token importToken, IList<Token> importChain, IList<Token> fromChain, Token asValue)
     : base(importToken)
 {
     this.ImportChain = importChain.ToArray();
     this.FromChain = fromChain == null ? null : fromChain.ToArray();
     this.AsValue = asValue;
 }
 public void TokenToStringTest()
 {
     var t1 = new Token { TokenStart = 10, TokenEnd = 20, Content = "1234" };
     var expected = "10-20: 1234";
     var actual = t1.ToString();
     Assert.AreEqual(expected, actual);
 }
Exemplo n.º 3
0
        public void WithToken_AToken_ReturnsExpectedToken()
        {
            var expected = new Token
            {
                Id = "4f2b900cfa08ac1f1b4ae00d",
                IdMember = Constants.MeId,
                DateCreated = new DateTime(2012, 02, 03, 08, 43, 08, 478),
                Permissions = new List<Token.TokenPermissions>
                {
                    new Token.TokenPermissions
                    {
                        IdModel = "*",
                        ModelType = "Board",
                        Read = true,
                        Write = false
                    },
                    new Token.TokenPermissions
                    {
                        IdModel = "*",
                        ModelType = "Organization",
                        Read = true,
                        Write = false
                    }
                }
            }.ToExpectedObject();

            var actual = _trelloReadOnly.Tokens.WithToken("34d12362615097b30d6140a8c596d8e8fd70d198fb6b3df7f6ab5605e4ec6f54");

            expected.ShouldEqual(actual);
        }
Exemplo n.º 4
0
 public void ReadString()
 {
     int len = rtb1.Text.Length;
     char c;
     Token temp = new Token();
     temp.type = 3;
     temp.Value = "";
     for (int i = 1; TokenPos + i < len; i++)
     {
         c = rtb1.Text[TokenPos + i];
         if (isLetter(c))
         {
             temp.Value += c;
             continue;
         }
         if (c == '"')
         {
             TokenPos += i + 1;
             tokenlist.Add(temp);
             return;
         }
     }
     TokenPos += temp.Value.Length;
     tokenlist.Add(temp);
     return;
 }
Exemplo n.º 5
0
        public override Token Build(Token lastToken, ScriptEngine engine, Script script, ref SourceCode sourceCode)
        {
            while ((++sourceCode).SpecialChar)
            {
            }
            if (sourceCode.Peek() != '{')
            {
                sourceCode.Throw(String.Format("Error parsing a 'do' statement, expected a '{' but got '{0}' instead.",
                                               sourceCode.Peek()));
            }
            List<List<List<Token>>> code = engine.BuildLongTokens(ref sourceCode, ref script, new[] {'}'});

            if (!sourceCode.SeekToNext("while"))
            {
                sourceCode.Throw("Error parsing a 'do' statement, was expecting a 'while' after the { } block.");
            }

            if (!sourceCode.SeekToNext('('))
            {
                sourceCode.Throw("Error parsing a 'do' statement, was expecting a '(' after 'while'.");
            }

            List<List<Token>> exitCondition = engine.BuildTokensAdvanced(ref sourceCode, ref script, new[] {')'});

            return new DoWhileToken(code, exitCondition);
        }
Exemplo n.º 6
0
 public ModuleDefinitionLoader(IServiceProvider services, string filename, byte[]  bytes) : base(services, filename, bytes)
 {
     this.filename = filename;
     var rdr = new StreamReader(new MemoryStream(bytes));
     this.lexer = new Lexer(rdr);
     this.bufferedTok = null;
 }
        public Token match(string name, Token lastToken)
        {
            Token token = null;
            if(name[0] == '<') {
                token = new Token();

                if(name[1] == '=') {
                    token.type = TokenType.SmallerOrEqualThan;
                } else {
                    token.type = TokenType.SmallerThan;
                }

            } else if(name[0] == '>') {
                token = new Token();
                if(name[1] == '=') {
                    token.type = TokenType.LargerOrEqualThan;
                } else {
                    token.type = TokenType.Largerthan;
                }

            } else if(name[0] == '=') {
                if(name[1] == '=') {
                    token = new Token();
                    token.type = TokenType.Equals;
                }
            }
            if(token != null) {
                token.value = name.Substring(0, 2);
            }

            return token;
        }
Exemplo n.º 8
0
 public HttpParameter(Token name,
                      string value)
     : this()
 {
     Name = name;
     Value = value;
 }
Exemplo n.º 9
0
		public IExpression Parse(Parser parser, Token<TokenType> token)
		{
			var name = parser.TakeExpression<CallExpression>(Predecence.Prefix);
			if (!name.GetArguments().All(a => a is NameExpression)) // TODO: should this constraint be handled by the parser?
				throw new ParseException(token.GetLocation(), "All arguments in function's name must be NameExpressions");

			List<IExpression> inner = new List<IExpression>();
			while (true)
			{
				var innerToken = parser.PeekToken();

				if (innerToken.Identifier == TokenType.End)
				{
					parser.TakeToken(); // consume the token we peeked
					break;
				}

				if (innerToken.Identifier == TokenType.EOF)
					throw new ParseException(innerToken.GetLocation(), "EOF token reached before End was found");

				inner.Add(parser.TakeExpression(Predecence.Prefix));
			}

			return new FunctionExpression(name, inner, token);
		}
 void Expect(Token tok)
 {
     if(Next() == tok)
         Consume();
     else
         Error();
 }
Exemplo n.º 11
0
 public static StatementNode Parse(Token[] tokens, ref int i)
 {
     if (IfNode.IsIf(tokens, i))
     {
         return IfNode.Parse(tokens, ref i);
     }
     else if (WhileNode.IsWhile(tokens, i))
     {
         return WhileNode.Parse(tokens, ref i);
     }
     else if (ForNode.IsFor(tokens, i))
     {
         return ForNode.Parse(tokens, ref i);
     }
     else if (BreakNode.IsBreak(tokens, i))
     {
         return BreakNode.Parse(tokens, ref i);
     }
     else if (ContinueNode.IsContinue(tokens, i))
     {
         return ContinueNode.Parse(tokens, ref i);
     }
     else if (VariableDeclarationNode.IsVariableDeclaration(tokens, i))
     {
         VariableDeclarationNode node = VariableDeclarationNode.Parse(tokens, ref i);
         Parser.Expect(tokens, ref i, TokenType.Semicolon);
         return node;
     }
     else //Assume expression if no previous match
     {
         ExpressionStatementNode node = ExpressionStatementNode.Parse(tokens, ref i);
         Parser.Expect(tokens, ref i, TokenType.Semicolon);
         return node;
     }
 }
Exemplo n.º 12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GenericParamRow" /> struct.
 /// </summary>
 /// <param name="number">The number.</param>
 /// <param name="flags">The flags.</param>
 /// <param name="owner">The owner.</param>
 /// <param name="nameString">The name string.</param>
 public GenericParamRow(ushort number, GenericParameterAttributes flags, Token owner, HeapIndexToken nameString)
 {
     Number = number;
     Flags = flags;
     Owner = owner;
     NameString = nameString;
 }
Exemplo n.º 13
0
		public ForLoopStatement(ScriptLoadingContext lcontext, Token nameToken, Token forToken)
			: base(lcontext)
		{
			//	for Name ‘=’ exp ‘,’ exp [‘,’ exp] do block end | 

			// lexer already at the '=' ! [due to dispatching vs for-each]
			CheckTokenType(lcontext, TokenType.Op_Assignment);

			m_Start = Expression.Expr(lcontext);
			CheckTokenType(lcontext, TokenType.Comma);
			m_End = Expression.Expr(lcontext);

			if (lcontext.Lexer.Current.Type == TokenType.Comma)
			{
				lcontext.Lexer.Next();
				m_Step = Expression.Expr(lcontext);
			}
			else
			{
				m_Step = new LiteralExpression(lcontext, DynValue.NewNumber(1));
			}

			lcontext.Scope.PushBlock();
			m_VarName = lcontext.Scope.DefineLocal(nameToken.Text);
			m_RefFor = forToken.GetSourceRef(CheckTokenType(lcontext, TokenType.Do));
			m_InnerBlock = new CompositeStatement(lcontext);
			m_RefEnd = CheckTokenType(lcontext, TokenType.End).GetSourceRef();
			m_StackFrame = lcontext.Scope.PopBlock();

			lcontext.Source.Refs.Add(m_RefFor);
			lcontext.Source.Refs.Add(m_RefEnd);
		}		
Exemplo n.º 14
0
 public override void AppendAnythingElse(TreeConstruction tree, Token token)
 {
     OnMessageRaised(new UnexpectedTokenAfterHtmlError(token.Name));
     tree.ChangeInsertionMode<InBodyInsertionMode>();
     tree.ReprocessFlag = true;
     return;
 }
Exemplo n.º 15
0
        public dynamic Parse(string code, ParserOptions options)
        {
            dynamic program = null;

            _lineNumber = (code.Length > 0) ? 1 : 0;
            _lineStart = 0;
            _length = code.Length;
            _buffer = null;
            _state = new State
            {
                AllowIn = true,
                LabelSet = new Dictionary<string, object>(),
                LastParenthesized = null,
                InFunctionBody = false,
                InIteration = false,
                InSwitch = false
            };

            if (_length > 0)
            {
                _source = StringToArray(code).ToList();
            }

            return ParseProgram();
        }
Exemplo n.º 16
0
		public Instantiate(Token firstToken, Token firstClassNameToken, string name, IList<Expression> args, Executable owner)
			: base(firstToken, owner)
		{
			this.NameToken = firstClassNameToken;
			this.Name = name;
			this.Args = args.ToArray();
		}
Exemplo n.º 17
0
		public override Token NextToken()
		{
			if (curToken == null) { // first call of NextToken()
				curToken = Next();
				specialTracker.InformToken(curToken.kind);
				//Console.WriteLine("Tok:" + Tokens.GetTokenString(curToken.kind) + " --- " + curToken.val);
				return curToken;
			}
			
			lastToken = curToken;
			
			if (curToken.next == null) {
				curToken.next = Next();
				specialTracker.InformToken(curToken.next.kind);
			}
			
			curToken = curToken.next;
			
			if (curToken.kind == Tokens.EOF && !(lastToken.kind == Tokens.EOL)) { // be sure that before EOF there is an EOL token
				curToken = new Token(Tokens.EOL, curToken.col, curToken.line, "\n");
				specialTracker.InformToken(curToken.kind);
				curToken.next = new Token(Tokens.EOF, curToken.col, curToken.line, "\n");
				specialTracker.InformToken(curToken.next.kind);
			}
			//Console.WriteLine("Tok:" + Tokens.GetTokenString(curToken.kind) + " --- " + curToken.val);
			return curToken;
		}
Exemplo n.º 18
0
 public RangeTerm(RiakFluentSearch search, string field, Token from, Token to, bool inclusive)
     : base(search, field)
 {
     _from = from;
     _to = to;
     _inclusive = inclusive;
 }
Exemplo n.º 19
0
		public Lexer(TextReader rdr)
		{
			this.sb = new StringBuilder();
			this.lineNumber = 1;
			this.rdr = rdr;
			this.tok = Token.EOFile;
		}
Exemplo n.º 20
0
        private IEnumerable<Parselet> FuncArgs(Token<R> fromToken, RantFunctionGroup group)
        { 
            Token<R> funcToken = null;
            var actions = new List<RantAction>();
            var sequences = new List<RantAction>();

            while (!reader.End)
            {
                funcToken = reader.ReadToken();

                if (funcToken.ID == R.Semicolon)
                {
                    // add action to args and continue
                    sequences.Add(actions.Count == 1 ? actions[0] : new RASequence(actions, funcToken));
                    actions.Clear();
                    reader.SkipSpace();
                    continue;
                }
                else if (funcToken.ID == R.RightSquare)
                {
                    // add action to args and return
                    sequences.Add(actions.Count == 1 ? actions[0] : new RASequence(actions, funcToken));
                    AddToOutput(new RAFunction(Stringe.Range(fromToken, funcToken),
                        compiler.GetFunctionInfo(group, sequences.Count, fromToken, funcToken), sequences));
                    yield break;
                }

                yield return GetParselet(funcToken, actions.Add);
            }

            compiler.SyntaxError(fromToken, "Unterminated function: unexpected end of file");
        }
Exemplo n.º 21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GenericParamRow"/> struct.
 /// </summary>
 /// <param name="number">The number.</param>
 /// <param name="flags">The flags.</param>
 /// <param name="owner">The owner table idx.</param>
 /// <param name="nameStringIdx">The name string idx.</param>
 public GenericParamRow(ushort number, GenericParameterAttributes flags, Token owner, HeapIndexToken nameStringIdx)
 {
     this.number = number;
     this.flags = flags;
     this.owner = owner;
     this.nameStringIdx = nameStringIdx;
 }
Exemplo n.º 22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AssemblyRefOSRow"/> struct.
 /// </summary>
 /// <param name="platformId">The platform id.</param>
 /// <param name="majorVersion">The major version.</param>
 /// <param name="minorVersion">The minor version.</param>
 /// <param name="assemblyRef">The assembly ref.</param>
 public AssemblyRefOSRow(uint platformId, uint majorVersion, uint minorVersion, Token assemblyRef)
 {
     this.platformId = platformId;
     this.majorVersion = majorVersion;
     this.minorVersion = minorVersion;
     this.assemblyRef = assemblyRef;
 }
Exemplo n.º 23
0
 public ScriptForEachStatement(AstNodeArgs args)
     : base(args)
 {
     name = (Token)ChildNodes[1];
       expr = (ScriptExpr)ChildNodes[3];
       statement = (ScriptStatement)ChildNodes[4];
 }
Exemplo n.º 24
0
        public static AuthRequest Create(Token token, Trust trust)
        {
            Scope scope = null;

            if (trust != null)
            {
                scope = new Scope()
                {
                    Trust = trust,
                };
            }

            return new AuthRequest()
            {
                Auth = new Auth()
                {
                    Identity = new Identity()
                    {
                        Methods = new[] { "token" },
                        Token = token
                    },
                    Scope = scope
                }
            };
        }
 internal static void ValidateToken(Token token)
 {
     if (ReferenceEquals(token, null))
         throw new ArgumentNullException(nameof(token));
     if (String.IsNullOrEmpty(token.Value))
         throw new ArgumentException(nameof(token.Value));
 }
Exemplo n.º 26
0
        public LiteralExpression(ScriptLoadingContext lcontext, Token t)
            : base(lcontext)
        {
            switch (t.Type)
            {
                case TokenType.Number:
                case TokenType.Number_Hex:
                case TokenType.Number_HexFloat:
                    Value = DynValue.NewNumber(t.GetNumberValue()).AsReadOnly();
                    break;
                case TokenType.String:
                case TokenType.String_Long:
                    Value = DynValue.NewString(t.Text).AsReadOnly();
                    break;
                case TokenType.True:
                    Value = DynValue.True;
                    break;
                case TokenType.False:
                    Value = DynValue.False;
                    break;
                case TokenType.Nil:
                    Value = DynValue.Nil;
                    break;
                default:
                    throw new InternalErrorException("type mismatch");
            }

            if (Value == null)
                throw new SyntaxErrorException(t, "unknown literal format near '{0}'", t.Text);

            lcontext.Lexer.Next();
        }
Exemplo n.º 27
0
 // Text Parsing
 protected void GenericRCDATAElementParsingAlgorithm(TreeConstruction tree, Token token)
 {
     tree.InsertElementForToken((TagToken)token);
     tree.Parser.ChangeTokenState<RCDATAState>();
     tree.OriginalInsertionMode = tree.CurrentInsertionMode;
     tree.ChangeInsertionMode<TextInsertionMode>();
 }
Exemplo n.º 28
0
 public ControlInvokation(Token Source, Control Control, List<Node> Arguments, Node Body)
     : base(Source)
 {
     this.Control = Control;
     this.Arguments = Arguments;
     this.Body = Body;
 }
        public virtual async Task<string> CreateTokenAsync(Token token)
        {
            var header = await CreateHeaderAsync(token);
            var payload = await CreatePayloadAsync(token);

            return await SignAsync(new JwtSecurityToken(header, payload));
        }
Exemplo n.º 30
0
		public BracketIndex(Expression root, Token bracketToken, Expression index, Executable owner)
			: base(root.FirstToken, owner)
		{
			this.Root = root;
			this.BracketToken = bracketToken;
			this.Index = index;
		}
Exemplo n.º 31
0
 public void TokenBetweenFailsIfLeftParserFails()
 {
     AssertParser.Fails(Token.EqualTo('a').Between(Token.EqualTo('('), Token.EqualTo(')')), "{a)");
 }
Exemplo n.º 32
0
 public BitwiseXorExpressionNode(ExpressionNode left, Token operador, ExpressionNode right) : base(left, operador, right)
 {
 }
Exemplo n.º 33
0
        static public AnalysisRule BuildStatments(Rule_Context context, Token token)
        {
            AnalysisRule result = null;

            if (token is NonterminalToken)
            {
                NonterminalToken nonterminal = (NonterminalToken)token;
                switch (nonterminal.Symbol.ToString())
                {
                case "<Statements>":
                    result = new Rule_Statements(context, nonterminal);
                    break;

                case "<Statement>":
                    result = new Rule_Statement(context, nonterminal);
                    break;

                case "<Always_Statement>":
                    result = new Rule_Always(context, nonterminal);
                    break;

                case "<Simple_Assign_Statement>":
                case "<Let_Statement>":
                case "<Assign_Statement>":
                    result = new Rule_Assign(context, nonterminal);
                    break;

                case "<Assign_DLL_Statement>":
                    result = new Rule_Assign_DLL_Statement(context, nonterminal);
                    break;

                case "<If_Statement>":
                case "<If_Else_Statement>":
                    result = new Rule_If_Then_Else_End(context, nonterminal);
                    break;

                case "<Define_Variable_Statement>":
                    result = new Rule_Define(context, nonterminal);
                    break;

                case "<FuncName2>":
                case "<FunctionCall>":
                    result = new Rule_FunctionCall(context, nonterminal);
                    break;

                case "<Simple_Dialog_Statement>":
                case "<Numeric_Dialog_Implicit_Statement>":
                case "<Numeric_Dialog_Explicit_Statement>":
                case "<TextBox_Dialog_Statement>":
                case "<Db_Values_Dialog_Statement>":
                case "<YN_Dialog_Statement>":
                case "<Db_Views_Dialog_Statement>":
                case "<Databases_Dialog_Statement>":
                case "<Db_Variables_Dialog_Statement>":
                case "<Multiple_Choice_Dialog_Statement>":
                case "<Dialog_Read_Statement>":
                case "<Dialog_Write_Statement>":
                case "<Dialog_Read_Filter_Statement>":
                case "<Dialog_Write_Filter_Statement>":
                case "<Dialog_Date_Statement>":
                case "<Dialog_Date_Mask_Statement>":
                    result = new Rule_Dialog(context, nonterminal);
                    break;

                case "<Read_Epi_Statement>":
                case "<Simple_Read_Statement>":
                case "<Read_Epi_File_Spec_Statement>":
                case "<Read_Sql_Statement>":
                case "<Read_Excel_File_Statement>":
                case "<Read_Db_Table_Statement>":
                    result = new Rule_Read(context, nonterminal);
                    break;

                case "<Merge_Table_Statement>":
                case "<Merge_Db_Table_Statement>":
                case "<Merge_File_Statement>":
                case "<Merge_Excel_File_Statement>":
                    result = new Rule_Merge(context, nonterminal);
                    break;

                case "<Write_All_Statement>":
                case "<Write_Some_Statement>":
                case "<Write_Except_Statement>":
                    result = new Rule_Write(context, nonterminal);
                    break;

                case "<Select_Statement>":
                case "<Cancel_Select_By_Selecting_Statement>":
                case "<Cancel_Select_Statement>":
                    result = new Rule_Select(context, nonterminal);
                    break;

                case "<Recode_Statement>":
                    result = new Rule_Recode(context, nonterminal);
                    break;

                case "<Comment_Line>":
                    result = new Rule_CommentLine(context, nonterminal);
                    break;

                case "<Execute_Statement>":
                    result = new Rule_Execute(context, nonterminal);
                    break;

                case "<Report_Display_Statement>":
                case "<Report_File_Statement>":
                case "<Report_Print_Statement>":
                    result = new Rule_Report(context, nonterminal);
                    break;

                case "<List_Statement>":
                    result = new Rule_List(context, nonterminal);
                    break;

                case "<Simple_Tables_Statement>":
                case "<Tables_One_Variable_Statement>":
                case "<Row_All_Tables_Statement>":
                case "<Row_Except_Tables_Statement>":
                case "<Column_All_Tables_Statement>":
                case "<Column_Except_Tables_Statement>":
                case "<Row_Column_Tables_Statement>":
                    result = new Rule_Tables(context, nonterminal);
                    break;

                case "<Freq_All_Statement>":
                case "<Freq_Columns_Statement>":
                case "<Freq_All_Except_Statement>":
                    result = new Rule_Freq(context, nonterminal);
                    break;

                case "<Cancel_Sort_By_Sorting_Statement>":
                case "<Cancel_Sort_Statement>":
                case "<Sort_Statement>":
                    result = new Rule_Sort(context, nonterminal);
                    break;

                case "<Means_Statement>":
                    result = new Rule_Means(context, nonterminal);
                    break;

                case "<Relate_Epi_Table_Statement>":
                case "<Relate_Table_Statement>":
                case "<Relate_Db_Table_With_Identifier_Statement>":
                case "<Relate_Db_Table_Statement>":
                case "<Relate_File_Statement>":
                case "<Relate_Excel_File_Statement>":
                    result = new Rule_Relate(context, nonterminal);
                    break;

                case "<Beep_Statement>":
                    result = new Rule_Beep(context, nonterminal);
                    break;

                case "<Quit_Statement>":
                    result = new Rule_Quit(context, nonterminal);
                    break;

                case "<Delete_Table_Long_Statement>":
                    result = new Rule_Delete_Table_Long(context, nonterminal);
                    break;

                case "<Delete_File_Statement>":
                    result = new Rule_Delete_File(context, nonterminal);
                    break;

                case "<Delete_Table_Statement>":
                    result = new Rule_Delete_Table(context, nonterminal);
                    break;

                case "<Type_Out_String_Statement>":
                case "<Type_Out_File_Statement>":
                case "<Type_Out_String_With_Font_Statement>":
                case "<Type_Out_File_With_Font_Statement>":
                    result = new Rule_Typeout(context, nonterminal);
                    break;

                case "<Simple_Routeout_Statement>":
                case "<Replace_Routeout_Statement>":
                case "<Append_Routeout_Statement>":
                    result = new Rule_RouteOut(context, nonterminal);
                    break;

                case "<Close_Out_Statement>":
                    result = new Rule_CloseOut(context, nonterminal);
                    break;

                case "<Variables_Display_Statement>":
                case "<Views_Display_Statement>":
                case "<Tables_Display_Statement>":
                    result = new Rule_Display(context, nonterminal);
                    break;

                case "<Header_Title_String_Statement>":
                case "<Header_Title_Font_Statement>":
                case "<Header_Title_String_And_Font_Statement>":
                    result = new Rule_Header(context, nonterminal);
                    break;

                case "<Simple_Undefine_Statement>":
                    result = new Rule_Undefine(context, nonterminal);
                    break;

                case "<Run_File_PGM_Statement>":
                    result = new Rule_Run_File_PGM_Statement(context, nonterminal);
                    break;

                case "<Run_String_Statement>":
                    result = new Rule_Run_String_Statement(context, nonterminal);
                    break;

                case "<Run_PGM_In_Db_Statement>":
                    result = new Rule_Run_PGM_In_Db_Statement(context, nonterminal);
                    break;

                case "<Delete_Records_All_Statement>":
                    result = new Rule_Delete_Records_All_Statement(context, nonterminal);
                    break;

                case "<Delete_Records_Selected_Statement>":
                    result = new Rule_Delete_Records_Selected_Statement(context, nonterminal);
                    break;

                case "<Simple_Print_Out_Statement>":
                case "<File_Print_Out_Statement>":
                    result = new Rule_Printout(context, nonterminal);
                    break;

                case "<SQL_Execute_Command>":
                    result = new Rule_SQLExec(context, nonterminal);
                    break;

                case "<RecordSet_Command>":
                    result = new Rule_RecordSet(context, nonterminal);
                    break;

                case "<Define_Connection_Command>":
                    result = new Rule_Define_Connection(context, nonterminal);
                    break;

                case "<Regress_Statement>":
                    result = new Rule_LinearRegression(context, nonterminal);
                    break;

                case "<Logistic_Statement>":
                    result = new Rule_LogisticRegression(context, nonterminal);
                    break;

                case "<CoxPH_Statement>":
                    result = new Rule_CoxPH(context, nonterminal);
                    break;

                case "<KM_Survival_Statement>":
                    result = new Rule_KMSurvival(context, nonterminal);
                    break;

                case "<Define_Dll_Statement>":
                    result = new Rule_DLL_Statement(context, nonterminal);
                    break;

                case "<Define_Group_Statement>":
                    result = new Rule_Define_Group(context, nonterminal);
                    break;

                case "<Summarize_Statement>":
                    result = new Rule_Summarize(context, nonterminal);
                    break;

                case "<Set_Statement>":
                    result = new Rule_Set(context, nonterminal);
                    break;

                case "<Match_Row_All_Statement>":
                case "<Match_Row_Except_Statement>":
                case "<Match_Column_All_Statement>":
                case "<Match_Column_Except_Statement>":
                case "<Match_Row_Column_Statement>":
                    result = new Rule_Match(context, nonterminal);
                    break;

                case "<Graph_Statement>":
                case "<Simple_Graph_Statement>":
                case "<Strata_Var_Graph_Statement>":
                case "<Weight_Var_Graph_Statement>":
                case "<Stra_Wei_Var_Graph_Statement>":
                case "<Graph_Opt_1_Statement>":
                case "<Graph_Opt_2_Statement>":
                case "<Graph_Opt_3_Statement>":
                case "<Graph_Opt_4_Statement>":
                case "<Graph_Opt_5_Statement>":
                case "<Graph_Generic_Opt_Statement>":
                    result = new Rule_Graph(context, nonterminal);
                    break;

                case "<Expr List>":
                    result = new Rule_ExprList(context, nonterminal);
                    break;

                case "<Expression>":
                    result = new Rule_Expression(context, nonterminal);
                    break;

                case "<And Exp>":
                    result = new Rule_AndExp(context, nonterminal);
                    break;

                case "<Not Exp>":
                    result = new Rule_NotExp(context, nonterminal);
                    break;

                case "<Compare Exp>":
                    result = new Rule_CompareExp(context, nonterminal);
                    break;

                case "<Concat Exp>":
                    result = new Rule_ConcatExp(context, nonterminal);
                    break;

                case "<Add Exp>":
                    result = new Rule_AddExp(context, nonterminal);
                    break;

                case "<Mult Exp>":
                    result = new Rule_MultExp(context, nonterminal);
                    break;

                case "<Pow Exp>":
                    result = new Rule_PowExp(context, nonterminal);
                    break;

                case "<Negate Exp>":
                    result = new Rule_NegateExp(context, nonterminal);
                    break;

                default:
                case "<Value>":
                    result = new Rule_Value(context, nonterminal);
                    break;

                case "<Undelete_All_Statement>":
                    result = new Rule_UnDelete(context, nonterminal);
                    break;

                case "<QualifiedIdList>":
                    result = new Rule_QualifiedIdList(context, nonterminal);
                    break;

                case "<Subroutine_Statement>":
                    result = new Rule_Subroutine_Statement(context, nonterminal);
                    break;

                case "<Call_Statement>":
                    result = new Rule_Call(context, nonterminal);
                    break;
                //**these are not yet implemented; move up when completed
                //**these are not yet implemented; move up when completed
                //**these are not yet implemented; move up when completed
                //**these are not yet implemented; move up when completed
                //**these are not yet implemented; move up when completed

                case "<Simple_Run_Statement>":
                case "<About_Statement>":
                case "<Browser_Statement>":
                case "<Browser_Size_Statement>":
                case "<Button_Offset_Size_1_Statement>":
                case "<Button_Offset_Size_2_Statement>":
                case "<Button_Offset_1_Statement>":
                case "<Button_Offset_2_Statement>":
                case "<Simple_CMD_Statement>":
                case "<CMD_Line_Statement>":
                case "<Delete_Table_Short_Statement>":
                case "<Exit_Statement>":
                case "<File_Dialog_Statement>":
                case "<Get_Path_Statement>":
                case "<Help_File_Statement>":
                case "<Simple_Help_Statement>":
                case "<Link_Statement>":
                case "<Link_Remove_Statement>":
                case "<Map_AVG_Statement>":
                case "<Map_Case_Statement>":
                case "<Map_Sum_Statement>":
                case "<Map_Count_Statement>":
                case "<Map_Min_Statement>":
                case "<Map_Max_Statement>":
                case "<Map_Opt_1_Statement>":
                case "<Map_Opt_2_Statement>":
                case "<Map_Opt_3_Statement>":
                case "<Map_Opt_4_Statement>":
                case "<Map_Opt_5_Statement>":
                case "<Menu_Statement>":
                case "<Menu_Command_Statement>":
                case "<Menu_Dialog_Statement>":
                case "<Menu_Execute_Statement>":
                case "<Menu_Item_Block_Name_Statement>":
                case "<Menu_Item_Separator_Statement>":
                case "<Menu_Replace_Statement>":
                case "<Move_Buttons_Statement>":
                case "<New_Page_Statement>":
                case "<On_Browser_Exit_Block>":
                case "<Picture_Statement>":
                case "<Picture_Size_Statement>":
                case "<Popup_Statement>":
                case "<Repeat_Statement>":
                case "<Screen_Text_Statement>":
                case "<Set_Buttons_Statement>":
                case "<Set_DB_Version_Statement>":
                case "<Set_DOS_Win_Statement>":
                case "<Set_Import_Year_Statement>":
                case "<Set_Ini_Dir_Statement>":
                case "<Set_Language_Statement>":
                case "<Set_Picture_Statement>":
                case "<Set_Work_Dir_Statement>":
                case "<ShutDown_Block>":
                case "<Startup_Block>":
                case "<Sys_Info_Statement>":
                case "<All_Standard_Undefine_Statement>":
                case "<All_Global_Undefine_Statement>":
                case "<Wait_For_Statement>":
                case "<Wait_For_Exit_Statement>":
                case "<Wait_For_File_Exists_Statement>":
                case "<Command_Block>":
                case "<On_Browser_Exit_Empty_Block>":
                case "<Startup_Empty_Block>":
                case "<ShutDown_Empty_Block>":
                case "<Menu_Empty_Block>":
                case "<Popup_Empty_Block>":
                case "<Empty_Command_Block>":
                    break;
                }
            }
            else // terminal token
            {
                TerminalToken terminal = (TerminalToken)token;

                switch (terminal.Symbol.ToString())
                {
                case "<Value>":
                default:
                    result = new Rule_Value(context, terminal);
                    break;
                }
            }

            return(result);
        }
Exemplo n.º 34
0
 public AuthenticationMiddleware(RequestDelegate next, IOptions <Token> token)
 {
     _next  = next;
     _token = token.Value;
 }
Exemplo n.º 35
0
 public void WriteUnaryOp(Token opToken)
 {
     _streamWriter.WriteLine(opToken.Value == "-" ? "neg" : "not");
 }
Exemplo n.º 36
0
 public string bee(Token <OptionTestToken> b)
 {
     return($"B({b.Value})");
 }
Exemplo n.º 37
0
        public string RManyNT(Token <TokenType> e, Token <TokenType> f)
        {
            var result = $"G({e.Value},{f.Value})";

            return(result);
        }
Exemplo n.º 38
0
        public void Token_ToString()
        {
            var token = new Token(Lexeme.Text, "Hello world");

            Assert.AreEqual(@"Type: ""Text"" Value: ""Hello world""", token.ToString());
        }
Exemplo n.º 39
0
        /// <summary>
        /// before actually analysing the current token, we can do special stuff
        /// </summary>
        /// <param name="token"></param>
        private void AnalyseForEachToken(Token token)
        {
            // replace a pre proc var {&x} / include at current pos + 2
            ReplaceIncludeAndPreprocVariablesAhead(2); // (why 2? because for for statement parsing, we need to peek at position +2)

            var tokenIsWord             = token is TokenWord;
            var tokenIsPreProcDirective = token is TokenPreProcDirective;

            // starting a new statement, we need to remember its starting line
            if (_context.CurrentStatementIsEnded && (tokenIsWord || tokenIsPreProcDirective))
            {
                _context.CurrentStatementIsEnded = false;
                _context.CurrentStatement        = new ParsedStatement(token);
                _parsedStatementList.Add(_context.CurrentStatement);

                if (tokenIsWord)
                {
                    // if we are not continuing a IF ... THEN with a ELSE we should pop all single indent block
                    if (!token.Value.ToLower().Equals("else"))
                    {
                        PopOneStatementIndentBlock(0);
                    }
                }
            }

            // word
            if (tokenIsWord)
            {
                _context.CurrentStatement.WordCount++;
            }

            // pre processed if statement
            else if (tokenIsPreProcDirective)
            {
                var directiveLower = token.Value.ToLower();
                switch (directiveLower)
                {
                case "&endif":
                case "&else":
                case "&elseif":
                    if (_context.InFalsePreProcIfBlock)
                    {
                        // we were in false if block so we did not replace ahead, do it now
                        ReplaceIncludeAndPreprocVariablesAhead(1);
                        ReplaceIncludeAndPreprocVariablesAhead(2);
                    }
                    _context.InFalsePreProcIfBlock = false;
                    if (!CloseBlock <ParsedScopePreProcIfBlock>(token))
                    {
                        // we match an end w/o beggining, flag a mismatch
                        _parserErrors.Add(new ParserError(ParserErrorType.UnexpectedPreProcEndIf, token, _context.BlockStack.Count, _parsedIncludes));
                    }
                    switch (directiveLower)
                    {
                    case "&endif":
                        NewStatement(token);
                        _context.LastPreprocIfwasTrue = false;
                        break;

                    case "&else":
                        // push a block to stack
                        var newElse = CreateParsedIfEndIfPreProc(token, _context.LastPreprocIfwasTrue);
                        _context.BlockStack.Push(newElse);
                        NewStatement(token);
                        _context.InFalsePreProcIfBlock = !newElse.ExpressionResult;
                        break;

                    case "&elseif":
                        // push a block to stack
                        var newElseIf = CreateParsedIfEndIfPreProc(token, _context.LastPreprocIfwasTrue);
                        _context.BlockStack.Push(newElseIf);
                        _context.LastPreprocIfwasTrue = _context.LastPreprocIfwasTrue || newElseIf.ExpressionResult;
                        break;
                    }
                    break;

                case "&then":
                    // &then without a &if or &elseif
                    var currentPreProcIfBlock = GetCurrentBlock <ParsedScopePreProcIfBlock>();
                    if (currentPreProcIfBlock == null)
                    {
                        _parserErrors.Add(new ParserError(ParserErrorType.UnexpectedPreprocThen, token, _context.BlockStack.Count, _parsedIncludes));
                    }
                    NewStatement(token);
                    _context.InFalsePreProcIfBlock = currentPreProcIfBlock != null && !currentPreProcIfBlock.ExpressionResult;
                    break;

                case "&if":
                    // push a block to stack
                    var newIf = CreateParsedIfEndIfPreProc(token, false);
                    _context.BlockStack.Push(newIf);
                    _context.LastPreprocIfwasTrue = newIf.ExpressionResult;
                    break;

                default:
                    // pre processed directive (&analyze-suspend, &analyze-resume, &scop/glob-define, &undefine)

                    var lowerValue = token.Value.ToLower();
                    if (lowerValue.Equals("&analyze-resume"))
                    {
                        // end of a preprocessed (UIB / appbuilder) directive
                        if (token.OwnerNumber == 0)
                        {
                            // it marks the end of an appbuilder block, it can only be at a root/File level
                            if (!(GetCurrentBlock <ParsedScopeBlock>() is ParsedFile))
                            {
                                _parserErrors.Add(new ParserError(ParserErrorType.NotAllowedUibBlockEnd, token, _context.BlockStack.Count, _parsedIncludes));
                            }

                            if (!CloseBlock <ParsedScopePreProcBlock>(token))
                            {
                                // we match an end w/o beggining, flag a mismatch
                                _parserErrors.Add(new ParserError(ParserErrorType.UnexpectedUibBlockEnd, token, _context.BlockStack.Count, _parsedIncludes));
                            }
                        }

                        // info we will extract from the current statement :
                        while (MoveNext())
                        {
                            var nextToken = PeekAt(0);     // next token
                            if (nextToken is TokenEol)
                            {
                                break;
                            }
                        }

                        NewStatement(PeekAt(0));     // new statement is done on the EOL
                        break;
                    }
                    else
                    {
                        if (!lowerValue.StartsWith("&analyze"))
                        {
                            // should be the first word of a statement (otherwise this probably doesn't compile anyway!)
                            if (token.OwnerNumber == 0 && _context.CurrentStatement.WordCount > 0)
                            {
                                _parserErrors.Add(new ParserError(ParserErrorType.UibBlockStartMustBeNewStatement, token, _context.BlockStack.Count, _parsedIncludes));
                            }
                        }

                        // can create a new block if it is a UIB directive (&analyse-suspend) or create a preproc variable (and &undefine a variable)
                        var newBlock = CreateParsedPreProcDirective(token);
                        if (newBlock != null)
                        {
                            _context.BlockStack.Push(newBlock);
                        }
                    }

                    if (token.OwnerNumber != 0 || _context.CurrentStatement.WordCount == 0)
                    {
                        NewStatement(PeekAt(0));     // new statement is done on the EOL
                    }
                    break;
                }
                MoveNext();

                // End of line
            }
            else if (token is TokenEol)
            {
                AddLineInfo(token);

                // keywords like then/otherwise only increase the indentation for a single statement,
                // if the statement it indented is over then pop the indent block
                PopOneStatementIndentBlock(1);
            }
        }
Exemplo n.º 40
0
 /// <summary>
 /// called when a Eos token is found, store information on the statement's line
 /// </summary>
 private void NewStatement(Token token)
 {
     AddLineInfo(token);
     _context.CurrentStatementIsEnded = true;
 }
Exemplo n.º 41
0
 public void TokenBetweenFailsIfMiddleParserFails()
 {
     AssertParser.Fails(Token.EqualTo('a').Between(Token.EqualTo('('), Token.EqualTo(')')), "(b)");
 }
Exemplo n.º 42
0
 public void TokenBetweenSucceedsIfAllParsersSucceed()
 {
     AssertParser.SucceedsWith(Token.EqualTo('a').Between(Token.EqualTo('('), Token.EqualTo(')')), "(a)", 'a');
 }
Exemplo n.º 43
0
        static public List <AnalysisRule> GetFunctionParameters(Rule_Context context, Token token)
        {
            List <AnalysisRule> result = new List <AnalysisRule>();

            if (token is NonterminalToken)
            {
                NonterminalToken nonterminal = (NonterminalToken)token;

                switch (nonterminal.Symbol.ToString())
                {
                case "<NonEmptyFunctionParameterList>":
                    result.AddRange(AnalysisRule.GetFunctionParameters(context, nonterminal));
                    break;

                case "<SingleFunctionParameterList>":
                    result.AddRange(AnalysisRule.GetFunctionParameters(context, nonterminal));
                    break;

                case "<EmptyFunctionParameterList>":
                    break;

                case "<MultipleFunctionParameterList>":
                    result.AddRange(AnalysisRule.GetFunctionParameters(context, nonterminal.Tokens[0]));
                    result.Add(AnalysisRule.BuildStatments(context, nonterminal.Tokens[2]));
                    break;

                case "<FuncName2>":
                case "<Expression>":
                case "<expression>":
                case "<FunctionCall>":
                default:
                    result.Add(AnalysisRule.BuildStatments(context, nonterminal));
                    break;
                }
            }
            else
            {
                TerminalToken terminal = (TerminalToken)token;
                if (terminal.Text != ",")
                {
                    result.Add(new Rule_Value(context, token));
                }
            }

            return(result);
        }
Exemplo n.º 44
0
 public void TokenBetweenFailsIfRightParserFails()
 {
     AssertParser.Fails(Token.EqualTo('a').Between(Token.EqualTo('('), Token.EqualTo(')')), "(a}");
 }
Exemplo n.º 45
0
 public CmpInstruction(Input input, Token instructionToken, Token operand1, Token operand2)
     : base(input, instructionToken, operand1, operand2)
 {
 }
Exemplo n.º 46
0
        /// <summary>
        /// Creates an identity token.
        /// </summary>
        /// <param name="request">The token creation request.</param>
        /// <returns>
        /// An identity token
        /// </returns>
        public virtual async Task <Token> CreateIdentityTokenAsync(TokenCreationRequest request)
        {
            Logger.LogTrace("Creating identity token");
            request.Validate();

            // todo: Dom, add a test for this. validate the at and c hashes are correct for the id_token when the client's alg doesn't match the server default.
            var credential = await KeyMaterialService.GetSigningCredentialsAsync(request.ValidatedRequest.Client.AllowedIdentityTokenSigningAlgorithms);

            if (credential == null)
            {
                throw new InvalidOperationException("No signing credential is configured.");
            }

            var signingAlgorithm = credential.Algorithm;

            // host provided claims
            var claims = new List <Claim>();

            // if nonce was sent, must be mirrored in id token
            if (request.Nonce.IsPresent())
            {
                claims.Add(new Claim(JwtClaimTypes.Nonce, request.Nonce));
            }

            // add iat claim
            claims.Add(new Claim(JwtClaimTypes.IssuedAt, Clock.UtcNow.ToUnixTimeSeconds().ToString(), ClaimValueTypes.Integer64));

            // add at_hash claim
            if (request.AccessTokenToHash.IsPresent())
            {
                claims.Add(new Claim(JwtClaimTypes.AccessTokenHash, CryptoHelper.CreateHashClaimValue(request.AccessTokenToHash, signingAlgorithm)));
            }

            // add c_hash claim
            if (request.AuthorizationCodeToHash.IsPresent())
            {
                claims.Add(new Claim(JwtClaimTypes.AuthorizationCodeHash, CryptoHelper.CreateHashClaimValue(request.AuthorizationCodeToHash, signingAlgorithm)));
            }

            // add s_hash claim
            if (request.StateHash.IsPresent())
            {
                claims.Add(new Claim(JwtClaimTypes.StateHash, request.StateHash));
            }

            // add sid if present
            if (request.ValidatedRequest.SessionId.IsPresent())
            {
                claims.Add(new Claim(JwtClaimTypes.SessionId, request.ValidatedRequest.SessionId));
            }

            claims.AddRange(await ClaimsProvider.GetIdentityTokenClaimsAsync(
                                request.Subject,
                                request.ValidatedResources,
                                request.IncludeAllIdentityClaims,
                                request.ValidatedRequest));

            var issuer = ContextAccessor.HttpContext.GetIdentityServerIssuerUri();

            var token = new Token(OidcConstants.TokenTypes.IdentityToken)
            {
                CreationTime             = Clock.UtcNow.UtcDateTime,
                Audiences                = { request.ValidatedRequest.Client.ClientId },
                Issuer                   = issuer,
                Lifetime                 = request.ValidatedRequest.Client.IdentityTokenLifetime,
                Claims                   = claims.Distinct(new ClaimComparer()).ToList(),
                ClientId                 = request.ValidatedRequest.Client.ClientId,
                AccessTokenType          = request.ValidatedRequest.AccessTokenType,
                AllowedSigningAlgorithms = request.ValidatedRequest.Client.AllowedIdentityTokenSigningAlgorithms
            };

            return(token);
        }
 public async Task Create(Token token)
 {
     await _context.Tokens.InsertOneAsync(token);
 }
Exemplo n.º 48
0
        /// <summary>
        /// Creates an access token.
        /// </summary>
        /// <param name="request">The token creation request.</param>
        /// <returns>
        /// An access token
        /// </returns>
        public virtual async Task <Token> CreateAccessTokenAsync(TokenCreationRequest request)
        {
            Logger.LogTrace("Creating access token");
            request.Validate();

            var claims = new List <Claim>();

            claims.AddRange(await ClaimsProvider.GetAccessTokenClaimsAsync(
                                request.Subject,
                                request.ValidatedResources,
                                request.ValidatedRequest));

            if (request.ValidatedRequest.Client.IncludeJwtId)
            {
                claims.Add(new Claim(JwtClaimTypes.JwtId, CryptoRandom.CreateUniqueId(16, CryptoRandom.OutputFormat.Hex)));
            }

            if (request.ValidatedRequest.SessionId.IsPresent())
            {
                claims.Add(new Claim(JwtClaimTypes.SessionId, request.ValidatedRequest.SessionId));
            }

            var issuer = ContextAccessor.HttpContext.GetIdentityServerIssuerUri();
            var token  = new Token(OidcConstants.TokenTypes.AccessToken)
            {
                CreationTime             = Clock.UtcNow.UtcDateTime,
                Issuer                   = issuer,
                Lifetime                 = request.ValidatedRequest.AccessTokenLifetime,
                Claims                   = claims.Distinct(new ClaimComparer()).ToList(),
                ClientId                 = request.ValidatedRequest.Client.ClientId,
                Description              = request.Description,
                AccessTokenType          = request.ValidatedRequest.AccessTokenType,
                AllowedSigningAlgorithms = request.ValidatedResources.Resources.ApiResources.FindMatchingSigningAlgorithms()
            };

            // add aud based on ApiResources in the validated request
            foreach (var aud in request.ValidatedResources.Resources.ApiResources.Select(x => x.Name).Distinct())
            {
                token.Audiences.Add(aud);
            }

            if (Options.EmitLegacyResourceAudienceClaim)
            {
                token.Audiences.Add(string.Format(IdentityServerConstants.AccessTokenAudience, issuer.EnsureTrailingSlash()));
            }

            // add cnf if present
            if (request.ValidatedRequest.Confirmation.IsPresent())
            {
                token.Confirmation = request.ValidatedRequest.Confirmation;
            }
            else
            {
                if (Options.MutualTls.AlwaysEmitConfirmationClaim)
                {
                    var clientCertificate = await ContextAccessor.HttpContext.Connection.GetClientCertificateAsync();

                    if (clientCertificate != null)
                    {
                        token.Confirmation = clientCertificate.CreateThumbprintCnf();
                    }
                }
            }

            return(token);
        }
Exemplo n.º 49
0
    /*
    ** Generate code to implement the "ALTER TABLE xxx RENAME TO yyy"
    ** command.
    */
    static void sqlite3AlterRenameTable(
    Parse pParse,             /* Parser context. */
    SrcList pSrc,             /* The table to rename. */
    Token pName               /* The new table name. */
    )
    {
      int iDb;                  /* Database that contains the table */
      string zDb;               /* Name of database iDb */
      Table pTab;               /* Table being renamed */
      string zName = null;      /* NULL-terminated version of pName */
      sqlite3 db = pParse.db;   /* Database connection */
      int nTabName;             /* Number of UTF-8 characters in zTabName */
      string zTabName;          /* Original name of the table */
      Vdbe v;
#if !SQLITE_OMIT_TRIGGER
      string zWhere = "";       /* Where clause to locate temp triggers */
#endif
      VTable pVTab = null;         /* Non-zero if this is a v-tab with an xRename() */

      //if ( NEVER( db.mallocFailed != 0 ) ) goto exit_rename_table;
      Debug.Assert( pSrc.nSrc == 1 );
      Debug.Assert( sqlite3BtreeHoldsAllMutexes( pParse.db ) );
      pTab = sqlite3LocateTable( pParse, 0, pSrc.a[0].zName, pSrc.a[0].zDatabase );
      if ( pTab == null ) goto exit_rename_table;
      iDb = sqlite3SchemaToIndex( pParse.db, pTab.pSchema );
      zDb = db.aDb[iDb].zName;

      /* Get a NULL terminated version of the new table name. */
      zName = sqlite3NameFromToken( db, pName );
      if ( zName == null ) goto exit_rename_table;

      /* Check that a table or index named 'zName' does not already exist
      ** in database iDb. If so, this is an error.
      */
      if ( sqlite3FindTable( db, zName, zDb ) != null || sqlite3FindIndex( db, zName, zDb ) != null )
      {
        sqlite3ErrorMsg( pParse,
        "there is already another table or index with this name: %s", zName );
        goto exit_rename_table;
      }

      /* Make sure it is not a system table being altered, or a reserved name
      ** that the table is being renamed to.
      */
      if ( sqlite3Strlen30( pTab.zName ) > 6
      && 0 == sqlite3StrNICmp( pTab.zName, "sqlite_", 7 )
      )
      {
        sqlite3ErrorMsg( pParse, "table %s may not be altered", pTab.zName );
        goto exit_rename_table;
      }
      if ( SQLITE_OK != sqlite3CheckObjectName( pParse, zName ) )
      {
        goto exit_rename_table;
      }

#if !SQLITE_OMIT_VIEW
      if ( pTab.pSelect != null )
      {
        sqlite3ErrorMsg( pParse, "view %s may not be altered", pTab.zName );
        goto exit_rename_table;
      }
#endif

#if !SQLITE_OMIT_AUTHORIZATION
/* Invoke the authorization callback. */
if( sqlite3AuthCheck(pParse, SQLITE_ALTER_TABLE, zDb, pTab.zName, 0) ){
goto exit_rename_table;
}
#endif

      if ( sqlite3ViewGetColumnNames( pParse, pTab ) != 0 )
      {
        goto exit_rename_table;
      }
#if !SQLITE_OMIT_VIRTUALTABLE
  if( IsVirtual(pTab) ){
    pVTab = sqlite3GetVTable(db, pTab);
    if( pVTab.pVtab.pModule.xRename==null ){
      pVTab = null;
    }
#endif
      /* Begin a transaction and code the VerifyCookie for database iDb.
** Then modify the schema cookie (since the ALTER TABLE modifies the
** schema). Open a statement transaction if the table is a virtual
** table.
*/
      v = sqlite3GetVdbe( pParse );
      if ( v == null )
      {
        goto exit_rename_table;
      }
      sqlite3BeginWriteOperation( pParse, pVTab != null ? 1 : 0, iDb );
      sqlite3ChangeCookie( pParse, iDb );

      /* If this is a virtual table, invoke the xRename() function if
      ** one is defined. The xRename() callback will modify the names
      ** of any resources used by the v-table implementation (including other
      ** SQLite tables) that are identified by the name of the virtual table.
      */
#if  !SQLITE_OMIT_VIRTUALTABLE
if ( pVTab !=null)
{
int i = ++pParse.nMem;
sqlite3VdbeAddOp4( v, OP_String8, 0, i, 0, zName, 0 );
sqlite3VdbeAddOp4( v, OP_VRename, i, 0, 0, pVtab, P4_VTAB );
}
#endif

      /* figure out how many UTF-8 characters are in zName */
      zTabName = pTab.zName;
      nTabName = sqlite3Utf8CharLen( zTabName, -1 );

      /* Modify the sqlite_master table to use the new table name. */
      sqlite3NestedParse( pParse,
      "UPDATE %Q.%s SET " +
#if SQLITE_OMIT_TRIGGER
"sql = sqlite_rename_table(sql, %Q), "+
#else
 "sql = CASE " +
      "WHEN type = 'trigger' THEN sqlite_rename_trigger(sql, %Q)" +
      "ELSE sqlite_rename_table(sql, %Q) END, " +
#endif
 "tbl_name = %Q, " +
      "name = CASE " +
      "WHEN type='table' THEN %Q " +
      "WHEN name LIKE 'sqlite_autoindex%%' AND type='index' THEN " +
      "'sqlite_autoindex_' || %Q || substr(name,%d+18) " +
      "ELSE name END " +
      "WHERE tbl_name=%Q AND " +
      "(type='table' OR type='index' OR type='trigger');",
      zDb, SCHEMA_TABLE( iDb ), zName, zName, zName,
#if !SQLITE_OMIT_TRIGGER
 zName,
#endif
 zName, nTabName, zTabName
      );

#if !SQLITE_OMIT_AUTOINCREMENT
      /* If the sqlite_sequence table exists in this database, then update
** it with the new table name.
*/
      if ( sqlite3FindTable( db, "sqlite_sequence", zDb ) != null )
      {
        sqlite3NestedParse( pParse,
        "UPDATE \"%w\".sqlite_sequence set name = %Q WHERE name = %Q",
        zDb, zName, pTab.zName
        );
      }
#endif

#if !SQLITE_OMIT_TRIGGER
      /* If there are TEMP triggers on this table, modify the sqlite_temp_master
** table. Don't do this if the table being ALTERed is itself located in
** the temp database.
*/
      if ( ( zWhere = whereTempTriggers( pParse, pTab ) ) != "" )
      {
        sqlite3NestedParse( pParse,
        "UPDATE sqlite_temp_master SET " +
        "sql = sqlite_rename_trigger(sql, %Q), " +
        "tbl_name = %Q " +
        "WHERE %s;", zName, zName, zWhere );
        //sqlite3DbFree( db, ref zWhere );
      }
#endif

      /* Drop and reload the internal table schema. */
      reloadTableSchema( pParse, pTab, zName );

exit_rename_table:
      sqlite3SrcListDelete( db, ref pSrc );
      //sqlite3DbFree( db, ref zName );
    }
Exemplo n.º 50
0
 private void ConsumeToken()
 {
     lookAheadToken = Token.None;
 }
Exemplo n.º 51
0
        public Token GetToken()
        {
            // skip white chars
            while (lastChar == ' ' || lastChar == '\t' || lastChar == '\r')
            {
                GetChar();
            }

            TokenMarker = sourceMarker;

            if (char.IsLetter(lastChar))
            {
                Identifier = lastChar.ToString();
                while (char.IsLetterOrDigit(GetChar()))
                {
                    Identifier += lastChar;
                }

                switch (Identifier.ToUpper())
                {
                case "PRINT": return(Token.Print);

                case "IF": return(Token.If);

                case "ENDIF": return(Token.EndIf);

                case "THEN": return(Token.Then);

                case "ELSE": return(Token.Else);

                case "FOR": return(Token.For);

                case "TO": return(Token.To);

                case "NEXT": return(Token.Next);

                case "GOTO": return(Token.Goto);

                case "INPUT": return(Token.Input);

                case "LET": return(Token.Let);

                case "GOSUB": return(Token.Gosub);

                case "RETURN": return(Token.Return);

                case "END": return(Token.End);

                case "OR": return(Token.Or);

                case "AND": return(Token.And);

                case "NOT": return(Token.Not);

                case "ASSERT": return(Token.Assert);

                case "REM":
                    while (lastChar != '\n')
                    {
                        GetChar();
                    }
                    GetChar();
                    return(GetToken());

                default:
                    return(Token.Identifier);
                }
            }

            if (char.IsDigit(lastChar))
            {
                string num = "";
                do
                {
                    num += lastChar;
                } while (char.IsDigit(GetChar()) || lastChar == '.');

                double real;
                if (!double.TryParse(num, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out real))
                {
                    throw new Exception("ERROR while parsing number");
                }
                Value = new Value(real);
                return(Token.Value);
            }

            Token tok = Token.Unknown;

            switch (lastChar)
            {
            case '\n': tok = Token.NewLine; break;

            case ':': tok = Token.Colon; break;

            case ';': tok = Token.Semicolon; break;

            case ',': tok = Token.Comma; break;

            case '=': tok = Token.Equal; break;

            case '+': tok = Token.Plus; break;

            case '-': tok = Token.Minus; break;

            case '/': tok = Token.Slash; break;

            case '*': tok = Token.Asterisk; break;

            case '^': tok = Token.Caret; break;

            case '(': tok = Token.LParen; break;

            case ')': tok = Token.RParen; break;

            case '\'':
                // skip comment until new line
                while (lastChar != '\n')
                {
                    GetChar();
                }
                GetChar();
                return(GetToken());

            case '<':
                GetChar();
                if (lastChar == '>')
                {
                    tok = Token.NotEqual;
                }
                else if (lastChar == '=')
                {
                    tok = Token.LessEqual;
                }
                else
                {
                    return(Token.Less);
                }
                break;

            case '>':
                GetChar();
                if (lastChar == '=')
                {
                    tok = Token.MoreEqual;
                }
                else
                {
                    return(Token.More);
                }
                break;

            case '"':
                string str = "";
                while (GetChar() != '"')
                {
                    if (lastChar == '\\')
                    {
                        // parse \n, \t, \\, \"
                        switch (char.ToLower(GetChar()))
                        {
                        case 'n': str += '\n'; break;

                        case 't': str += '\t'; break;

                        case '\\': str += '\\'; break;

                        case '"': str += '"'; break;
                        }
                    }
                    else
                    {
                        str += lastChar;
                    }
                }
                Value = new Value(str);
                tok   = Token.Value;
                break;

            case (char)0:
                return(Token.EOF);
            }

            GetChar();
            return(tok);
        }
Exemplo n.º 52
0
    /*
    ** This function is called after an "ALTER TABLE ... ADD" statement
    ** has been parsed. Argument pColDef contains the text of the new
    ** column definition.
    **
    ** The Table structure pParse.pNewTable was extended to include
    ** the new column during parsing.
    */
    static void sqlite3AlterFinishAddColumn( Parse pParse, Token pColDef )
    {
      Table pNew;              /* Copy of pParse.pNewTable */
      Table pTab;              /* Table being altered */
      int iDb;                 /* Database number */
      string zDb;              /* Database name */
      string zTab;             /* Table name */
      string zCol;             /* Null-terminated column definition */
      Column pCol;             /* The new column */
      Expr pDflt;              /* Default value for the new column */
      sqlite3 db;              /* The database connection; */

      db = pParse.db;
      if ( pParse.nErr != 0 /*|| db.mallocFailed != 0 */ ) return;
      pNew = pParse.pNewTable;
      Debug.Assert( pNew != null );
      Debug.Assert( sqlite3BtreeHoldsAllMutexes( db ) );
      iDb = sqlite3SchemaToIndex( db, pNew.pSchema );
      zDb = db.aDb[iDb].zName;
      zTab = pNew.zName.Substring( 16 );// zTab = &pNew->zName[16]; /* Skip the "sqlite_altertab_" prefix on the name */
      pCol = pNew.aCol[pNew.nCol - 1];
      pDflt = pCol.pDflt;
      pTab = sqlite3FindTable( db, zTab, zDb );
      Debug.Assert( pTab != null );

#if !SQLITE_OMIT_AUTHORIZATION
/* Invoke the authorization callback. */
if( sqlite3AuthCheck(pParse, SQLITE_ALTER_TABLE, zDb, pTab.zName, 0) ){
return;
}
#endif

      /* If the default value for the new column was specified with a
** literal NULL, then set pDflt to 0. This simplifies checking
** for an SQL NULL default below.
*/
      if ( pDflt != null && pDflt.op == TK_NULL )
      {
        pDflt = null;
      }

      /* Check that the new column is not specified as PRIMARY KEY or UNIQUE.
      ** If there is a NOT NULL constraint, then the default value for the
      ** column must not be NULL.
      */
      if ( pCol.isPrimKey != 0 )
      {
        sqlite3ErrorMsg( pParse, "Cannot add a PRIMARY KEY column" );
        return;
      }
      if ( pNew.pIndex != null )
      {
        sqlite3ErrorMsg( pParse, "Cannot add a UNIQUE column" );
        return;
      }
      if ( pCol.notNull != 0 && pDflt == null )
      {
        sqlite3ErrorMsg( pParse,
        "Cannot add a NOT NULL column with default value NULL" );
        return;
      }

      /* Ensure the default expression is something that sqlite3ValueFromExpr()
      ** can handle (i.e. not CURRENT_TIME etc.)
      */
      if ( pDflt != null )
      {
        sqlite3_value pVal = null;
        if ( sqlite3ValueFromExpr( db, pDflt, SQLITE_UTF8, SQLITE_AFF_NONE, ref pVal ) != 0 )
        {
  //        db.mallocFailed = 1;
          return;
        }
        if ( pVal == null )
        {
          sqlite3ErrorMsg( pParse, "Cannot add a column with non-constant default" );
          return;
        }
        sqlite3ValueFree( ref pVal );
      }

      /* Modify the CREATE TABLE statement. */
      zCol = pColDef.z.Substring( 0, pColDef.n ).Replace( ";", " " ).Trim();//sqlite3DbStrNDup(db, (char*)pColDef.z, pColDef.n);
      if ( zCol != null )
      {
        //  char zEnd = zCol[pColDef.n-1];
        //      while( zEnd>zCol && (*zEnd==';' || sqlite3Isspace(*zEnd)) ){
        //    zEnd-- = '\0';
        //  }
        sqlite3NestedParse( pParse,
        "UPDATE \"%w\".%s SET " +
        "sql = substr(sql,1,%d) || ', ' || %Q || substr(sql,%d) " +
        "WHERE type = 'table' AND name = %Q",
        zDb, SCHEMA_TABLE( iDb ), pNew.addColOffset, zCol, pNew.addColOffset + 1,
        zTab
        );
        //sqlite3DbFree( db, ref zCol );
      }

      /* If the default value of the new column is NULL, then set the file
      ** format to 2. If the default value of the new column is not NULL,
      ** the file format becomes 3.
      */
      sqlite3MinimumFileFormat( pParse, iDb, pDflt != null ? 3 : 2 );

      /* Reload the schema of the modified table. */
      reloadTableSchema( pParse, pTab, pTab.zName );
    }
Exemplo n.º 53
0
        void Start()
        {
            tokens = new List <Token>();

            addRouteButton.onClick.AddListener(() => {
                Token token = AddNewToken();

                // Select the new token when created via the button.
                token.selector.isOn = true;
            });

            removeRouteButton.onClick.AddListener(() => {
                if (currentSelected != null)
                {
                    Destroy(currentSelected);
                    currentSelected = null;
                }
            });

            addPointButton.onClick.AddListener(() => {
                if (currentSelected != null)
                {
                    int index        = currentSelected.line.positionCount++;
                    Vector3 position = Camera.main.transform.position;

                    // apply offset position
                    position.y += currentSelected.verticalOffset;

                    currentSelected.line.SetPosition(index, position);
                }
            });

            undoButton.onClick.AddListener(() => {
                if (currentSelected != null)
                {
                    currentSelected.line.positionCount = Mathf.Max(
                        currentSelected.line.positionCount - 1, 0);
                }
            });

            if (restartLineButton)
            {
                restartLineButton.onClick.AddListener(() => {
                    if (currentSelected != null)
                    {
                        currentSelected.line.positionCount = 0;
                    }
                });
            }

            // Name of routes is in Token.selector.text.
            routeNameInputField.onEndEdit.AddListener(name => {
                if (currentSelected != null)
                {
                    currentSelected.selector.text = name;
                }
            });

            loadButton.onClick.AddListener(() => {
                Load();
            });

            saveButton.onClick.AddListener(() => {
                Save();
            });

            startRouteButton.onClick.AddListener(() => {
                if (currentSelected == null || currentRoute)
                {
                    // don't start this when currentRoute is set or nothing is selected.
                    Debug.Log("Route is not selected or already animating.");
                }
                else
                {
                    Debug.Log("Route started");

                    // for making it a closure, we need a local variable
                    Token selectedToken = currentSelected;

                    // Route eats up a line's positions,
                    // so duplicate the current line to be sacrificed for it.
                    LineRenderer duplicatedLine = Instantiate(selectedToken.line);

                    // Copy the original line's positions to the duplicated line.
                    duplicatedLine.positionCount = selectedToken.line.positionCount;
                    for (int i = 0; i < selectedToken.line.positionCount; i++)
                    {
                        duplicatedLine.SetPosition(i, selectedToken.line.GetPosition(i));
                    }

                    // Instantiate Route with the duplicated line.
                    Route route = duplicatedLine.gameObject.AddComponent <Route>();

                    // Initialize the Route's properties.
                    route.OffsetSpeed     = offsetSpeed;
                    route.IntervalSeconds = intervalSeconds;
                    route.MaxDistance     = selectedToken.maxDistance;

                    // this is invoked either when completed or halted.
                    route.OnEnd += () => {
                        // Turn back on the original line/selector when route is done.
                        selectedToken.line.gameObject.SetActive(true);

                        // Re-select the original token when the route completes.
                        selectedToken.selector.isOn = true;

                        // delete duplicated instances.
                        Destroy(route.gameObject);
                    };

                    // Turn off the original line/selector while route is active.
                    // Otherwise they will sit on top of each other.
                    selectedToken.line.gameObject.SetActive(false);

                    // Expose this route so it can be halted anytime.
                    currentRoute = route;
                }
            });

            haltRouteButton.onClick.AddListener(() => {
                HaltCurrentRoute();
            });

            offsetSpeedSlider.onValueChanged.AddListener(value => {
                offsetSpeed = value;

                if (currentRoute)
                {
                    currentRoute.OffsetSpeed = value;
                }
            });

            maxDistanceSlider.onValueChanged.AddListener(value => {
                if (currentSelected != null)
                {
                    currentSelected.maxDistance = value;
                }

                if (currentRoute)
                {
                    currentRoute.MaxDistance = value;
                }
            });

            intervalSecondsSlider.onValueChanged.AddListener(value => {
                intervalSeconds = value;

                if (currentRoute)
                {
                    currentRoute.IntervalSeconds = value;
                }
            });

            verticalOffsetSlider.onValueChanged.AddListener(value => {
                if (currentSelected != null)
                {
                    // offset is determined by comparing the current input with the last input.
                    // The last input is stored as Token::verticalOffset.
                    float lastOffset = currentSelected.verticalOffset;
                    Vector3 move     = new Vector3(0, value - lastOffset, 0);
                    currentSelected.verticalOffset = value;
                    MoveAllPositions(currentSelected.line, move);

                    if (currentRoute)
                    {
                        MoveAllPositions(currentRoute.Line, move);
                    }
                }
            });
        }
Exemplo n.º 54
0
    /* This function is used by SQL generated to implement the
** ALTER TABLE command. The first argument is the text of a CREATE TRIGGER
** statement. The second is a table name. The table name in the CREATE
** TRIGGER statement is replaced with the third argument and the result
** returned. This is analagous to renameTableFunc() above, except for CREATE
** TRIGGER, not CREATE INDEX and CREATE TABLE.
*/
    static void renameTriggerFunc(
    sqlite3_context context,
    int NotUsed,
    sqlite3_value[] argv
    )
    {
      string zSql = sqlite3_value_text( argv[0] );
      string zTableName = sqlite3_value_text( argv[1] );

      int token = 0;
      Token tname = new Token();
      int dist = 3;
      int zCsr = 0;
      int zLoc = 0;
      int len = 1;
      string zRet;

      sqlite3 db = sqlite3_context_db_handle( context );

      UNUSED_PARAMETER( NotUsed );

      /* The principle used to locate the table name in the CREATE TRIGGER
      ** statement is that the table name is the first token that is immediatedly
      ** preceded by either TK_ON or TK_DOT and immediatedly followed by one
      ** of TK_WHEN, TK_BEGIN or TK_FOR.
      */
      if ( zSql != null )
      {
        do
        {

          if ( zCsr == zSql.Length )
          {
            /* Ran out of input before finding the table name. Return NULL. */
            return;
          }

          /* Store the token that zCsr points to in tname. */
          zLoc = zCsr;
          tname.z = zSql.Substring( zCsr, len );//(char*)zCsr;
          tname.n = len;

          /* Advance zCsr to the next token. Store that token type in 'token',
          ** and its length in 'len' (to be used next iteration of this loop).
          */
          do
          {
            zCsr += len;
            len = ( zCsr == zSql.Length ) ? 1 : sqlite3GetToken( zSql, zCsr, ref token );
          } while ( token == TK_SPACE );
          Debug.Assert( len > 0 );

          /* Variable 'dist' stores the number of tokens read since the most
          ** recent TK_DOT or TK_ON. This means that when a WHEN, FOR or BEGIN
          ** token is read and 'dist' equals 2, the condition stated above
          ** to be met.
          **
          ** Note that ON cannot be a database, table or column name, so
          ** there is no need to worry about syntax like
          ** "CREATE TRIGGER ... ON ON.ON BEGIN ..." etc.
          */
          dist++;
          if ( token == TK_DOT || token == TK_ON )
          {
            dist = 0;
          }
        } while ( dist != 2 || ( token != TK_WHEN && token != TK_FOR && token != TK_BEGIN ) );

        /* Variable tname now contains the token that is the old table-name
        ** in the CREATE TRIGGER statement.
        */
        zRet = sqlite3MPrintf( db, "%.*s\"%w\"%s", zLoc, zSql.Substring( 0, zLoc ),
        zTableName, zSql.Substring( zLoc + tname.n ) );
        sqlite3_result_text( context, zRet, -1, SQLITE_DYNAMIC );
      }
    }
Exemplo n.º 55
0
        /// <summary>
        /// 接收一条完整的数据,使用异步接收完成,包含了指令头信息
        /// </summary>
        /// <param name="socket">已经打开的网络套接字</param>
        /// <param name="timeOut">超时时间</param>
        /// <param name="netMsg">消息规则</param>
        /// <returns>数据的接收结果对象</returns>
        protected OperateResult <TNetMessage> ReceiveMessage(Socket socket, int timeOut, TNetMessage netMsg)
        {
            OperateResult <TNetMessage> result = new OperateResult <TNetMessage>( );

            // 超时接收的代码验证
            HslTimeOut hslTimeOut = new HslTimeOut( )
            {
                DelayTime  = timeOut,
                WorkSocket = socket,
            };

            if (timeOut > 0)
            {
                ThreadPool.QueueUserWorkItem(new WaitCallback(ThreadPoolCheckTimeOut), hslTimeOut);
            }

            // 接收指令头
            OperateResult <byte[]> headResult = Receive(socket, netMsg.ProtocolHeadBytesLength);

            if (!headResult.IsSuccess)
            {
                hslTimeOut.IsSuccessful = true;
                result.CopyErrorFromOther(headResult);
                return(result);
            }

            netMsg.HeadBytes = headResult.Content;
            if (!netMsg.CheckHeadBytesLegal(Token.ToByteArray( )))
            {
                // 令牌校验失败
                hslTimeOut.IsSuccessful = true;
                socket?.Close( );
                LogNet?.WriteError(ToString( ), StringResources.TokenCheckFailed);
                result.Message = StringResources.TokenCheckFailed;
                return(result);
            }


            int contentLength = netMsg.GetContentLengthByHeadBytes( );

            if (contentLength == 0)
            {
                netMsg.ContentBytes = new byte[0];
            }
            else
            {
                OperateResult <byte[]> contentResult = Receive(socket, contentLength);
                if (!headResult.IsSuccess)
                {
                    hslTimeOut.IsSuccessful = true;
                    result.CopyErrorFromOther(contentResult);
                    return(result);
                }

                netMsg.ContentBytes = contentResult.Content;
            }

            hslTimeOut.IsSuccessful = true;
            result.Content          = netMsg;
            result.IsSuccess        = true;
            return(result);
        }
Exemplo n.º 56
0
        public ClientLicense ActivateLicenseKey(string licenseKey, Guid?token, bool isOffline, ClientLicense scutexLicense, string hardwareFingerprint)
        {
            /* This method used to live in the LicenseKeyService class, where it should be
             *  but because of a circular reference in the WebServicesProvider and the ServicesLibrary
             *  project requiring the LicenseKeyService to valid keys it was causing and error and had
             *  to be moved here.
             */

            if (_licenseKeyService.ValidateLicenseKey(licenseKey, scutexLicense, true))
            {
                Token t = new Token();
                t.Data      = scutexLicense.ServiceToken;
                t.Timestamp = DateTime.Now;

                string packedToken = _packingService.PackToken(t);

                LicenseActivationPayload payload = new LicenseActivationPayload();
                payload.LicenseKey     = licenseKey;
                payload.ServiceLicense = new ServiceLicense(scutexLicense);
                payload.Token          = token;

                if (!String.IsNullOrEmpty(hardwareFingerprint))
                {
                    payload.HardwareFingerprint = hardwareFingerprint;
                }

                if (!isOffline)
                {
                    ActivationResult result = _licenseActiviationProvider.ActivateLicense(scutexLicense.ServiceAddress, packedToken,
                                                                                          GetClientStandardEncryptionInfo(scutexLicense),
                                                                                          payload, scutexLicense);

                    if (result != null && result.WasRequestValid && result.ActivationSuccessful)
                    {
                        scutexLicense.IsLicensed              = true;
                        scutexLicense.IsActivated             = true;
                        scutexLicense.ActivatingServiceId     = result.ServiceId;
                        scutexLicense.ActivationToken         = result.ActivationToken;
                        scutexLicense.ActivatedOn             = DateTime.Now;
                        scutexLicense.ActivationLastCheckedOn = DateTime.Now;

                        _clientLicenseService.SaveClientLicense(scutexLicense);

                        return(scutexLicense);
                    }
                }
                else
                {
                    scutexLicense.IsLicensed              = true;
                    scutexLicense.IsActivated             = false;
                    scutexLicense.ActivatingServiceId     = null;
                    scutexLicense.ActivationToken         = null;
                    scutexLicense.ActivatedOn             = DateTime.Now;
                    scutexLicense.ActivationLastCheckedOn = DateTime.Now;

                    _clientLicenseService.SaveClientLicense(scutexLicense);

                    return(scutexLicense);
                }
            }

            return(scutexLicense);
        }
Exemplo n.º 57
0
 public NumericLiteralSyntax(Token literal, int value)
 {
     Literal = literal;
     Value   = value;
 }
Exemplo n.º 58
0
 void Destroy(Token token)
 {
     Destroy(token.line.gameObject);
     Destroy(token.selector.gameObject);
     tokens.Remove(token);
 }
Exemplo n.º 59
0
 public MethodCallAstNode(Token token, IList <AstNode> arguments)
 {
     _token     = token;
     _arguments = arguments;
 }
Exemplo n.º 60
0
 public iExchange.Common.TransactionError Cancel(Token token, Guid accountId, Guid tranId, CancelReason cancelReason)
 {
     return(this.Call <TransactionError>(() => this.Service.Cancel(token, accountId, tranId, cancelReason)));
 }