コード例 #1
0
ファイル: BulletBuilder.cs プロジェクト: frankgu98/Phosphaze
        protected override void ProcessNext()
        {
            // Check for an assignment statement.
            if (DmlTokens.IsMatch(CurrentToken, DmlTokens.KW_ASSIGN))
            {
                throw DmlSyntaxError.BadAssignmentNamespace();
            }
            else if (DmlTokens.IsMatch(CurrentToken, DmlTokens.KW_INIT))
            {
                if (Init != null)
                {
                    throw DmlSyntaxError.DuplicateNamespaceInBullet("Init");
                }
                SetExpecting(DmlTokens.LANGLE);
                Advance(exception: DmlSyntaxError.BlockMissingDelimiters("Init"));

                string[]          tokens      = GetNamespaceBlock();
                BulletInitBuilder initBuilder = new BulletInitBuilder(tokens, currentLine);
                initBuilder.Parse();

                var initBlock = (Instruction[])initBuilder.GetResult();
                Init = new CodeBlock(initBlock);
            }
            else if (DmlTokens.IsMatch(CurrentToken, DmlTokens.KW_UPDATE))
            {
                if (Update != null)
                {
                    throw DmlSyntaxError.DuplicateNamespaceInBullet("Update");
                }
                SetExpecting(DmlTokens.LANGLE);
                Advance(exception: DmlSyntaxError.BlockMissingDelimiters("Update"));

                string[]            tokens        = GetNamespaceBlock();
                BulletUpdateBuilder updateBuilder = new BulletUpdateBuilder(tokens, currentLine);
                updateBuilder.Parse();

                var updateBlock = (Instruction[])updateBuilder.GetResult();
                Update = new CodeBlock(updateBlock);
            }
            else
            {
                throw DmlSyntaxError.InvalidTokenForContext(CurrentToken, "bullet");
            }
        }
コード例 #2
0
ファイル: BulletBuilder.cs プロジェクト: roflwaffl/Phosphaze
        protected override void ProcessNext()
        {
            // Check for an assignment statement.
            if (DmlTokens.IsMatch(CurrentToken, DmlTokens.KW_ASSIGN))
            {
                throw DmlSyntaxError.BadAssignmentNamespace();
            }
            else if (DmlTokens.IsMatch(CurrentToken, DmlTokens.KW_INIT))
            {
                if (Init != null)
                    throw DmlSyntaxError.DuplicateNamespaceInBullet("Init");
                SetExpecting(DmlTokens.LANGLE);
                Advance(exception: DmlSyntaxError.BlockMissingDelimiters("Init"));

                string[] tokens = GetNamespaceBlock();
                BulletInitBuilder initBuilder = new BulletInitBuilder(tokens, currentLine);
                initBuilder.Parse();

                var initBlock = (Instruction[])initBuilder.GetResult();
                Init = new CodeBlock(initBlock);
            }
            else if (DmlTokens.IsMatch(CurrentToken, DmlTokens.KW_UPDATE))
            {
                if (Update != null)
                    throw DmlSyntaxError.DuplicateNamespaceInBullet("Update");
                SetExpecting(DmlTokens.LANGLE);
                Advance(exception: DmlSyntaxError.BlockMissingDelimiters("Update"));

                string[] tokens = GetNamespaceBlock();
                BulletUpdateBuilder updateBuilder = new BulletUpdateBuilder(tokens, currentLine);
                updateBuilder.Parse();

                var updateBlock = (Instruction[])updateBuilder.GetResult();
                Update = new CodeBlock(updateBlock);
            }
            else
                throw DmlSyntaxError.InvalidTokenForContext(CurrentToken, "bullet");
        }