17.2 Lexical items
SML# lexical items consist of the following.
- keywords
-
The following are SML# keywords and they cannot be used as identifiers.
abstype and andalso as case datatype do else end eqtype exception fn fun functor handle if in include infix infixr let local nonfix of op open orelse raise rec set sharing sig signature struct structure then type val where while with withtype ( ) [ ] { } , : :> ; ... _ = => -> #
alphaId defined in the identifier section does not contain these keywords.
- SQL keywords
-
The following are keywords used in SQL expressions and cannot be used as identifiers within SQL expressions.
asc all begin by commit cross default delete desc distinct fetch first from group inner insert into is join limit natural next not null offset only on or order rollback row rows select set update values where
- Extended keywords
-
The following names started with _ are keywords used to represent SML# special features. Since they are not lexical items in the definition of Standard ML, introducing them preserves the backward compatibility.
__attribute__ _builtin _foreach _import _interface _join _dynamic _dynamiccase _polyrec _require _sizeof _sql _sqlserver _typeof _use
- Identifiers
-
Identifiers are names used in programs. SML# has the following 7 classes of identifiers defined below. Their classes are determined from their occurring context, so the same name can be used in different identifiers.
name usage vid variables, data constructors lab record labels strid structure names sigid signature names funid functor names tycon type constructors tyvar type variables これら識別子の構造は以下の通りである.
vid ::= alphaId symbolId lab ::= alphaId string decimal decimal _ alphaId (note *1) strid ::= alphaId sigid ::= alphaId funid ::= alphaId tyvar ::= ’ alphaId ’’alphaId tycon ::= alphaId symbolId Note.
-
1.
There are the following three kinds of record labels: character string labels(alphaId or string), integer labels(decimal), ordered character string labels([1-9][0-9]* _ alphaId). In SML#, record fields are sorted according to the ordering of their labels. Character string labels are ordered by String.compare. Integer labels are ordered according to the integer they represents. Ordered character string labels are order by the lexicographical pairing of integer labels and character string labels.
The definition of these character classes are given below.
alpha ::= [A-Za-z \
127-\
255]symbol ::= ! % & $ + / : < = > ? @ ‘ | # - ^ \ alphaId ::= alpha (alpha [0-9] ’ _ )* (Note 1) decimal ::= [1-9] [0-9]* symbolId ::= symbol* (Note 2) Note.
-
1.
The character class alphaId does not contain keywords. Furthermore, in SQL expressions that begins with _sql, alphaId does not contain SQL keywords.
-
2.
symbolId does not contain keywords. Therefore ==> is an instance of symbolId but => is not.
-
1.
- Long identifiers
-
For vid (variable names and constructor names) and strid (structure names), the following long identifiers are defined.
longVid ::= (strid .)* vid longTycon ::= (strid .)* tycon longStrid ::= (strid .)* strid - constant literals scon
-
Syntax for constant literals are given below.
scon ::= int word real string char Constant literals int ::= ~
[0-9]Decimal integers ~
0x
[0-9a-fA-F]Hexadecimal integers word ::= 0w
[0-9]unsigned decimal integers 0wx
[0-9a-fA-F]unsigned hexadecimal integers real ::= ~
[0-9] . [0-9] [Ee]~
[0-9]+Floating-point numbers ~
[0-9] . [0-9]+~
[0-9] [Ee]~
[0-9]+char ::= #"
(printable escape)"
Character string ::= "
(printable escape)"
String printable ::= characters except for \ and " escape ::= \a
The warning character (ASCII 7) \b
Backspace (ASCII 8) \t
Horizontal tab (ASCII 9) \n
New line character (ASCII 10) \v
Vertical tab (ASCII 11) \f
Home feed (ASCII 12) \r
Carriage return (ASCII 13) \^
[\
064-\
095]Control character represented by [\064-\095] \\
The \ character \"
The " character \
The character of decimal code \
\
ignoring whitespace characters \u
The string of the UTF-8 character of hexadecimal code