/////////////////////////////////////////////////////////////////////////////////////////////////////
        // OBJECT
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <c>ParentLexer</c> class.
        /// </summary>
        /// <param name="childLanguage">The child language.</param>
        public ParentLexer(ISyntaxLanguage childLanguage)
        {
            // Initialize lexical states
            lexicalStates = new LexicalStateCollection(this);

            ProgrammaticLexicalState defaultState = new ProgrammaticLexicalState(ParentLexicalStateId.Default, "Default");

            lexicalStates.Add(defaultState);
            this.DefaultLexicalStateCore = defaultState;

            ProgrammaticLexicalState childOutputBlockTransitionState = new ProgrammaticLexicalState(ParentLexicalStateId.ChildOutputBlock, "Child output block transition");

            childOutputBlockTransitionState.LexicalScopes.Add(new ProgrammaticLexicalScope(new ProgrammaticLexicalScopeMatch(this.IsChildOutputBlockTransitionStateScopeStart),
                                                                                           new ProgrammaticLexicalScopeMatch(this.IsChildOutputBlockTransitionStateScopeEnd)));
            lexicalStates.Add(childOutputBlockTransitionState);
            defaultState.ChildLexicalStates.Add(childOutputBlockTransitionState);

            ProgrammaticLexicalState childCodeBlockTransitionState = new ProgrammaticLexicalState(ParentLexicalStateId.ChildCodeBlock, "Child code block transition");

            childCodeBlockTransitionState.LexicalScopes.Add(new ProgrammaticLexicalScope(new ProgrammaticLexicalScopeMatch(this.IsChildCodeBlockTransitionStateScopeStart),
                                                                                         new ProgrammaticLexicalScopeMatch(this.IsChildCodeBlockTransitionStateScopeEnd)));
            lexicalStates.Add(childCodeBlockTransitionState);
            defaultState.ChildLexicalStates.Add(childCodeBlockTransitionState);

            IMergableLexer lexer = childLanguage.GetLexer() as IMergableLexer;

            if (lexer != null)
            {
                childOutputBlockTransitionState.Transition = new LexicalStateTransition(childLanguage, lexer.DefaultLexicalState, null);
                childCodeBlockTransitionState.Transition   = new LexicalStateTransition(childLanguage, lexer.DefaultLexicalState, null);
            }
        }
Exemple #2
0
 public JsonTokenReader(ITextBufferReader reader, IMergableLexer rootLexer) : base(reader, rootLexer)
 {
 }
        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // OBJECT
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <c>SimpleTokenReader</c> class.
        /// </summary>
        /// <param name="reader">The <see cref="ITextBufferReader"/> to use for consuming text.</param>
        /// <param name="rootLexer">The root <see cref="IMergableLexer"/>.</param>
        public SimpleTokenReader(ITextBufferReader reader, IMergableLexer rootLexer) : base(reader, rootLexer)
        {
        }