Skip to content

Instantly share code, notes, and snippets.

@SMotaal
Last active May 2, 2020 18:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SMotaal/1d877e3459082160793bc330cb9d2ec4 to your computer and use it in GitHub Desktop.
Save SMotaal/1d877e3459082160793bc330cb9d2ec4 to your computer and use it in GitHub Desktop.
Error composing block page

JSON Token Matcher

The Matcher-based tokenizer implementation for JSON.

Progress

  • Contextual Definitions — json-definitions.js

    Structured definitions for keywords, goals, symbols… etc, used by the tokenization process.

    • JSONGoal (…)

      Special subset of ECMAScriptGoal grammar specific to the PrimaryExpression production further restricted to derivatives of NullLiteral, BooleanLiteral, NumericLiteral, StringLiteral, ObjectLiteral, and ArrayLiteral.

      • JSONStringGoal "…"
        • Loose
        • Strict
      • JSONArrayGoal […]
        • Loose
        • Strict
      • JSONObjectGoal {…}
        • Loose
        • Strict
  • Matcher Ranges — json-ranges.js

    Special regular expressions instances of RegExpRange that take the range or class form (ie /[…]/) reflecting ones found in actual specifications to be used as the building blocks of the matcher.

    • ControlCharacter \0-\x1F
      • NullCharacter \0
    • DecimalDigit 0-9
    • HexDigit 0-9 a-f A-F
      • HexLetter a-f A-F

We needed to use this:

  - [x] ControlCharacter `\0-\x1F`
    - [x] NullCharacter `\0`
  - [x] DecimalDigit `0-9`
  - [x] HexDigit `0-9 a-f A-F`
    - [x] HexLetter `a-f A-F`

Which renders the following HTML:

<ul style="list-style: square">
			<li type="checkbox" checked=""><p> ControlCharacter <code token-type="sequence" token-hint="markdown" class="markdown fenced-code code">\0-\x1F</code>



</p><ul style="list-style: square">
					<li type="checkbox" checked=""><p> NullCharacter <code token-type="sequence" token-hint="markdown" class="markdown fenced-code code">\0</code> </p></li>
				</ul></li>
			<li type="checkbox" checked=""><p> DecimalDigit <code token-type="sequence" token-hint="markdown" class="markdown fenced-code code">0-9</code> </p></li>
			<li type="checkbox" checked=""><p> HexDigit <code token-type="sequence" token-hint="markdown" class="markdown fenced-code code">0-9 a-f A-F</code>



</p><ul style="list-style: square">
					<li type="checkbox" checked=""><p> HexLetter <code token-type="sequence" token-hint="markdown" class="markdown fenced-code code">a-f A-F</code> </p></li>
				</ul></li>
		</ul>

For some reason we get "Error composing block page" with:

  - [x] ControlCharacter `\0-\x1F`
    - [x] NullCharacter `\0`
  - [x] DecimalDigit `0-9`
  - [x] HexDigit `0-9a-fA-F`
    - [x] HexLetter `a-fA-F`

And with:

  - [x] ControlCharacter `\0-\x1F`
    - [x] NullCharacter `\0`
  - [x] DecimalDigit `0-9`
  - [x] HexDigit `a-fA-F0-9`
    - [x] HexLetter `a-fA-F`

But not with:

  - [x] ControlCharacter `\0-\x1F`
    - [x] NullCharacter `\0`
  - [x] DecimalDigit `0-9`
  - [x] HexDigit `a-f A-F 0-9`
    - [x] HexLetter `a-fA-F`

Or just with:

  - [x] ControlCharacter `\0-\x1F`
    - [x] NullCharacter `\0`
  - [x] DecimalDigit `0-9`
  - [x] HexDigit `0-9a-fA-F`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment