public bool RunGenerator(string text) { bool result = true; inputStream = new StringReader(text); contextManager.PushContext(new PonyLexerContext(0, literalRecognizer)); while (inputStream.Peek() != -1 && !contextManager.IsEmpty() && result && !isHalted) { PonyLexerContext context = contextManager.CurrentContext; result = context.DFAHandler.Invoke(context.CurrentState); } result = result && !isHalted; if (!result || contextManager.IsEmpty()) { errorListener?.OnLexerErrorReported("Lexer terminated unexpected", string.Empty, col, row); } return(result); }
public void PopContext() { contextStack.Pop(); CurrentContext = contextStack.Peek(); }
public void SwitchContext(PonyLexerContext newContext) { contextStack.Pop(); contextStack.Push(newContext); CurrentContext = newContext; }
public void PushContext(PonyLexerContext newContext) { CurrentContext = newContext; contextStack.Push(newContext); }