Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
 public void PopContext()
 {
     contextStack.Pop();
     CurrentContext = contextStack.Peek();
 }
Ejemplo n.º 3
0
 public void SwitchContext(PonyLexerContext newContext)
 {
     contextStack.Pop();
     contextStack.Push(newContext);
     CurrentContext = newContext;
 }
Ejemplo n.º 4
0
 public void PushContext(PonyLexerContext newContext)
 {
     CurrentContext = newContext;
     contextStack.Push(newContext);
 }