ERights Home elang / kernel 
Back to: Float64 Literal Expression On to: String Literal Expression

Char Literal Expression


Has the conventional meaning -- evaluates to the expressed Unicode character. Any unicode character should be able to be expressed literally, but the "\u..." escape syntax hasn't yet been implemented. We first need to decide what at level of abstraction this escape should be processed. (Java makes a non-obvious choice that is probably correct -- expand only this one prior to lexing -- in which case it would disappear from the production below.)

Lexical Regex:
constChar: \\b             # backspace
           \\t             # tab
           \\n             # linefeed
           \\f             # formfeed
           \\r             # carriage return
           \\"             # double quote
           \\'             # single quote
           \\\\            # backslash
           \\$             # dollar sign
           \\@             # at sign
           \\u[o-9a-fA-F]+ # not yet implemented
           \\digits        # reserved

Char: 'constChar | non-blackslash-char'
XML DTD:
<!ELEMENT Char #PCDATA>

Where, after processing the Minimal-XML escapes and whitespace rules, the #PCDATA must conform to the above regex, and should be written as it appears in the source text.

Java:

The E syntax can be used directly in Java with the same meaning with the following exceptions:

in E translate to Java
'\$' or '$'
'$'
'\@' or '@'
'@'
'\'' or '''
'\''

Future versions of the E compiler should try to determine when it can use the scalar rather than widening it to a Character object. However, in the general case (and currently the only case), this will translate to

new Character(char-literal)
XXX Should probably instead call a function that checks if the argument is in the ascii subset and, if so, indexes into a table of pre-allocated Characters.
Example:
'a'
in Kernel-E:
same
in XML:
<Char>a</Char>
in Java
new Character('a')

x
 
Unless stated otherwise, all text on this page which is either unattributed or by Mark S. Miller is hereby placed in the public domain.
ERights Home elang / kernel 
Back to: Float64 Literal Expression On to: String Literal Expression
Download    FAQ    API    Mail Archive    Donate

report bug (including invalid html)

Golden Key Campaign Blue Ribbon Campaign