private void Term() { Factor(); if (error != Enums.GeneratorError.NONE) { return; } while ((tokenList.GetCurrentTokenType() == Enums.TokenType.multsym) || (tokenList.GetCurrentTokenType() == Enums.TokenType.slashsym)) { Enums.TokenType op = tokenList.GetCurrentTokenType(); tokenList.NextToken(); Factor(); if (error != Enums.GeneratorError.NONE) { return; } if (op == Enums.TokenType.multsym) { Emit((int)Enums.OpCode.MUL, currentRegister - 2, currentRegister - 2, currentRegister - 1); } else { Emit((int)Enums.OpCode.DIV, currentRegister - 2, currentRegister - 2, currentRegister - 1); } currentRegister--; } }
public JsonResult TokenValidate(string token = "", Enums.TokenType type = Enums.TokenType.Sorry, string email = "") { if (type == Enums.TokenType.Sorry) { return(null); } string _email = (type == Enums.TokenType.Email) ? SessionConfig.Email : email; Enums.TokenType t = (Enums.TokenType)(int) type; var ac = userService.TokenValidate(t, token, _email); if (type == Enums.TokenType.Email) { if (ac.ResponseCode == ResponseCode.Success) { SessionConfig.EmailConfirmed = true; } } else if (type == Enums.TokenType.ForgetPassword) { var repo = Mapper.Map <SessionModel>((UserBo)ac.Content); SessionConfig.Session = repo; } return(new JsonContractResult { Data = ac }); }
public Symbol() { type = Enums.TokenType.nulsym; scope = null; name = ""; value = 0; level = 0; address = 0; }
private void Expression() { if ((tokenList.GetCurrentTokenType() == Enums.TokenType.plussym) || (tokenList.GetCurrentTokenType() == Enums.TokenType.minussym)) { Enums.TokenType op = tokenList.GetCurrentTokenType(); tokenList.NextToken(); Term(); if (error != Enums.GeneratorError.NONE) { return; } if (op == Enums.TokenType.minussym) { Emit((int)Enums.OpCode.NEG, currentRegister - 1, currentRegister - 1, 0); } } else { Term(); if (error != Enums.GeneratorError.NONE) { return; } } while ((tokenList.GetCurrentTokenType() == Enums.TokenType.plussym) || (tokenList.GetCurrentTokenType() == Enums.TokenType.minussym)) { Enums.TokenType op = tokenList.GetCurrentTokenType(); tokenList.NextToken(); Term(); if (error != Enums.GeneratorError.NONE) { return; } if (op == Enums.TokenType.plussym) { Emit((int)Enums.OpCode.ADD, currentRegister - 2, currentRegister - 2, currentRegister - 1); } else { Emit((int)Enums.OpCode.SUB, currentRegister - 2, currentRegister - 2, currentRegister - 1); } currentRegister--; } }
public ActionDetails TokenValidate(Enums.TokenType type, string token, string email) { try { var res = dba.Users.Where(p => p.TokenType == (int)type && p.Email == email && p.Token == token).FirstOrDefault(); if (res == null) { return(ResponseMessage.Error("invalied token")); } else { if (type == Enums.TokenType.Email) { res.EmailConfirmed = true; dba.SaveChanges(); } } return(ResponseMessage.Success(content: Authenticate(email).Content)); } catch (Exception ex) { return(ResponseMessage.Error(ex)); } }
private void Condition() { if (tokenList.GetCurrentTokenType() == Enums.TokenType.oddsym) { tokenList.NextToken(); Expression(); if (error != Enums.GeneratorError.NONE) { return; } } else { Expression(); if (error != Enums.GeneratorError.NONE) { return; } Enums.TokenType currentTokenType = tokenList.GetCurrentTokenType(); tokenList.NextToken(); Expression(); if (error != Enums.GeneratorError.NONE) { return; } if (tokenList.GetCurrentTokenType() == Enums.TokenType.eqsym) { Emit((int)Enums.OpCode.EQL, currentRegister - 2, currentRegister - 2, currentRegister - 1); } else if (tokenList.GetCurrentTokenType() == Enums.TokenType.neqsym) { Emit((int)Enums.OpCode.NEQ, currentRegister - 2, currentRegister - 2, currentRegister - 1); } else if (tokenList.GetCurrentTokenType() == Enums.TokenType.lessym) { Emit((int)Enums.OpCode.LSS, currentRegister - 2, currentRegister - 2, currentRegister - 1); } else if (tokenList.GetCurrentTokenType() == Enums.TokenType.leqsym) { Emit((int)Enums.OpCode.LEQ, currentRegister - 2, currentRegister - 2, currentRegister - 1); } else if (tokenList.GetCurrentTokenType() == Enums.TokenType.gtrsym) { Emit((int)Enums.OpCode.GTR, currentRegister - 2, currentRegister - 2, currentRegister - 1); } else if (tokenList.GetCurrentTokenType() == Enums.TokenType.geqsym) { Emit((int)Enums.OpCode.GEQ, currentRegister - 2, currentRegister - 2, currentRegister - 1); } else { error = Enums.GeneratorError.RELATIONAL_OP_EXPECTED; return; } currentRegister--; } }
private void HandleSpecial() { Enums.TokenType id = Enums.TokenType.nulsym; char lookaheadSymbol = code[charIndex + 1]; if ((currentSymbol == '/') && (lookaheadSymbol == '*')) { while (true) { NextSymbol(); if (currentSymbol == '\0') { error = Enums.LexerError.COMMENT_NOT_CLOSED; return; } if (currentSymbol == '\n') { lineNum++; } lookaheadSymbol = code[charIndex + 1]; // Stop ignoring symbols when we reach the end of comment symbols */ if ((currentSymbol == '*') && (lookaheadSymbol == '/')) { break; } } // Skip the end of comment symbols */ NextSymbol(); NextSymbol(); return; } else if ((currentSymbol == '<') && (lookaheadSymbol == '>')) { id = Enums.TokenType.neqsym; NextSymbol(); } else if ((currentSymbol == '<') && (lookaheadSymbol == '=')) { id = Enums.TokenType.leqsym; NextSymbol(); } else if ((currentSymbol == '>') && (lookaheadSymbol == '=')) { id = Enums.TokenType.geqsym; NextSymbol(); } else if ((currentSymbol == ':') && (lookaheadSymbol == '=')) { id = Enums.TokenType.becomessym; NextSymbol(); } else { switch (currentSymbol) { case '+': id = Enums.TokenType.plussym; break; case '-': id = Enums.TokenType.minussym; break; case '*': id = Enums.TokenType.multsym; break; case '/': id = Enums.TokenType.slashsym; break; case '(': id = Enums.TokenType.lparentsym; break; case ')': id = Enums.TokenType.rparentsym; break; case '<': id = Enums.TokenType.lessym; break; case '>': id = Enums.TokenType.gtrsym; break; case '.': id = Enums.TokenType.periodsym; break; case ';': id = Enums.TokenType.semicolonsym; break; case ',': id = Enums.TokenType.commasym; break; case '=': id = Enums.TokenType.eqsym; break; } } NextSymbol(); Token newToken = new Token { id = id, lineNum = lineNum }; tokenList.Add(newToken); }
public Token() { id = Enums.TokenType.nulsym; lexeme = ""; lineNum = 0; }