internal LexemeEnumerator(LexemeSource <TToken> lexemeSource) { _lexemeSource = lexemeSource; _pointer = BufferSize - 1; _lexemeBuffer = new Lexeme <TToken> [BufferSize]; _operandBuffer = new int[BufferSize]; _bufferSize = BufferSize; Current = default; }
public virtual void Mount(LexemeSource <TToken> lexemeSource, ParserContext parserContext, Parser <TGrammar, TToken> parser) { _poolDictionary = _threadLocalPoolDictionary.Value; LexemeSource = lexemeSource; TextSource = lexemeSource.TextSource; ParserContext = parserContext; if (ParserContext != null) { ParserContext.ParserAutomataContext = this; } }
public LexerProcess(Lexer <TGrammar, TToken> lexer, LexemeSource <TToken> lexemeSource) { var textSource = lexemeSource.TextSource; var lexerContext = lexer.CreateContext(lexemeSource); if (textSource is StringTextSource stringTextSource) { _process = new LexerAutomata.SpanProcess(stringTextSource, lexer, lexerContext); } else { _process = new LexerAutomata.ReaderProcess(textSource, lexer, lexerContext); } }
public virtual void Dispose() { TextSource = null; LexemeSource = null; _poolDictionary = null; if (ParserContext == null) { return; } ParserContext.Dispose(); ParserContext.ParserAutomataContext = null; ParserContext = null; }
protected void RunCore <TContext>(LexemeSource <TToken> lexemeSource, TContext context) where TContext : AutomataContext { using var instructionReader = new LexemeStreamInstructionReader(lexemeSource); RunCore(instructionReader, context); }
private protected AutomataResult PartialRunCore <TContext>(LexemeSource <TToken> lexemeSource, TContext context) where TContext : AutomataContext { using var instructionReader = new LexemeStreamInstructionReader(lexemeSource); return(PartialRunCore(instructionReader, context)); }
public LexemeStreamInstructionReader(LexemeSource <TToken> lexemeSource) { _lexemeSource = lexemeSource; }
protected LexerContext(LexemeSource <TToken> lexemeSource) { LexemeSource = lexemeSource; }
public VisitorAutomataContext MountVisitorContext(Visitor visitor, ParserAutomata parserAutomata, LexemeSource <TToken> lexemeSource, ParserContext parserContext, Parser <TGrammar, TToken> parser) { var pool = GetVisitorContextPool(visitor.GetType()); VisitorAutomataContext context; lock (pool) context = pool.Count > 0 ? pool.Pop() : new VisitorAutomataContext(visitor, this, parserAutomata); context.Mount(lexemeSource, parserContext, parser); return(context); }
public SyntaxTreeAutomataContext MountSyntaxTreeContext(ParserAutomata parserAutomata, LexemeSource <TToken> lexemeSource, ParserContext parserContext, Parser <TGrammar, TToken> parser) { SyntaxTreeAutomataContext context; lock (SyntaxTreeContextPool) context = SyntaxTreeContextPool.Count > 0 ? SyntaxTreeContextPool.Pop() : new SyntaxTreeAutomataContext(this, parserAutomata); context.Mount(lexemeSource, parserContext, parser); return(context); }
public ProcessAutomataContext MountProcessContext(ParserAutomata parserAutomata, LexemeSource <TToken> lexemeSource, ParserContext parserContext, Parser <TGrammar, TToken> parser) { ProcessAutomataContext context; lock (ProcessContextPool) context = ProcessContextPool.Count > 0 ? ProcessContextPool.Pop() : new ProcessAutomataContext(this, parserAutomata); context.Mount(lexemeSource, parserContext, parser); return(context); }