On 2011-01-11, at 10:55 PM, David Sheets wrote:
What makes you say this? I don't see any language in Sec 3.1 or 3.3 that
allows characters outside of the defined source character set in a GLSL ES
Sec 3.5 states that comments are treated syntactically as a single
space. Sec 3.3 states that the second phase of compilation is removal
of comments after string concatenation and before preprocessing.
Comments are not included as part of the grammar productions and do
not effect processing except via insertion of space/newline.
You are correct that Sec 3.3 says that part of the second step is to replace comments with a single space. However even before this, in step 1 and 2a, it says that "Source strings are concatenated" and the "source string is converted into a sequence of preprocessing tokens".
So what constitutes a "source string"? According to 3.2, "The source for a single compilation unit is an array of strings of characters from the character set. A single compilation unit is made from the concatenation of these strings."
Which "character set" is that talking about? The one defined in 3.1. Which explicitly states that no quote characters are included, etc.
Furthermore, here is a list of invalid shader examples (due to invalid
character use) in the ESSL spec itself:
4.1.2: // declare “success” to be a Boolean
4.1.2: // declare and initialize “done”
4.2.2: // y is initialized to '2'
4.2.2: // x is initialized to '1'
4.2.2: // 'S' is only visible as a struct and constructor
4.2.2: // 'S' is now visible only as a variable
4.2.7: // Error: type 'f' conflicts with function 'f'
4.2.7: // Error: conflicts with the type 'f'
4.6.2: // a has a value a2 where possibly a1 ≠ a2
5.5: // illegal - 'x' used twice
I'd always taken the comments in the examples to be intended as annotations and/or editor's notes and not intended to be part of the example itself per-se.
As these characters never reach the compiler and do not participate in
identifiers or executable code, the spec is silent on their acceptable
character set. The spec does indicate that shader length is used to
determine the end of processing and that newlines delimit the end of
single lines comments and */ ends /* block comments. The spec also
indicates that nested comments are not allowed as the inside of a
comment is not parsed and inspected.
I think your definition of "compiler" here is perhaps a bit too narrow. IMHO all 9 steps of Sec 3.3 would constitute part of the compilation process and thus be "the compiler" as it were (yes including the pre-processing and linking). It seems that you are expecting only steps 6 and 7 to be the "compiler".
All that said, this is defined the same as the desktop GLSL specification (except that it doesn't list the logical phases of compilation), but I suspect that many implementations there may be a bit less strict about these things.
Hope this helps,