Description
Originally Loyc trees had a convention that there was a single character #
to mark all "special" identifiers. In this system, trivia (non-semantic information such as comments) were attached to things as attributes and required to have a Name
that starts with #trivia_
, e.g. #trivia_SLComment
for a single-line comment.
Later I decided to switch to a different special prefix for operators, an apostrophe (why an apostrophe? To minimize visual noise - I liked that it was a small character. Also, I didn't want to use a punctuation mark that already connoted a specific operator). I didn't want to slow down the check that distinguishes "normal" and "special" names so rather than check if name[0] == '\'' || name[0] == '#'
, LNode.IsSpecialName
checks if name[0] <= '\''
. Thus any prefix below ASCII 40 is reserved for special names.
Now I'm thinking that #trivia_
is a bit clunky - why not define a single-character prefix for trivia? At first I was thinking that the space character would be a good prefix, but then I remembered that #trivia_
does have one virtue, it greps well: code referring to #trivia_
is easy to find. With that in mind I think the best prefix is %
, because %
is a fairly rare character in most code, especially if that code is compiler-related. What do you think @jonathanvdc?
The next question then is whether to keep an alphanumeric representation of trivia concepts, like %SLComment
for "single-line comment", or whether to go with a compact symbolic representation like %//
- with the understanding that if one is parsing a language where comments are denoted # like this
or (* like this *)
it would still be recommended to use %//
and %/**/
to represent those comments in the Loyc tree.