<< Non Terminals | Ignore Symbols >>
#1 Reserved Words
ResWord :=
ALIAS | AND | ARGLIST | ARRAY | BEGIN | BLUEPRINT | BY | CASE | CONST | COPY |
DEFINITION | DIV | DO | ELSE | ELSIF | END | EXIT | FOR | FROM | GENLIB | IF |
IMPLEMENTATION | IMPORT | IN | LOOP | MOD | MODULE | NEW | NONE | NOT | OF |
OPAQUE | OR | POINTER | PROCEDURE | RECORD | REFERENTIAL | RELEASE | REPEAT |
RETAIN | RETURN | SET | THEN | TO | TYPE | UNTIL | VAR | WHILE | YIELD
;
#2 Dual-Use Identifiers
(Schrödinger's Tokens)
DualUseIdent :=
ABS | ADDRESS | APPEND | CAST | COUNT | COROUTINE | EXISTS | INSERT |
LENGTH | OCTET | READ | READNEW | REMOVE | SEEK | STORE | SUBSET | SXF |
TDYN | TFLAGS | TLIMIT | TLITERAL | TMAX | TMIN | TORDERED | TREFC |
TSCALAR | TSORTED | UNSAFE | VAL | VALUE | WRITE | WRITEF
;
#3 Special Symbols
SpecialSymbol :=
'.' | ',' | ':' | ';' | '|' | '~' | '..' | ':=' | '++' | '--' |
'::' | '+' | '-' | '*' | '/' | '\' | '&' | '^' |
'=' | '#' | '>' | '>=' | '<' | '<=' | '==' |
'->' | '<>' | '><' | '+/-' |
'(' | ')' | '[' | ']' | '{' | '}'
;
#3.1 Quoted Text Delimiters
'
"
<<
>>
#3.2 Comment Delimiters
!
(*
*)
#3.3 Pragma Punctuation and Delimiters
?
<*
*>
#3.4 Template Language Symbols
##
<#
#>
@@
//
/*
*/
#3.5 Reserved Symbols
`
for use as a token by Objective Modula-2
@
for use as a lead character in identifiers and reserved words by language supersets
%
for use as a character in identifiers and reserved words by implementations targetingOpenVMS
Ident :=
( Letter | ForeignIdentChar+ LetterOrDigit+ ) IdentTailChar*
;
#4.1 Standard Library Identifier syntax diagram
StdLibIdent :=
Letter LetterOrDigit*
;
LetterOrDigit :=
Letter | Digit
;
#4.3 Foreign Identifier Character syntax diagram
ForeignIdentChar :=
'_' | '$'
;
#4.4 Identifier Tail Character syntax diagram
IdentTailChar :=
LetterOrDigit | ForeignIdentChar
;
NumberLiteral :=
/* number literals starting with digit 0 ... */
'0' (
/* without prefix are real numbers */
RealNumberTail |
/* with prefix 0b are base-2 numbers */
'b' Base2DigitSeq |
/* with prefix 0x are base-16 numbers */
'x' Base16DigitSeq |
/* with prefix 0u are unicode code points */
'u' Base16DigitSeq
)?
/* number literals starting with digits 1 to 9 ... */
| '1'..'9' DecimalNumberTail? /* are always decimal numbers */
;
DecimalNumberTail :=
DigitSep? DigitSeq RealNumberTail? | RealNumberTail
;
RealNumberTail :=
'.' DigitSeq ( 'e' ( '+' | '-' )? DigitSeq )?
;
DigitSeq :=
Digit+ ( DigitSep Digit+ )*
;
Base16DigitSeq :=
Base16Digit+ ( DigitSep Base16Digit+ )*
;
Base2DigitSeq :=
Base2Digit+ ( DigitSep Base2Digit+ )*
;
Digit :=
Base2Digit | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'
;
Base16Digit :=
Digit | 'A' | 'B' | 'C' | 'D' | 'E' | 'F'
;
Base2Digit :=
'0' | '1'
;
#5.9 Digit Separator
DigitSep := "'" ;
StringLiteral :=
SingleQuotedString | DoubleQuotedString
;
SingleQuotedString :=
"'" ( QuotableCharacter | '"' )* "'"
;
DoubleQuotedString :=
'"' ( QuotableCharacter | "'" )* '"'
;
QuotableCharacter :=
Digit | Letter | Space | NonAlphaNumQuotable | EscapedCharacter
;
Letter :=
'A' .. 'Z' | 'a' .. 'z'
;
#6.5 Space
Space := ' ' ;
#6.6 Non-Alphanumeric Quotable syntax diagram
NonAlphaNumQuotable :=
'!' | '#' | '$' | '%' | '&' | '(' | ')' | '*' | '+' | ',' |
'-' | '.' | '/' | ':' | ';' | '<' | '=' | '>' | '?' | '@' |
'[' | ']' | '^' | '_' | '`' | '{' | '|' | '}' | '~'
EscapedCharacter :=
'\' ( 'n' | 't' | '\' )
;
ChevronText :=
'<<' ( QuotableCharacter | "'" | '"' )* '>>'
;