vb6parse 1.0.0

vb6parse is a library for parsing and analyzing VB6 code, from projects, to controls, to modules, and forms.
Documentation
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Getting Started with VB6Parse - Step-by-step tutorial for parsing Visual Basic 6 code">
    <title>Getting Started - VB6Parse</title>
    <link rel="stylesheet" href="assets/css/style.css">
    <link rel="stylesheet" href="assets/css/docs-style.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github-dark.min.css">
    <script src="assets/js/theme-switcher.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/rust.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/vbnet.min.js"></script>
    <script>
        // Load code examples from GitHub
        const CDN_BASE = 'https://raw.githubusercontent.com/scriptandcompile/vb6parse/master/examples/docs/';
        
        document.addEventListener('DOMContentLoaded', function() {
            document.querySelectorAll('pre[data-github-example]').forEach(async (pre) => {
                const filename = pre.getAttribute('data-github-example');
                const code = pre.querySelector('code');
                
                try {
                    const response = await fetch(CDN_BASE + filename);
                    if (!response.ok) throw new Error('Failed to load');
                    const text = await response.text();
                    code.textContent = text;
                    code.classList.remove('loading-state', 'error-fallback');
                    hljs.highlightElement(code);
                } catch (error) {
                    code.textContent = '⚠️ Failed to load example from GitHub.\n\nPlease check your connection or view the example directly at:\nhttps://github.com/scriptandcompile/vb6parse/tree/master/examples/docs/' + filename;
                    code.classList.remove('loading-state');
                    code.classList.add('error-fallback');
                }
            });
        });
    </script>
    <style>
        .loading-state {
            color: #6b7280 !important;
            font-style: italic;
        }
        .error-fallback {
            border-left: 4px solid #f59e0b !important;
            background: #fffbeb !important;
            color: #92400e !important;
        }
    </style>
</head>
<body>
    <header class="docs-header">
        <div class="container">
            <h1><a href="index.html">VB6Parse</a> / <a href="documentation.html">Documentation</a> / Getting Started</h1>
            <p class="tagline">Step-by-step tutorial for parsing Visual Basic 6 code</p>
        </div>
    </header>

    <nav class="docs-nav">
        <div class="container">
            <a href="index.html">Home</a>
            <a href="documentation.html">Documentation</a>
            <a href="https://docs.rs/vb6parse" target="_blank">API Docs</a>
            <a href="https://github.com/scriptandcompile/vb6parse" target="_blank">GitHub</a>
            <button id="theme-toggle" class="theme-toggle" aria-label="Toggle theme">
                <span class="theme-icon">🌙</span>
            </button>
        </div>
    </nav>

    <main class="container">
        <section id="introduction">
            <h2>Introduction</h2>
            <p>
                This guide will walk you through using VB6Parse, from installation to advanced parsing scenarios.
                By the end, you'll understand how to parse VB6 projects, handle errors, navigate syntax trees, and
                build tools that process legacy Visual Basic 6 code.
            </p>
        </section>

        <section id="prerequisites">
            <h2>Prerequisites</h2>
            <ul>
                <li><strong>Rust:</strong> Version 1.70 or later (Install from <a href="https://rustup.rs" target="_blank">rustup.rs</a>)</li>
                <li><strong>Basic Rust knowledge:</strong> Understanding of Result types, ownership, and cargo</li>
                <li><strong>VB6 familiarity:</strong> Helpful but not required</li>
            </ul>
        </section>

        <section id="installation">
            <h2>Installation</h2>
            
            <div class="step-card">
                <span class="step-number">1</span>
                <h3>Create a new Rust project</h3>
            </div>
            <pre data-lang="bash"><code class="language-bash">cargo new vb6parse-demo
cd vb6parse-demo</code></pre>

            <div class="step-card">
                <span class="step-number">2</span>
                <h3>Add VB6Parse to Cargo.toml</h3>
            </div>
            <pre data-file="Cargo.toml" data-lang="toml"><code class="language-toml">[dependencies]
vb6parse = "0.5.1"</code></pre>

            <div class="step-card">
                <span class="step-number">3</span>
                <h3>Verify installation</h3>
            </div>
            <pre data-lang="bash"><code class="language-bash">cargo build</code></pre>
        </section>

        <section id="hello-world">
            <h2>Your First Parse: Hello World</h2>
            <p>Let's start with the simplest possible example - parsing a VB6 module with a single subroutine.</p>

            <div class="step-card">
                <span class="step-number">1</span>
                <h3>Create a simple module parser</h3>
                <p>Replace the contents of <code>src/main.rs</code>:</p>
            </div>
            <pre data-file="examples/docs/hello_world.rs" data-lang="rust" data-github-example="hello_world.rs"><code class="language-rust loading-state">Loading example from GitHub...</code></pre>

            <div class="step-card">
                <span class="step-number">2</span>
                <h3>Run the example</h3>
            </div>
            <pre data-lang="bash"><code class="language-bash">cargo run</code></pre>

            <div class="tip-box">
                <strong>💡 Key Concept: ParseResult</strong><br>
                VB6Parse uses a <code>ParseResult&lt;T, E&gt;</code> type that contains both the parsed output 
                (<code>Option&lt;T&gt;</code>) and any failures (<code>Vec&lt;ErrorDetails&lt;E&gt;&gt;</code>). 
                This allows partial success - you can get a usable parse tree even if some parts failed.
            </div>
        </section>

        <section id="project-parsing">
            <h2>Parsing VB6 Projects</h2>
            <p>VB6 projects (.vbp files) list all modules, forms, and references. Let's parse one:</p>

            <pre data-file="examples/docs/project_parsing.rs" data-lang="rust" data-github-example="project_parsing.rs"><code class="language-rust loading-state">Loading example from GitHub...</code></pre>

            <div class="warning-box">
                <strong>⚠️ Important:</strong> ProjectFile only parses the .vbp file itself - it doesn't load 
                the referenced files. You'll need to read and parse each module/form/class file separately.
            </div>
        </section>

        <section id="error-handling">
            <h2>Handling Parse Errors</h2>
            <p>VB6Parse is designed to handle malformed input gracefully. Even with syntax errors, you often get partial results:</p>

            <pre data-file="examples/docs/error_handling.rs" data-lang="rust" data-github-example="error_handling.rs"><code class="language-rust loading-state">Loading example from GitHub...</code></pre>

            <div class="tip-box">
                <strong>💡 Best Practice:</strong> Always check both the result and failures. In tools that 
                process many files, log failures but continue processing - don't stop on the first error.
            </div>
        </section>

        <section id="tokenization">
            <h2>Tokenization</h2>
            <p>For lower-level analysis, you can tokenize VB6 code without building a full parse tree:</p>

            <pre data-file="examples/docs/tokenization.rs" data-lang="rust" data-github-example="tokenization.rs"><code class="language-rust loading-state">Loading example from GitHub...</code></pre>
        </section>

        <section id="cst-navigation">
            <h2>Navigating the Concrete Syntax Tree</h2>
            <p>The CST preserves all source information including whitespace and comments, making it perfect for code analysis tools:</p>

            <pre data-file="examples/docs/cst_navigation.rs" data-lang="rust" data-github-example="cst_navigation.rs"><code class="language-rust loading-state">Loading example from GitHub...</code></pre>

        </section>

        <section id="form-parsing">
            <h2>Parsing Forms and Controls</h2>
            <p>Forms are the most complex VB6 file type, containing both UI controls and code:</p>

            <pre data-file="examples/docs/form_parsing.rs" data-lang="rust" data-github-example="form_parsing.rs"><code class="language-rust loading-state">Loading example from GitHub...</code></pre>

        </section>

        <section id="use-cases">
            <h2>Common Use Cases</h2>
            <p>Here are some practical applications you can build with VB6Parse:</p>

            <div class="use-case-grid">
                <div class="use-case-card">
                    <h4>Code Migration Tools</h4>
                    <p>Parse VB6 projects and convert them to modern languages (C#, VB.NET, Python). Extract 
                    forms, business logic, and database connections for automated conversion.</p>
                </div>

                <div class="use-case-card">
                    <h4>Static Analysis</h4>
                    <p>Build linters and code quality tools for legacy VB6 codebases. Find deprecated API usage, 
                    detect code smells, enforce coding standards.</p>
                </div>

                <div class="use-case-card">
                    <h4>Documentation Generation</h4>
                    <p>Automatically generate API documentation from VB6 source code. Extract function signatures, 
                    comments, and module relationships.</p>
                </div>

                <div class="use-case-card">
                    <h4>Code Metrics</h4>
                    <p>Calculate lines of code, cyclomatic complexity, dependency graphs, and other metrics 
                    for project planning and technical debt assessment.</p>
                </div>

                <div class="use-case-card">
                    <h4>Form Extraction</h4>
                    <p>Extract UI layouts and control hierarchies from .frm files for migration to modern 
                    UI frameworks or for visual documentation.</p>
                </div>

                <div class="use-case-card">
                    <h4>Code Search Tools</h4>
                    <p>Build semantic search tools that understand VB6 syntax. Find all usages of a function, 
                    locate API calls, track variable usage across projects.</p>
                </div>
            </div>
        </section>

        <section id="next-steps">
            <h2>Next Steps</h2>
            <p>Now that you understand the basics, explore these resources:</p>

            <div class="doc-links">
                <a href="https://docs.rs/vb6parse" class="doc-link" target="_blank">
                    <h3>📖 API Documentation</h3>
                    <p>Complete API reference with all types, methods, and examples</p>
                </a>

                <a href="https://github.com/scriptandcompile/vb6parse/tree/master/examples" class="doc-link" target="_blank">
                    <h3>💡 Code Examples</h3>
                    <p>More examples showing advanced parsing scenarios and techniques</p>
                </a>

                <a href="documentation.html" class="doc-link">
                    <h3>📚 Technical Documentation</h3>
                    <p>Deep dive into VB6 file formats and parser architecture</p>
                </a>
            </div>

            <div class="tip-box">
                <strong>💡 Need Help?</strong><br>
                • Check the <a href="https://github.com/scriptandcompile/vb6parse/issues" target="_blank">GitHub Issues</a> for common problems<br>
                • Review the <a href="https://github.com/scriptandcompile/vb6parse/tree/master/examples" target="_blank">examples directory</a> for more code samples<br>
                • Open a discussion or issue if you encounter problems
            </div>
        </section>
    </main>

    <footer>
        <div class="container">
            <p>&copy; 2024-2026 VB6Parse Contributors</p>
            <p>
                <a href="https://github.com/scriptandcompile/vb6parse" target="_blank">GitHub</a> |
                <a href="https://crates.io/crates/vb6parse" target="_blank">Crates.io</a> |
                <a href="https://docs.rs/vb6parse" target="_blank">API Docs</a> |
                <a href="https://opensource.org/licenses/MIT" target="_blank">MIT License</a>
            </p>
        </div>
    </footer>
</body>
</html>