Exemple #1
0
        private void DiscardToken()
        {
            _lookaheadFirst = _lookaheadSecond.Clone();

            if (_tokenSequence.Any())
            {
                _lookaheadSecond = _tokenSequence.Pop();
            }
            else
            {
                _lookaheadSecond = new DslToken(TokenType.SequenceTerminator, string.Empty);
            }
        }
Exemple #2
0
        public override ParseState Parse(DslToken token)
        {
            switch (token.TokenType)
            {
            case TokenType.DomainClass:
                return(DomainClassIdentifierFound());

            case TokenType.Value:
                return(ValueFound(token));

            default:
                throw new NoTransitionException(token);
            }
        }
Exemple #3
0
        public override ParseState Parse(DslToken token)
        {
            switch (token.TokenType)
            {
            case TokenType.SynchronouslyToken:
                return(SynchronousDomainHookFound());

            case TokenType.AsynchronouslyToken:
                return(AsyncDomainHookFound());

            default:
                throw new NoTransitionException(token);
            }
        }
Exemple #4
0
        public override ParseState Parse(DslToken token)
        {
            switch (token.TokenType)
            {
            case TokenType.ObjectBracketClose:
                return(EventDefinitionEndFound());

            case TokenType.Value:
                return(PropertyNameFound(token));

            default:
                throw new NoTransitionException(token);
            }
        }
Exemple #5
0
        public override ParseState Parse(DslToken token)
        {
            switch (token.TokenType)
            {
            case TokenType.Value:
                return(MethodParamTypeFound(token));

            case TokenType.LoadToken:
                return(LoadTypeFound());

            default:
                throw new NoTransitionException(token);
            }
        }
Exemple #6
0
        public override ParseState Parse(DslToken token)
        {
            switch (token.TokenType)
            {
            case TokenType.Value:
                return(PropertyTypeDefFound(token));

            case TokenType.ListBracketOpen:
                return(ListPropertyFound());

            default:
                throw new NoTransitionException(token);
            }
        }
Exemple #7
0
        public override ParseState Parse(DslToken token)
        {
            switch (token.TokenType)
            {
            case TokenType.ParamSeparator:
                return(AdditionalParamStateFound());

            case TokenType.ParameterBracketClose:
                return(MethodParamClosedStateFound());

            default:
                throw new NoTransitionException(token);
            }
        }
Exemple #8
0
        private bool IsOperator(DslToken token)
        {
            var tt = token.TokenType;

            return(tt == TokenType.Add ||
                   tt == TokenType.Subtract ||
                   tt == TokenType.Multiply ||
                   tt == TokenType.Divide ||
                   tt == TokenType.Equals ||
                   tt == TokenType.NotEquals ||
                   tt == TokenType.In ||
                   tt == TokenType.NotIn ||
                   tt == TokenType.Assign);
        }
Exemple #9
0
        public override ParseState Parse(DslToken token)
        {
            switch (token.TokenType)
            {
            case TokenType.ParameterBracketClose:
                return(CreateMethodParamsFinished());

            case TokenType.Value:
                return(ParamCreateMethodStarted(token));

            default:
                throw new NoTransitionException(token);
            }
        }
Exemple #10
0
        private ParseState AsyncDomainHookEventFound(DslToken token)
        {
            var strings = token.Value.Split(".");

            MicrowaveLanguageParser.CurrentAsyncDomainHook.ClassType  = strings[0];
            MicrowaveLanguageParser.CurrentAsyncDomainHook.MethodName = strings[1];

            if (strings[1] == "Create")
            {
                MicrowaveLanguageParser.CurrentAsyncDomainHook.IsCreateHook = true;
            }

            MicrowaveLanguageParser.AsyncDomainHooks.Add(MicrowaveLanguageParser.CurrentAsyncDomainHook);

            return(new StartState(MicrowaveLanguageParser));
        }
Exemple #11
0
 private void PrepareLookaheads()
 {
     if (_tokenSequence.Count == 0)
     {
         _lookaheadFirst = new DslToken(TokenType.EOF, string.Empty, 0);
         return;
     }
     _lookaheadFirst = _tokenSequence.Pop();
     if (_tokenSequence.Count > 0)
     {
         _lookaheadSecond = _tokenSequence.Pop();
     }
     else
     {
         _lookaheadSecond = new DslToken(TokenType.EOF, string.Empty, _lookaheadFirst.Line);
     }
 }
Exemple #12
0
        public override ParseState Parse(DslToken token)
        {
            switch (token.TokenType)
            {
            case TokenType.CreateMethod:
                return(CreateMethodFound());

            case TokenType.ObjectBracketClose:
                return(DomainClassClosed());

            case TokenType.Value:
                return(MemberStarted(token));

            default:
                throw new NoTransitionException(token);
            }
        }
Exemple #13
0
        public override ParseState Parse(DslToken token)
        {
            switch (token.TokenType)
            {
            case TokenType.TypeDefSeparator:
                return(PropertySeparatorFound());

            case TokenType.ParameterBracketOpen:
                return(MethodParamOpenFound());

            case TokenType.OnChild:
                return(OnChildFound());

            default:
                throw new NoTransitionException(token);
            }
        }
Exemple #14
0
        private DslOperator GetOperator(DslToken token)
        {
            switch (token.TokenType)
            {
            case TokenType.Equals:
                return(DslOperator.Equals);

            case TokenType.NotEquals:
                return(DslOperator.NotEquals);

            case TokenType.Like:
                return(DslOperator.Like);

            case TokenType.NotLike:
                return(DslOperator.NotLike);

            case TokenType.In:
                return(DslOperator.In);

            case TokenType.NotIn:
                return(DslOperator.NotIn);

            case TokenType.GreaterThan:
                return(DslOperator.Greater);

            case TokenType.GreaterOrEqual:
                return(DslOperator.GreaterOrEqual);

            case TokenType.LowerThan:
                return(DslOperator.Lower);

            case TokenType.LowerOrEqual:
                return(DslOperator.LowerOrEqual);

            case TokenType.Is:
                return(DslOperator.Is);

            case TokenType.Function:
                return(DslOperator.Function);

            default:
                throw new DslParserException("Expected =, !=, <>, >, >=, <, <=, LIKE, IN, IS, a Function Call but found: " + token.Value);
            }
        }
        get_production(short conflict_number,
                       DslToken tokens)
        {
            short entry = 0;
            int   index, level;

            if (conflict_number <= TOTAL_CONFLICTS)
            {
                entry = (short)(conflict_number + (START_CONFLICT - 1));
                level = 1;
                while (entry >= START_CONFLICT)
                {
                    index  = Conflict_row [entry - (START_CONFLICT - 1)];
                    index += tokens.peek(level);
                    entry  = Conflict [index];
                    ++level;
                }
            }

            return(entry);
        }
Exemple #16
0
        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 DslParserException(ExpectedObjectErrorText + token.Value);
            }
        }
Exemple #17
0
        private IExpression ReadMemberAccess(
            Predicate <TokenMarker> terminatingPredicate,
            DslToken token,
            Stack <IExpression> previousExpressions)
        {
            Reader.DiscardToken();
            var left   = previousExpressions.Pop();
            var member = new MemberExpression(left);

            //expArray.Object = left;
            var currentCursor = Reader.Marker.Clone();
            var isKeyword     = Filters.Keyword(currentCursor);
            var isTerminating = Filters.ExpressionTermination(currentCursor);
            Predicate <TokenMarker> isComma = x =>
                                              x.Depth == currentCursor.Depth && x.Token.TokenType == TokenType.Comma;
            var valueExpression = ReadExpressions((c) =>
            {
                return(isKeyword(c) || isTerminating(c) || isComma(c));
            }).FirstOrDefault();

            member.ChildMember = valueExpression;
            return(member
                   );
        }
Exemple #18
0
 private void PrepareLookaheads()
 {
     _lookaheadFirst  = _tokenSequence.Pop();
     _lookaheadSecond = _tokenSequence.Pop();
 }
Exemple #19
0
 private bool IsInverter(DslToken token)
 {
     return(token.TokenType == TokenType.Invert);
 }
Exemple #20
0
 private ParseState MethodParamTypeFound(DslToken token)
 {
     MicrowaveLanguageParser.CurrentParam.Type = token.Value;
     MicrowaveLanguageParser.CurrentMethod.LoadParameters.Add(MicrowaveLanguageParser.CurrentParam);
     return(new MethodSingleParamFinishedState(MicrowaveLanguageParser));
 }
        parse(DslAction action,
              DslToken tokens,
              DslError error,
              short start_symbol)
        {
            short lhs;
            short production_number, entry, symbol, token, new_token;
            int   production_length, top, index, level;

            short[] stack = new short[512];

            top         = 511;
            stack [top] = 0;
            if (start_symbol == 0)
            {
                start_symbol = START_SYMBOL;
            }
            if (top > 0)
            {
                stack [--top] = start_symbol;
            }
            else
            {
                error.message("DslParse: stack overflow\n"); return;
            }
            token     = tokens.get();
            new_token = token;

            for (symbol = (stack[top] != 0  ? stack[top++] : (short)0); symbol != 0;)
            {
                if (symbol >= START_ACTION)
                {
                    action.execute(symbol - (START_ACTION - 1));
                }
                else if (symbol >= START_SYMBOL)
                {
                    entry             = 0;
                    level             = 1;
                    production_number = get_conditional_production(symbol);
                    if (production_number != 0)
                    {
                        entry = get_predicted_entry(tokens,
                                                    production_number, token,
                                                    level, 1);
                    }
                    if (entry == 0)
                    {
                        index  = Parse_row [symbol - (START_SYMBOL - 1)];
                        index += token;
                        entry  = Parse [index];
                    }
                    while (entry >= START_CONFLICT)
                    {
                        index  = Conflict_row [entry - (START_CONFLICT - 1)];
                        index += tokens.peek(level);
                        entry  = Conflict [index];
                        ++level;
                    }
                    if (entry != 0)
                    {
                        index             = Production_row [entry];
                        production_length = Production [index] - 1;
                        lhs = Production [++index];
                        if (lhs == symbol)
                        {
                            action.predict(entry);
                            index += production_length;
                            for (; production_length-- > 0; --index)
                            {
                                if (top > 0)
                                {
                                    stack [--top] = Production [index];
                                }
                                else
                                {
                                    error.message("DslParse: stack overflow\n"); return;
                                }
                            }
                        }
                        else
                        {
                            new_token = error.no_entry(symbol, token, level - 1);
                        }
                    }
                    else                                // no table entry
                    {
                        new_token = error.no_entry(symbol, token, level - 1);
                    }
                }
                else if (symbol > 0)
                {
                    if (symbol == token)
                    {
                        token     = tokens.get();
                        new_token = token;
                    }
                    else
                    {
                        new_token = error.mismatch(symbol, token);
                    }
                }
                else
                {
                    error.message("\n parser error: symbol value 0\n");
                }

                if (token != new_token)
                {
                    if (new_token != 0)
                    {
                        token = new_token;
                    }
                    if (token != END_OF_SLK_INPUT_)
                    {
                        continue;
                    }
                }

                symbol = (stack[top] != 0  ? stack[top++] : (short)0);
            }

            if (token != END_OF_SLK_INPUT_)
            {
                error.input_left();
            }
        }
Exemple #22
0
 private static short get_predicted_entry( DslToken   tokens,
               short      production_number,
               short      token,
               int        scan_level,
               int        depth )
 {
     return  0;
 }
Exemple #23
0
 public ExpressionNode(DslToken token)
     : this()
 {
     this.Token = token;
 }
Exemple #24
0
 internal DslError(DslToken tokens)
 {
     this.tokens = tokens;
 }
Exemple #25
0
        internal static short get_production( short     conflict_number,
                 DslToken  tokens )
        {
            short   entry = 0;
            int     index, level;

            if ( conflict_number <= TOTAL_CONFLICTS ) {
            entry = (short) ( conflict_number + (START_CONFLICT - 1) );
            level = 1;
            while ( entry >= START_CONFLICT ) {
            index = Conflict_row [entry - (START_CONFLICT -1)];
            index += tokens.peek ( level );
            entry = Conflict [ index ];
            ++level;
            }
            }

            return  entry;
        }
Exemple #26
0
 private ParseState EventPropertyTypeFound(DslToken token)
 {
     MicrowaveLanguageParser.CurrentProperty.Type = token.Value;
     MicrowaveLanguageParser.CurrentEvent.Properties.Add(MicrowaveLanguageParser.CurrentProperty);
     return(new EventDefinitionFoundState(MicrowaveLanguageParser));
 }
Exemple #27
0
 public UnaryExpression(DslToken token)
 {
     this.Token = token;
 }
Exemple #28
0
 private ParseState ParamCreateMethodTypeFound(DslToken token)
 {
     MicrowaveLanguageParser.CurrentParam.Type = token.Value;
     MicrowaveLanguageParser.CurrentCreateMethod.Parameters.Add(MicrowaveLanguageParser.CurrentParam);
     return(new PropertyCreateMethodTypeFoundState(MicrowaveLanguageParser));
 }
Exemple #29
0
        internal static void parse( DslAction   action,
        DslToken    tokens,
        DslError    error,
        short       start_symbol )
        {
            short     rhs, lhs;
             short     production_number, entry, symbol, token, new_token;
             int       production_length, top, index, level;
             short[]   stack = new short[512];

             top = 511;
             stack [ top ] = 0;
             if ( start_symbol == 0 ) {
             start_symbol = START_SYMBOL;
             }
             if ( top > 0 ) { stack [--top] = start_symbol;
             } else { error.message ("DslParse: stack overflow\n"); return; }
             token = tokens.get();
             new_token = token;

             for ( symbol = (stack[top] != 0  ? stack[top++] : (short) 0);  symbol != 0; ) {

             if ( symbol >= START_ACTION ) {
             action.execute ( symbol - (START_ACTION-1) );

             } else if ( symbol >= START_SYMBOL ) {
             entry = 0;
             level = 1;
             production_number = get_conditional_production ( symbol );
             if ( production_number != 0 ) {
             entry = get_predicted_entry ( tokens,
                                           production_number, token,
                                           level, 1 );
             }
             if ( entry == 0 ) {
             index = Parse_row [ symbol - (START_SYMBOL-1) ];
             index += token;
             entry = Parse [ index ];
             }
             while ( entry >= START_CONFLICT ) {
             index = Conflict_row [entry - (START_CONFLICT -1)];
             index += tokens.peek (level);
             entry = Conflict [ index ];
             ++level;
             }
             if ( entry != 0 ) {
             index = Production_row [ entry ];
             production_length = Production [ index ] - 1;
             lhs = Production [ ++index ];
             if ( lhs == symbol ) {
                 action.predict ( entry );
                 index += production_length;
                 for (;  production_length-- > 0;  --index ) {
                     if ( top > 0 ) { stack [--top] = Production [index];
                     } else { error.message ("DslParse: stack overflow\n"); return; }
                 }
             } else {
                 new_token = error.no_entry ( symbol, token, level-1 );
             }
             } else {                                       // no table entry
             new_token = error.no_entry ( symbol, token, level-1 );
             }
             } else if ( symbol > 0 ) {
             if ( symbol == token ) {
             token = tokens.get();
             new_token = token;
             } else {
             new_token = error.mismatch ( symbol, token );
             }
             } else {
             error.message ( "\n parser error: symbol value 0\n" );
             }
             if ( token != new_token ) {
             if ( new_token != 0 ) {
             token = new_token;
             }
             if ( token != END_OF_SLK_INPUT_ ) {
             continue;
             }
             }
             symbol = (stack[top] != 0  ? stack[top++] : (short) 0);
             }
             if ( token != END_OF_SLK_INPUT_ ) {
             error.input_left ();
             }
        }
Exemple #30
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="strReader"></param>
        /// <returns></returns>
        public IEnumerable <DslToken> Tokenize(StringReader strReader, ref int cReadTokens)
        {
            var tokenMatches = FindTokenMatches(strReader).ToList();
            var definitions  = tokenMatches.GroupBy(x => new TokenPosition(x.Line, (uint)x.StartIndex),
                                                    new TokenPositionComparer())
                               .OrderBy(x => x.Key.Line)
                               .ThenBy(x => x.Key.Position)
                               .ToList();

            TokenMatch lastMatch   = null;
            var        output      = new Stack <DslToken>();
            bool       isSubstring = false;

            Data.DataIntegration matchedIntegration = null;
            for (int i = 0; i < definitions.Count; i++)
            {
                var orderedEnumerable = definitions[i].OrderBy(x => x.Precedence);
                var bestMatch         = orderedEnumerable.First();
                Data.DataIntegration tokensTargetDataset = null;
                if (lastMatch != null && bestMatch.StartIndex < lastMatch.EndIndex &&
                    bestMatch.Line == lastMatch.Line)
                {
                    //Validate if it's ok for the last expression to contain the current one;
                    var isValid = HandleExpressionSubstring(lastMatch, bestMatch, out tokensTargetDataset);
                    isSubstring = true;
                    if (!isValid)
                    {
                        continue;
                    }
                }

                if (bestMatch.TokenType == TokenType.DatasetTime)
                {
                    if (isSubstring)
                    {
                        if (tokensTargetDataset == null)
                        {
                            throw new Exception("Target DataSet not found!");
                        }
                        var timeTokens = ConstructTimeTokens(tokensTargetDataset, bestMatch.Line, bestMatch.StartIndex, i, output);
                        foreach (var tt in timeTokens)
                        {
                            output.Push(tt);
                        }
                        continue;
                    }
                    else
                    {
                        var timeTokens = ConstructTimeTokens(_currentIntegration, bestMatch.Line, bestMatch.StartIndex, i, output);
                        foreach (var tt in timeTokens)
                        {
                            output.Push(tt);
                        }
                        i += 1;
                        continue;
                    }
                }
                if (bestMatch.TokenType == TokenType.First)
                {
                    var nextBestMatch = ((definitions.Count - 1) == i) ? null : definitions[i + 1];
                    if (nextBestMatch != null)
                    {
                        var nextTokens = definitions.Skip(i + 2).Select(x => x.FirstOrDefault()).ToList();
                        var expValue   = GetParameterSymbol(bestMatch, nextBestMatch, nextTokens, out matchedIntegration, ref cReadTokens);
                        i += cReadTokens;
                        _currentIntegration = matchedIntegration;
                        if (String.IsNullOrEmpty(expValue))
                        {
                            continue;
                        }
                        //Get the subtoken
                        int iReadTokens = 0;
                        var subTokens   = ConstructFirstElementTokens(bestMatch, expValue, ref iReadTokens);
                        if (subTokens == null || subTokens.Count() == 0)
                        {
                            continue;
                        }
                        foreach (var tt in subTokens)
                        {
                            output.Push(tt);
                        }
                        //We skip the subtokens, so that we can continue.
                        i += iReadTokens;
                        continue;
                    }
                    else
                    {
                        continue;
                    }
                }


                var token = new DslToken(bestMatch.TokenType, bestMatch.Value, bestMatch.Line)
                {
                    Position = (uint)bestMatch.StartIndex
                };
                output.Push(token);
                //yield return token;

                lastMatch = bestMatch;
            }
            cReadTokens = definitions.Count;
            return(output.Reverse());
        }
Exemple #31
0
 private ParseState ValueFound(DslToken token)
 {
     MicrowaveLanguageParser.CurrentFoundValue = token.Value;
     return(new ValueFoundState(MicrowaveLanguageParser));
 }
Exemple #32
0
 private ParseState ListPropertyTypeFound(DslToken token)
 {
     MicrowaveLanguageParser.CurrentListProperty.Type = token.Value;
     return(new ListPropertyTypeFoundState(MicrowaveLanguageParser));
 }
Exemple #33
0
 public abstract ParseState Parse(DslToken token);