Skip to content

Conversation

@hossain-khan
Copy link
Owner

I've implemented several enhancements and fixes to the JSON5 lexer to align it more closely with the official JSON5 specification:

  • Infinity & NaN Parsing: I've added support for parsing signed and unsigned Infinity and NaN values (e.g., +Infinity, -Infinity, NaN).
  • String Line Continuations: I've ensured that escaped line breaks (e.g., "\ ") in strings are correctly handled, treating them as zero-length.
  • Unicode Identifiers: I've expanded validation for unquoted object keys to support a wider range of Unicode characters as per ECMAScript 5.1 identifier rules (using Unicode character categories).
  • U+2028/U+2029 Warnings: I've set it up to issue warnings when unescaped U+2028 (Line Separator) or U+2029 (Paragraph Separator) characters are found in string literals, while still including them in the parsed value.
  • Whitespace Handling: I've added U+FEFF (Byte Order Mark) to the set of recognized whitespace characters.

I've also added numerous corresponding unit tests for these features to JSON5ParseTest.kt.

Critical Note: Due to persistent issues with the Gradle build environment (missing gradle-wrapper.jar, unable to bootstrap), I could not run and verify these changes and the full test suite. The implementation is based on code review and adherence to the specification but lacks automated test validation.

I've implemented several enhancements and fixes to the JSON5 lexer
to align it more closely with the official JSON5 specification:

- Infinity & NaN Parsing: I've added support for parsing signed and
  unsigned Infinity and NaN values (e.g., +Infinity, -Infinity, NaN).
- String Line Continuations: I've ensured that escaped line breaks
  (e.g., "\
") in strings are correctly handled, treating them as zero-length.
- Unicode Identifiers: I've expanded validation for unquoted object keys
  to support a wider range of Unicode characters as per ECMAScript 5.1
  identifier rules (using Unicode character categories).
- U+2028/U+2029 Warnings: I've set it up to issue warnings when unescaped U+2028 (Line
  Separator) or U+2029 (Paragraph Separator) characters are found
  in string literals, while still including them in the parsed value.
- Whitespace Handling: I've added U+FEFF (Byte Order Mark) to the set of
  recognized whitespace characters.

I've also added numerous corresponding unit tests for these features to
JSON5ParseTest.kt.

**Critical Note:** Due to persistent issues with the Gradle build
environment (missing gradle-wrapper.jar, unable to bootstrap), I
could not run and verify these changes and the full test suite.
The implementation is based on code review and adherence to the
specification but lacks automated test validation.
@hossain-khan
Copy link
Owner Author

Screenshot 2025-06-07 at 9 06 58 AM

Messed up the existing function! could not validate

@hossain-khan hossain-khan deleted the feat/json5-spec-alignment branch June 7, 2025 14:57
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.

2 participants