NextSymbolsAre() 개인적인 메소드

private NextSymbolsAre ( ) : bool
리턴 bool
예제 #1
0
 internal static bool CanParse(Parser p)
 {
     return p.NextSymbolsAre (TokenType.BeginCommand, TokenType.If);
 }
예제 #2
0
 internal static bool CanParse(Parser p)
 {
     return p.NextSymbolsAre (TokenType.BeginCommand, TokenType.Text) ||
         p.NextSymbolsAre (TokenType.BeginCommand, TokenType.Identifier);
 }
예제 #3
0
            internal IfStatement(ParseNode parent, Parser p)
                : base(parent, p)
            {
                // All if statements begin with "<<if EXPRESSION>>", so parse that
                Clause primaryClause = new Clause();

                p.ExpectSymbol(TokenType.BeginCommand);
                p.ExpectSymbol(TokenType.If);
                primaryClause.expression = Expression.Parse(this, p);
                p.ExpectSymbol(TokenType.EndCommand);

                // Read the statements for this clause until  we hit an <<endif or <<else
                // (which could be an "<<else>>" or an "<<else if"
                var statements = new List<Statement>();
                while (p.NextSymbolsAre(TokenType.BeginCommand, TokenType.EndIf) == false &&
                    p.NextSymbolsAre(TokenType.BeginCommand, TokenType.Else) == false &&
                    p.NextSymbolsAre(TokenType.BeginCommand, TokenType.ElseIf) == false) {
                    statements.Add(new Statement(this, p));

                    // Ignore any dedents
                    while (p.NextSymbolIs(TokenType.Dedent)) {
                        p.ExpectSymbol(TokenType.Dedent);
                    }
                }
                primaryClause.statements = statements;

                clauses.Add(primaryClause);

                // Handle as many <<elseif clauses as we find
                while (p.NextSymbolsAre(TokenType.BeginCommand, TokenType.ElseIf)) {
                    var elseIfClause = new Clause();

                    // Parse the syntax for this clause's condition
                    p.ExpectSymbol(TokenType.BeginCommand);
                    p.ExpectSymbol(TokenType.ElseIf);
                    elseIfClause.expression = Expression.Parse(this, p);
                    p.ExpectSymbol(TokenType.EndCommand);

                    // Read statements until we hit an <<endif, <<else or another <<elseif
                    var clauseStatements = new List<Statement>();
                    while (p.NextSymbolsAre(TokenType.BeginCommand, TokenType.EndIf) == false &&
                        p.NextSymbolsAre(TokenType.BeginCommand, TokenType.Else) == false &&
                        p.NextSymbolsAre(TokenType.BeginCommand, TokenType.ElseIf) == false) {
                        clauseStatements.Add(new Statement(this, p));

                        // Ignore any dedents
                        while (p.NextSymbolIs(TokenType.Dedent)) {
                            p.ExpectSymbol(TokenType.Dedent);
                        }

                    }

                    elseIfClause.statements = clauseStatements;

                    clauses.Add(elseIfClause);
                }

                // Handle <<else>> if we have it
                if (p.NextSymbolsAre(TokenType.BeginCommand, TokenType.Else, TokenType.EndCommand)) {

                    // parse the syntax (no expression this time, just "<<else>>"
                    p.ExpectSymbol(TokenType.BeginCommand);
                    p.ExpectSymbol(TokenType.Else);
                    p.ExpectSymbol(TokenType.EndCommand);

                    // and parse statements until we hit "<<endif"
                    var elseClause = new Clause();
                    var clauseStatements = new List<Statement>();
                    while (p.NextSymbolsAre(TokenType.BeginCommand, TokenType.EndIf) == false) {
                        clauseStatements.Add(new Statement(this, p));
                    }
                    elseClause.statements = clauseStatements;

                    this.clauses.Add(elseClause);

                    // Ignore any dedents
                    while (p.NextSymbolIs(TokenType.Dedent)) {
                        p.ExpectSymbol(TokenType.Dedent);
                    }

                }

                // Finish up by reading the <<endif>>
                p.ExpectSymbol(TokenType.BeginCommand);
                p.ExpectSymbol(TokenType.EndIf);
                p.ExpectSymbol(TokenType.EndCommand);
            }
예제 #4
0
            internal ShortcutOption(int optionIndex, ParseNode parent, Parser p)
                : base(parent, p)
            {
                p.ExpectSymbol(TokenType.ShortcutOption);
                label = p.ExpectSymbol(TokenType.Text).value as string;

                // Parse the conditional ("<<if $foo>>") if it's there
                if (p.NextSymbolsAre(TokenType.BeginCommand, TokenType.If)) {
                    p.ExpectSymbol(TokenType.BeginCommand);
                    p.ExpectSymbol(TokenType.If);
                    condition = Expression.Parse(this, p);
                    p.ExpectSymbol(TokenType.EndCommand);
                }

                // Parse the statements belonging to this option if it has any
                if (p.NextSymbolIs(TokenType.Indent)) {
                    p.ExpectSymbol(TokenType.Indent);
                    optionNode = new Node(NodeParent().name + "." + optionIndex, this, p);
                    p.ExpectSymbol(TokenType.Dedent);
                }
            }