-
Notifications
You must be signed in to change notification settings - Fork 36
Open
Description
NL = New Line (0x0a)
CR = Carriage Return (0x0d)
TAB = Tab (0x09)
Inside Line Comments and Documentation Comments
- Any TAB is rejected by the grammar since it is ambiguous how it should be rendered.
- CR directly preceding NL is unambiguously part of the newline sequence. It is accepted by the grammar and removed by
zig fmt
, leaving only NL. - CR anywhere else is rejected by the grammar.
Inside Multi-Line String Literals
zig fmt
may not mangle multi line string literals, and therefore the control character TAB are rejected by the grammar inside multi-line string literals.- CR inside the multiline string literal is also rejected for the same reason
- However CR directly before NL is interpreted as only a newline and not part of the multiline string. zig fmt will delete the CR.
For string literals that want to include CR, TAB, or any other control sequences, they will need to use regular string literals and the ++
operator, or @embedFile
.
Whitespace
- TAB used as whitespace is unambiguous. It is accepted by the grammar and replaced by the canonical whitespace by
zig fmt
. - CR used as whitespace, whether directly preceding NL or stray, is still unambiguously whitespace. It is accepted by the grammar and replaced by the canonical whitespace by
zig fmt
.
PanSashko, Weltspear, BeneDevRepo, sigod, MKRhere and 4 morekristoff-it, mlarouche, g-w1, komuw, kassane and 6 morekomuw, nektro, jagt and maxmiltonBeneDevRepomarler8997
Metadata
Metadata
Assignees
Labels
No labels