Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jun 6, 2025

Empty lines within nested elements (children blocks) were causing transpilation to fail with parsing errors. The issue occurred when empty lines appeared between elements at the same indentation level within a parent element.

Problem

div
    h1
        "Hello"

    p  # <- This line would cause "expected EOI" error
        "World"

The grammar's PUSH/DROP indentation mechanism couldn't handle empty lines within children blocks, causing the parser to exit prematurely and expect end-of-input.

Solution

Added minimal changes to the grammar rules in grammar.pest:

  • Added empty_line rule using negative lookahead to properly match empty lines
  • Modified later_line rule to accept either properly indented content OR empty lines

Changes

  • Updated wasm-bindgen dependency from 0.2 to 0.2.88 for build compatibility
  • Fixed grammar to handle empty lines within nested elements (2 lines added to grammar.pest)

Testing

Verified the fix works with:

  • Empty lines within children blocks
  • Multiple consecutive empty lines
  • Mixed indentation patterns
  • All existing functionality (original examples still work)

Fixes #2.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • rustwasm.github.io
    • Triggering command: curl REDACTED -sSf (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits June 6, 2025 05:32
Co-authored-by: JonasLoos <33965649+JonasLoos@users.noreply.github.com>
Co-authored-by: JonasLoos <33965649+JonasLoos@users.noreply.github.com>
Copilot AI changed the title [WIP] Empty lines cause an error Fix empty lines causing transpilation errors in nested elements Jun 6, 2025
Copilot AI requested a review from JonasLoos June 6, 2025 05:44
Copy link
Owner

@JonasLoos JonasLoos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dont change cargo.toml

Make sure whitespace on an empty line is ignored and that newline handling is accurate.

Copy link
Contributor Author

Copilot AI commented Jun 6, 2025

Dont change cargo.toml

Make sure whitespace on an empty line is ignored and that newline handling is accurate.

I reverted the Cargo.toml changes as requested, but the build fails with "older versions of the wasm-bindgen crate are incompatible with current versions of Rust; please update to wasm-bindgen v0.2.88". The grammar changes have been updated to properly handle whitespace on empty lines using empty_line = _{ (" " | "\t")* } instead of the complex double negation approach.

Co-authored-by: JonasLoos <33965649+JonasLoos@users.noreply.github.com>
@JonasLoos JonasLoos marked this pull request as ready for review June 7, 2025 08:36
@JonasLoos JonasLoos merged commit 9b2dbd2 into main Jun 7, 2025
@JonasLoos JonasLoos deleted the copilot/fix-2 branch June 7, 2025 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Empty lines cause an error

2 participants