Example #1
0
        private void HandleFlowSourceSpec(FlowSourceSpec flowSourceSpec)
        {
            flowSourceSpec.PreIdentifier = ConsumeType(TokenTypes.Identifier);
            ConsumeType(TokenTypes.SingleColon);
            ConsumeType(TokenTypes.Flow);
            Consume();

            flowSourceSpec.Identifier   = ConsumeType(TokenTypes.Identifier);
            flowSourceSpec.Associations = TryHandleAssociationBlock();
        }
Example #2
0
        private FlowSpec HandleFlows()
        {
            if (!ThisToken().Match(TokenTypes.Flows))
            {
                return(new NoneFlowSpec
                {
                    BeginPosition = ThisToken().TokenBeginIdx,
                    EndPosition = ThisToken().TokenBeginIdx
                });
            }

            Consume();
            FlowSpec spec = null;

            TryParseAndResumeToToken(() =>
            {
                if (ThisToken().Match(TokenTypes.None))
                {
                    spec = new NoneFlowSpec
                    {
                        BeginPosition = ThisToken().TokenBeginIdx
                    };
                    Consume();
                    return;
                }

                switch (LookAhead(3).TokenType)
                {
                case TokenTypes.Source:
                    var flowSourceSpec = new FlowSourceSpec
                    {
                        BeginPosition = ThisToken().TokenBeginIdx
                    };
                    spec = flowSourceSpec;
                    HandleFlowSourceSpec(flowSourceSpec);
                    break;

                case TokenTypes.Sink:
                    var flowSinkSpec = new FlowSinkSpec
                    {
                        BeginPosition = ThisToken().TokenBeginIdx
                    };
                    spec = flowSinkSpec;
                    HandleFlowSinkSpec(flowSinkSpec);
                    break;

                case TokenTypes.Path:
                    var flowPathSpec = new FlowPathSpec
                    {
                        BeginPosition = ThisToken().TokenBeginIdx
                    };
                    spec = flowPathSpec;
                    HandleFlowPathSpec(flowPathSpec);
                    break;

                default:
                    throw Error(new GrammarException("Expect source, sink or path", LookAhead(3), null));
                }
            }, TokenTypes.Semicolon);

            var token = ConsumeType(TokenTypes.Semicolon);

            if (spec != null)
            {
                spec.EndPosition = token.TokenEndIdx;
            }

            return(spec);
        }