CreateErrorToken() public method

public CreateErrorToken ( string message ) : Token
message string
return Token
Exemplo n.º 1
0
        }//method

        //Scans the source text and constructs a new token
        private void ScanToken()
        {
            if (!MatchNonGrammarTerminals() && !MatchRegularTerminals())
            {
                //we are in error already; try to match ANY terminal and let the parser report an error
                MatchAllTerminals(); //try to match any terminal out there
            }
            var token = Context.CurrentToken;

            //If we have normal token then return it
            if (token != null && !token.IsError())
            {
                //set position to point after the result token
                SourceStream.PreviewPosition = SourceStream.Location.Position + token.Length;
                SourceStream.MoveLocationToPreviewPosition();
                return;
            }
            //we have an error: either error token or no token at all
            if (token == null) //if no token then create error token
            {
                Context.CurrentToken = SourceStream.CreateErrorToken(Resources.ErrInvalidChar, SourceStream.PreviewChar);
            }
            Recover();
        }