amazon-ion / ion-docs

Source for the GitHub Pages for Ion.
https://amazon-ion.github.io/ion-docs/
Apache License 2.0
22 stars 22 forks source link

Clarify Sexp Comment Precedence #313

Closed rmarrowstone closed 2 months ago

rmarrowstone commented 2 months ago

Add clarifying note that comments take precedence over operators in S-expressions.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

rmarrowstone commented 2 months ago

Lexically, comments are whitespace. Per the grammar:

ws
    : WHITESPACE
    | INLINE_COMMENT
    | BLOCK_COMMENT
    ;

Note that comments are not allowed inside blobs, given that the // sequence is legitimate Base64 content.

[Update: removed worries about blobs; I misread the grammar, which confusingly has distinct ws, WS, and WHITESPACE]

There is a related issue issue with ws in the grammar: per the grammar a comment without whitespace should terminate a numeric_entity. e.g.:

2004T// comment after year precise timestamp with no space

But per the spoken language description in the spec (which describes "stop" characters) and the implementations I've tested, this is not valid.