Reader Grammar

The reader grammar defines whitespace/comments, identifiers, booleans, characters, strings, numeric tokens, lists, vectors, bytevectors, and quotation prefixes.

How to reason about it

  • Integer: -?(0|[1-9][0-9]*); rational: integer numerator over positive canonical denominator; real requires fraction or exponent.
  • Dotted-list placement, escape spelling, byte range, and delimiter closure are checked before normalization.
  • Strings spell a hexadecimal scalar as \xHEX;; characters spell it as #\xHEX without the semicolon.
  • Source spans use the reader input identity and deterministic positions.

Pinned token grammar

TokenAccepted shapeRejected boundary
integer-?(0|[1-9][0-9]*)leading zero, radix/exactness prefix
rational<integer>/[1-9][0-9]*; reduced after readzero/negative denominator spelling, leading-zero denominator
realdecimal with fraction and/or exponentbare integer ambiguity, non-finite literal
stringquoted UTF-8 with pinned escapes, including \xHEX;unterminated escape or missing hexadecimal semicolon
character#&lt;scalar>, #\xHEX, or pinned named forminvalid scalar or a semicolon after the hexadecimal character
bytevector#u8(<byte> ...)element outside 0..255

The named characters are exactly space, newline, linefeed, tab, return, null, nul, delete, rubout, escape, esc, backspace, alarm, and page. Line comments begin with ;; block comments use nested #| ... |#; a leading ;! header is preserved. #; datum comments and #lang directives are rejected with E120, not discarded as trivia.

A common mistake

Reader extensions not listed in the profile fail loudly.

Keep going

Use this page while writing code. For a guided explanation, return to the syntax map or the corresponding manual.

Syntax at a Glance · Learning Path