Skip to content

Cannot parse valid jbeam that the game reads #230

Description

@webdevred

BeamNG treats commas as insignificant, closer to whitespace than to structure. Our grammar only allows one between elements, so a comma anywhere else stops the parse. Four shapes occur in stock files:

Shape Example
after a key colon "innerfender_R":,
before a key colon "spoke1",: {"links:": ...}
empty element in an array ["id", ,"idRef:", ...]
after the root object file ends },\n},

objectKeyParser goes straight from byteChar ':' to nodeParser, and separatorParser runs only between elements, so none of these has anywhere to sit.

A fifth failure is unrelated to commas: a number written with a trailing dot, ["f1", 0., -1.66, 0.76]. intDecimalParser rejects it with notFollowedBy '.' and L.scientific wants digits after the dot.

97 of 4946 stock files fail, spread over 34 of the 123 vehicles. Reproduce with tools/extract-and-format-jbeam/corpus-extract.sh and run the tool over the result, reading stderr rather than the exit code.

Suggested direction: one lenient separator rule rather than a patch per shape, since commas really are insignificant and modders write by hand, so shapes we have not seen will turn up. Do not make skipWhiteSpace eat commas, because lastSeparatorHadComma would stop seeing them and TrailingComma Preserve would lose its input.

Output needs no new logic. The formatter already decides commas from JBFL rules, so the stray ones simply do not come back. The trailing dot is different: complex.jbfl sets PreserveNumberFormat on .*.nodes[*].*, which is where it occurs, so it round-trips unchanged unless we decide otherwise.

Done when the corpus parses with zero failures.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions