Parser.Expect C# (CSharp) Méthode

Expect() public méthode

public Expect ( int n ) : void
n int
Résultat void
    void Expect(int n)
    {
        if (la.kind==n) Get(); else { SynErr(n); }
    }

Usage Example

Exemple #1
0
        public override Statement ParseNoNewContext(Parser parser)
        {
            var result   = new IfStatement();
            var labelled = parser.Labels(result);

            // Consume the if keyword.
            parser.Expect(KeywordToken.If);

            // Read the left parenthesis.
            parser.Expect(PunctuatorToken.LeftParenthesis);

            // Parse the condition.
            result.Condition = parser.ParseExpression(PunctuatorToken.RightParenthesis);

            // Read the right parenthesis.
            parser.Expect(PunctuatorToken.RightParenthesis);

            // Read the statements that will be executed when the condition is true.
            result.IfClause = parser.ParseStatement();

            // Optionally, read the else statement.
            if (parser.nextToken == KeywordToken.Else)
            {
                // Consume the else keyword.
                parser.Consume();

                // Read the statements that will be executed when the condition is false.
                result.ElseClause = parser.ParseStatement();
            }

            return(labelled);
        }
All Usage Examples Of Parser::Expect