Ejemplo n.º 1
0
        private void HandleFlowSinkSpec(FlowSinkSpec flowSinkSpec)
        {
            flowSinkSpec.PreIdentifier = ConsumeType(TokenTypes.Identifier);
            ConsumeType(TokenTypes.SingleColon);
            ConsumeType(TokenTypes.Flow);
            Consume();

            flowSinkSpec.Identifier   = ConsumeType(TokenTypes.Identifier);
            flowSinkSpec.Associations = TryHandleAssociationBlock();
        }
Ejemplo n.º 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);
        }