示例#1
0
        public static GATNode _declaration(this LL1Processor ll1)
        {
            var node   = new GATNode();
            var offset = 2;

            //
            node.name = "global";
            CodeGenerator.AddLabel("global", 0);
            //
            switch (WordContainer.GetWordType(offset))
            {
            case WordType.SEMICOLON:
            {
                var varDeclaration = ll1._varDeclaration();
                node.AddChild(varDeclaration);
                node.generator = Declaration1;
                break;
            }

            case WordType.BRACKET_L:
            {
                var funDeclaration = ll1._funDeclaration();
                node.AddChild(funDeclaration);
                node.generator = Declaration2;
                break;
            }

            default:
            {
                throw new BNFException();
            }
            }
            return(node);
        }
        public static GATNode _localDeclarations(this LL1Processor ll1)
        {
            var node   = new GATNode();
            var offset = 1;

            var next = WordContainer.GetWordType(offset);

            while (next == WordType.ID)
            {
                var varDeclaration = ll1._varDeclaration();
                node.AddChild(varDeclaration);
                next = WordContainer.GetWordType(offset);
            }

            if (node.ChildCount() == 0)
            {
                node.generator = LocalDeclarations2;
            }
            else
            {
                node.generator = LocalDeclarations1;
            }

            return(node);
        }