Skip to content

Accept an insignificant comma where an array element would be - #238

Draft
webdevred wants to merge 1 commit into
masterfrom
tolerate-insignificant-commas
Draft

Accept an insignificant comma where an array element would be#238
webdevred wants to merge 1 commit into
masterfrom
tolerate-insignificant-commas

Conversation

@webdevred

Copy link
Copy Markdown
Owner

Part of #230. A failing spec only, no fix yet, so it stays a draft until the question at the end is settled.

BeamNG treats a comma as insignificant, closer to whitespace than to structure. Stock files rely on that, and one of the shapes is a stray comma where an array element would be:

["id", ,"idRef:", "posX", "posY", "posZ"],

Our grammar allows exactly one comma between elements, and separatorParser runs only between them, so a second one has nowhere to sit. The parse stops at it.

The spec asserts only that the input is accepted. What the formatter writes back for the empty slot is a separate decision, and it needs its own spec once it is made. Two ways to go:

Drop it. The file means the same thing to the game, and the formatter already normalises whitespace, indentation and padding, so a comma carrying nothing falls in the same category. collectElements skips it and nothing else changes.

Keep it.ArrayValue holds Vector (Node, Bool) where the flag means "this element was followed by a comma", so a comma with no element has nowhere to live. Preserving it needs either a node that renders as nothing or a second field, and AutoPad derives column widths from the elements, so it would also have to learn that the slot is not a column.

I lean towards dropping it.

BeamNG treats a comma as insignificant, so an array with a stray one where
an element would be is a file the game reads. The grammar allows exactly one
comma between elements and has nowhere to put a second, so the parse stops.
Sign up for freeto 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.

1 participant

@webdevred