Identifiers
In Spade identifier tokens are lexed as defined by the following regular expression:
(r#)?(
[\p{XID_Start}_]
\p{XID_Continue}*
(\u{3F} | \u{21} | (\u{3F}\u{21}) | \u{2048})?
)
This loosely follows the definition of identifiers as defined by the Unicode Standard Annex #31, with differences described in the Differences from UAX #31 section.
Breaking this down further:
- Identifiers may be prefixed with
r#, the raw identifier syntax, which allows for identifiers sharing names with keywords - Identifiers must start with
_or any unicode character in the setXID_Start - Identifiers may contain any character present in the set
XID_Continue - Identifiers may be followed by up to one the following character sequences:
?,!,?!,⁈
Examples
Here is a list of a few identifiers valid in Spade:
_spadefish123?r#if_游泳
Here is a list of some identifiers invalid in Spade:
if(a keyword without the raw identifier syntax)123spade(begins with a non-XID_Startcharacter)test-ident(contains a non-XID_Continuecharacter)
Differences from UAX 31
r#may be prefixed to denote a raw identifier- Underscore may be the first character in an identifier
- Identifiers may end in one of the following:
?,!,?!,⁈