Antlr.Runtime.Lexer.Match C# (CSharp) Method

Match() public method

public Match ( int c ) : void
c int
return void
        public virtual void Match( int c )
        {
            if ( input.LA( 1 ) != c )
            {
                if ( state.backtracking > 0 )
                {
                    state.failed = true;
                    return;
                }
                MismatchedTokenException mte = new MismatchedTokenException(c, input, TokenNames);
                Recover( mte );  // don't really recover; just consume in lexer
                throw mte;
            }
            input.Consume();
            state.failed = false;
        }

Same methods

Lexer::Match ( string s ) : void

Usage Example

        public AddsAntlr3Runtime()
        {
            _treeAdaptor = new CommonTreeAdaptor();
            _treeAdaptor.SetTokenBoundaries(new object(), _token, _token);
            _treeAdaptor.RulePostProcessing(new object());
            _treeAdaptor.Nil();
            _treeAdaptor.AddChild(new object(), new object());
            _treeAdaptor.Create(_token);

            _parser.TraceIn("", 0);
            _parser.TraceOut("", 0);

            _lexer.TraceOut("", 0);
            _lexer.TraceIn("", 0);
            _lexer.Recover(new Antlr.Runtime.RecognitionException(""));
            _lexer.MatchAny();
            _lexer.Match("");
            _lexer.Match(0);

            _tokenStream.LT(0);
            _tokenStream.Get(0);
            _intStream.LA(0);
            _intStream.Consume();
            _charStream.LT(0);
            _dfa.Predict(_intStream);
            _dfa.Error(new Antlr.Runtime.NoViableAltException(""));
        }