Exemple #1
0
        // Parse a statement.
        public virtual ICodeNode Parse(Token token)
        {
            ICodeNode statementNode = null;

            switch (token.type.GetName())
            {
            case "BEGIN":
            {
                CompoundStatementParser compoundParser = new CompoundStatementParser(this);
                statementNode = compoundParser.Parse(token);
                break;
            }

            // An assignment statement begins with a variable's identifier.
            case "IDENTIFIER":
            {
                AssignmentStatementParser assignmentParser =
                    new AssignmentStatementParser(this);
                statementNode = assignmentParser.Parse(token);
                break;
            }

            default:
            {
                statementNode = ICodeFactory.CreateICodeNode(ICodeNodeTypeImplementation.NO_OP);
                break;
            }
            }

            // Set the current line number as an attribute.
            SetLineNumber(statementNode, token);
            return(statementNode);
        }
        // Parse a statement.
        public virtual ICodeNode Parse(Token token)
        {
            ICodeNode statementNode = null;

            switch (token.type.GetName())
            {
                case "BEGIN":
                    {
                        CompoundStatementParser compoundParser = new CompoundStatementParser(this);
                        statementNode = compoundParser.Parse(token);
                        break;
                    }

                // An assignment statement begins with a variable's identifier.
                case "IDENTIFIER":
                    {
                        AssignmentStatementParser assignmentParser =
                            new AssignmentStatementParser(this);
                        statementNode = assignmentParser.Parse(token);
                        break;
                    }

                default:
                    {
                        statementNode = ICodeFactory.CreateICodeNode(ICodeNodeTypeImplementation.NO_OP);
                        break;
                    }
            }

            // Set the current line number as an attribute.
            SetLineNumber(statementNode, token);
            return statementNode;
        }