private void DiscardToken() { _lookaheadFirst = _lookaheadSecond.Clone(); if (_tokenSequence.Any()) { _lookaheadSecond = _tokenSequence.Pop(); } else { _lookaheadSecond = new DslToken(TokenType.SequenceTerminator, string.Empty); } }
//private void EqualityMatchCondition() //{ // _currentFilterInstruction.Object = GetObject(_lookaheadFirst); // DiscardToken(); // _currentFilterInstruction.Operator = GetOperator(_lookaheadFirst); // DiscardToken(); // _currentFilterInstruction.Value = _lookaheadFirst.Value; // DiscardToken(); //} //private DslObject GetObject(DslToken token) //{ // switch (token.TokenType) // { // case TokenType.Application: // return DslObject.Application; // case TokenType.ExceptionType: // return DslObject.ExceptionType; // case TokenType.Fingerprint: // return DslObject.Fingerprint; // case TokenType.Message: // return DslObject.Message; // case TokenType.StackFrame: // return DslObject.StackFrame; // default: // throw new Exception(ExpectedObjectErrorText + token.Value); // } //} private Operation GetOperator(DslToken token) { switch (token.TokenType) { case TokenType.Equals: return(Operation.Equals); case TokenType.NotEquals: return(Operation.NotEquals); case TokenType.GreaterThan: return(Operation.GreaterThan); case TokenType.LessThan: return(Operation.LessThan); default: throw new Exception("Expected =, <>, >, < but found: " + token.Value); } }
private void PrepareLookaheads() { _lookaheadFirst = _tokenSequence.Pop(); _lookaheadSecond = _tokenSequence.Pop(); }
//private void ParseInCondition(DslOperator inOperator) //{ // _currentFilterInstruction.Operator = inOperator; // _currentFilterInstruction.Values = new List<string>(); // _currentFilterInstruction.Object = GetObject(_lookaheadFirst); // DiscardToken(); // if (inOperator == DslOperator.In) // DiscardToken(TokenType.In); // else if (inOperator == DslOperator.NotIn) // DiscardToken(TokenType.NotIn); // DiscardToken(TokenType.OpenParenthesis); // StringLiteralList(); // DiscardToken(TokenType.CloseParenthesis); //} //private void StringLiteralList() //{ // _currentFilterInstruction.Values.Add(ReadToken(TokenType.StringValue).Value); // DiscardToken(TokenType.StringValue); // StringLiteralListNext(); //} //private void StringLiteralListNext() //{ // if (_lookaheadFirst.TokenType == TokenType.Comma) // { // DiscardToken(TokenType.Comma); // _currentFilterInstruction.Values.Add(ReadToken(TokenType.StringValue).Value); // DiscardToken(TokenType.StringValue); // StringLiteralListNext(); // } // else // { // // nothing // } //} //private void MatchConditionNext() //{ // if (_lookaheadFirst.TokenType == TokenType.And) // { // AndMatchCondition(); // } // else if (_lookaheadFirst.TokenType == TokenType.Or) // { // OrMatchCondition(); // } // else if (_lookaheadFirst.TokenType == TokenType.Between) // { // DateCondition(); // } // else // { // throw new Exception("Expected AND, OR or BETWEEN but found: " + _lookaheadFirst.Value); // } //} //private void AndMatchCondition() //{ // _currentFilterInstruction.LogOpToNextCondition = DslLogicalOperator.And; // DiscardToken(TokenType.And); // MatchCondition(); //} //private void OrMatchCondition() //{ // _currentFilterInstruction.LogOpToNextCondition = DslLogicalOperator.Or; // DiscardToken(TokenType.Or); // MatchCondition(); //} //private void DateCondition() //{ // DiscardToken(TokenType.Between); // _queryModel.DateRange = new DateRange(); // _queryModel.DateRange.From = DateTime.ParseExact(ReadToken(TokenType.DateTimeValue).Value, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture); // DiscardToken(TokenType.DateTimeValue); // DiscardToken(TokenType.And); // _queryModel.DateRange.To = DateTime.ParseExact(ReadToken(TokenType.DateTimeValue).Value, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture); // DiscardToken(TokenType.DateTimeValue); // DateConditionNext(); //} //private void DateConditionNext() //{ // if (_lookaheadFirst.TokenType == TokenType.Limit) // { // Limit(); // } // else if (_lookaheadFirst.TokenType == TokenType.SequenceTerminator) // { // // nothing // } // else // { // throw new Exception("Expected LIMIT or the end of the query but found: " + _lookaheadFirst.Value); // } //} //private void Limit() //{ // DiscardToken(TokenType.Limit); // int limit = 0; // bool success = int.TryParse(ReadToken(TokenType.Number).Value, out limit); // if (success) // _queryModel.Limit = limit; // else // throw new Exception("Expected an integer number but found " + ReadToken(TokenType.Number).Value); // DiscardToken(TokenType.Number); //} private bool IsVarName(DslToken token) { return(token.TokenType == TokenType.VarName); }