Skip to content

S-Expresssion parser fixes

jaseg requested to merge neinseg/kicad-library-utils:pr-sexp-fixes into master

This fixes some bugs in the S-Expression parser and improves error handling. Primarily, numbers right after a parenthesis are now interpreted correctly. This fixes a bug introduced with the recent S-Expression speedup by @neinseg, and found by @armin.sch over in !460 (merged).

This fix goes a bit further though, and also fixes some corner cases present in the old code. Inside an S-Expression, all "simple values" (quoted strings, bare strings, floats, or integers) must now be terminated with whitespace or a closing parenthesis. This means this is now illegal: ("foo"(bar)), as it is missing a space between the closing quote and the opening parenthesis.

The parser now recognizes Tab characters as whitespace in all positions. Previously, it would only consider tabs whitespace at the beginning of a line, but not after numbers.

Errors with leading or trailing garbage and/or unbalanced parentheses are now properly handled, and the error messages have been extended with a shortened quote of the offending bit.

Merge request reports