| 1 |
"Name" = 'D Lex' |
|---|
| 2 |
"Author" = 'Nick Sabalausky' |
|---|
| 3 |
"Version" = '0.02' |
|---|
| 4 |
"About" = 'Lexing grammar for D2' |
|---|
| 5 |
"Case Sensitive" = true |
|---|
| 6 |
|
|---|
| 7 |
"Start Symbol" = <Module> |
|---|
| 8 |
|
|---|
| 9 |
! -- Terminals ----------------------------------------- |
|---|
| 10 |
|
|---|
| 11 |
Whitespace = {Whitespace}+ |
|---|
| 12 |
Comment Line = '//' |
|---|
| 13 |
Comment Start = '/*' |
|---|
| 14 |
Comment End = '*/' |
|---|
| 15 |
|
|---|
| 16 |
! Nested comments not yet supported by Goldie |
|---|
| 17 |
NestedCommentStart = '/+' |
|---|
| 18 |
NestedCommentEnd = '+/' |
|---|
| 19 |
|
|---|
| 20 |
! Token Strings need to be lexed just like ordinary code, |
|---|
| 21 |
! so there's no special terminal for them other than 'q{' |
|---|
| 22 |
|
|---|
| 23 |
Identifier = ({Letter} | '_') ({AlphaNumeric} | '_')* |
|---|
| 24 |
|
|---|
| 25 |
{NonZeroDigit} = {Number} - [0] |
|---|
| 26 |
{DecimalDigit} = {Number} + [_] |
|---|
| 27 |
{BinaryDigit} = [_01] |
|---|
| 28 |
{OctalDigit} = [_01234567] |
|---|
| 29 |
{HexDigit} = {Number} + [_abcdefABCDEF] |
|---|
| 30 |
Decimal = ( '0' | ({NonZeroDigit} ({Number}|'_')*) ) ([LuU]|'Lu'|'LU'|'uL'|'UL')? |
|---|
| 31 |
Binary = '0' [bB] {BinaryDigit}+ ([LuU]|'Lu'|'LU'|'uL'|'UL')? |
|---|
| 32 |
Octal = '0' {OctalDigit}+ ([LuU]|'Lu'|'LU'|'uL'|'UL')? |
|---|
| 33 |
Hexadecimal = '0' [xX] {HexDigit}+ ([LuU]|'Lu'|'LU'|'uL'|'UL')? |
|---|
| 34 |
|
|---|
| 35 |
FloatLiteralDec = ( '0' | ({NonZeroDigit} ({Number}|'_')*) ) ([LuU]|'Lu'|'LU'|'uL'|'UL')? ([fF]'i'|'Li'|'i') ( [eE][-+]?({Number}|'_')+ )? |
|---|
| 36 |
FloatLiteralBin = '0' [bB] {BinaryDigit}+ ([LuU]|'Lu'|'LU'|'uL'|'UL')? ([fF]'i'|'Li'|'i') ( [eE][-+]?({Number}|'_')+ )? |
|---|
| 37 |
FloatLiteralOct = '0' {OctalDigit}+ ([LuU]|'Lu'|'LU'|'uL'|'UL')? ([fF]'i'|'Li'|'i') ( [eE][-+]?({Number}|'_')+ )? |
|---|
| 38 |
FloatLiteralHex = '0' [xX] {HexDigit}+ ([LuU]|'Lu'|'LU'|'uL'|'UL')? ([fF]'i'|'Li'|'i') ( [eE][-+]?({Number}|'_')+ )? |
|---|
| 39 |
|
|---|
| 40 |
DecimalFloat1 = {DecimalDigit}+ '.' ( {DecimalDigit}+ ( [eE][-+]?{DecimalDigit}+ )? )? |
|---|
| 41 |
DecimalFloat2 = '.' ( '0' | ({NonZeroDigit} {DecimalDigit}*) ) ( [eE][-+]?{DecimalDigit}+ )? |
|---|
| 42 |
DecimalFloat3 = {Number} {DecimalDigit}* [eE][-+]?{DecimalDigit}+ |
|---|
| 43 |
|
|---|
| 44 |
HexFloat1 = '0' [xX] {HexDigit} '.' {HexDigit}+ [pP][-+]?{HexDigit}+ |
|---|
| 45 |
HexFloat2 = '0' [xX] '.' {HexDigit}+ [pP][-+]?{HexDigit}+ |
|---|
| 46 |
HexFloat3 = '0' [xX] {HexDigit}+ [pP][-+]?{HexDigit}+ |
|---|
| 47 |
|
|---|
| 48 |
{DoubleQuotedStringChar} = {Printable} - ["] |
|---|
| 49 |
DoubleQuotedString = '"' ({DoubleQuotedStringChar} | '\' {Printable})* '"' [cwd]? |
|---|
| 50 |
WysiwygString = 'r"' {DoubleQuotedStringChar}* '"' [cwd]? |
|---|
| 51 |
|
|---|
| 52 |
{AlternateWysiwygStringChar} = {Printable} - [`] |
|---|
| 53 |
AlternateWysiwygString = '`' {DoubleQuotedStringChar}* '`' [cwd]? |
|---|
| 54 |
|
|---|
| 55 |
{HexStringDigit} = {HexDigit} + {Whitespace} |
|---|
| 56 |
HexString = 'x"' {HexStringDigit}* '"' [cwd]? |
|---|
| 57 |
|
|---|
| 58 |
! Not yet supported, the following won't work quite right |
|---|
| 59 |
! DelimitedString = 'q"' {DoubleQuotedStringChar}* '"' [cwd]? |
|---|
| 60 |
|
|---|
| 61 |
{CharacterLiteralChar} = {Printable} - [''] |
|---|
| 62 |
CharacterLiteral = '' ({CharacterLiteralChar} | '\' {Printable}) '' [cwd]? |
|---|
| 63 |
|
|---|
| 64 |
! -- Rules --------------------------------------------- |
|---|
| 65 |
|
|---|
| 66 |
<Module> ::= <Module> <Item> |
|---|
| 67 |
| |
|---|
| 68 |
|
|---|
| 69 |
<Item> ::= Identifier |
|---|
| 70 |
| Decimal |
|---|
| 71 |
| Binary |
|---|
| 72 |
| Octal |
|---|
| 73 |
| Hexadecimal |
|---|
| 74 |
| FloatLiteralDec |
|---|
| 75 |
| FloatLiteralBin |
|---|
| 76 |
| FloatLiteralOct |
|---|
| 77 |
| FloatLiteralHex |
|---|
| 78 |
| DecimalFloat1 |
|---|
| 79 |
| DecimalFloat2 |
|---|
| 80 |
| DecimalFloat3 |
|---|
| 81 |
| HexFloat1 |
|---|
| 82 |
| HexFloat2 |
|---|
| 83 |
| HexFloat3 |
|---|
| 84 |
| DoubleQuotedString |
|---|
| 85 |
| WysiwygString |
|---|
| 86 |
| AlternateWysiwygString |
|---|
| 87 |
| HexString !| DelimitedString |
|---|
| 88 |
| CharacterLiteral |
|---|
| 89 |
| NestedCommentStart |
|---|
| 90 |
| NestedCommentEnd |
|---|
| 91 |
| '/' |
|---|
| 92 |
| '/=' |
|---|
| 93 |
| '.' |
|---|
| 94 |
| '..' |
|---|
| 95 |
| '...' |
|---|
| 96 |
| '&' |
|---|
| 97 |
| '&=' |
|---|
| 98 |
| '&&' |
|---|
| 99 |
| '|' |
|---|
| 100 |
| '|=' |
|---|
| 101 |
| '||' |
|---|
| 102 |
| '-' |
|---|
| 103 |
| '-=' |
|---|
| 104 |
| '--' |
|---|
| 105 |
| '+' |
|---|
| 106 |
| '+=' |
|---|
| 107 |
| '++' |
|---|
| 108 |
| '<' |
|---|
| 109 |
| '<=' |
|---|
| 110 |
| '<<' |
|---|
| 111 |
| '<<=' |
|---|
| 112 |
| '<>' |
|---|
| 113 |
| '<>=' |
|---|
| 114 |
| '>' |
|---|
| 115 |
| '>=' |
|---|
| 116 |
| '>>=' |
|---|
| 117 |
| '>>>=' |
|---|
| 118 |
| '>>' |
|---|
| 119 |
| '>>>' |
|---|
| 120 |
| '!' |
|---|
| 121 |
| '!=' |
|---|
| 122 |
| '!<>' |
|---|
| 123 |
| '!<>=' |
|---|
| 124 |
| '!<' |
|---|
| 125 |
| '!<=' |
|---|
| 126 |
| '!>' |
|---|
| 127 |
| '!>=' |
|---|
| 128 |
| '(' |
|---|
| 129 |
| ')' |
|---|
| 130 |
| '[' |
|---|
| 131 |
| ']' |
|---|
| 132 |
| 'q{' |
|---|
| 133 |
| '{' |
|---|
| 134 |
| '}' |
|---|
| 135 |
| '?' |
|---|
| 136 |
| ',' |
|---|
| 137 |
| ';' |
|---|
| 138 |
| ':' |
|---|
| 139 |
| '$' |
|---|
| 140 |
| '=' |
|---|
| 141 |
| '==' |
|---|
| 142 |
| '*' |
|---|
| 143 |
| '*=' |
|---|
| 144 |
| '%' |
|---|
| 145 |
| '%=' |
|---|
| 146 |
| '^' |
|---|
| 147 |
| '^=' |
|---|
| 148 |
| '~' |
|---|
| 149 |
| '~=' |
|---|
| 150 |
| 'abstract' |
|---|
| 151 |
| 'alias' |
|---|
| 152 |
| 'align' |
|---|
| 153 |
| 'asm' |
|---|
| 154 |
| 'assert' |
|---|
| 155 |
| 'auto' |
|---|
| 156 |
| 'body' |
|---|
| 157 |
| 'bool' |
|---|
| 158 |
| 'break' |
|---|
| 159 |
| 'byte' |
|---|
| 160 |
| 'case' |
|---|
| 161 |
| 'cast' |
|---|
| 162 |
| 'catch' |
|---|
| 163 |
| 'cdouble' |
|---|
| 164 |
| 'cent' |
|---|
| 165 |
| 'cfloat' |
|---|
| 166 |
| 'char' |
|---|
| 167 |
| 'class' |
|---|
| 168 |
| 'const' |
|---|
| 169 |
| 'continue' |
|---|
| 170 |
| 'creal' |
|---|
| 171 |
| 'dchar' |
|---|
| 172 |
| 'debug' |
|---|
| 173 |
| 'default' |
|---|
| 174 |
| 'delegate' |
|---|
| 175 |
| 'delete' |
|---|
| 176 |
| 'deprecated' |
|---|
| 177 |
| 'do' |
|---|
| 178 |
| 'double' |
|---|
| 179 |
| 'else' |
|---|
| 180 |
| 'enum' |
|---|
| 181 |
| 'export' |
|---|
| 182 |
| 'extern' |
|---|
| 183 |
| 'false' |
|---|
| 184 |
| 'final' |
|---|
| 185 |
| 'finally' |
|---|
| 186 |
| 'float' |
|---|
| 187 |
| 'for' |
|---|
| 188 |
| 'foreach' |
|---|
| 189 |
| 'foreach_reverse' |
|---|
| 190 |
| 'function' |
|---|
| 191 |
| 'goto' |
|---|
| 192 |
| 'idouble' |
|---|
| 193 |
| 'if' |
|---|
| 194 |
| 'ifloat' |
|---|
| 195 |
| 'immutable' |
|---|
| 196 |
| 'import' |
|---|
| 197 |
| 'in' |
|---|
| 198 |
| 'inout' |
|---|
| 199 |
| 'int' |
|---|
| 200 |
| 'interface' |
|---|
| 201 |
| 'invariant' |
|---|
| 202 |
| 'ireal' |
|---|
| 203 |
| 'is' |
|---|
| 204 |
| 'lazy' |
|---|
| 205 |
| 'long' |
|---|
| 206 |
| 'macro' |
|---|
| 207 |
| 'mixin' |
|---|
| 208 |
| 'module' |
|---|
| 209 |
| 'new' |
|---|
| 210 |
| 'nothrow' |
|---|
| 211 |
| 'null' |
|---|
| 212 |
| 'out' |
|---|
| 213 |
| 'override' |
|---|
| 214 |
| 'package' |
|---|
| 215 |
| 'pragma' |
|---|
| 216 |
| 'private' |
|---|
| 217 |
| 'protected' |
|---|
| 218 |
| 'public' |
|---|
| 219 |
| 'pure' |
|---|
| 220 |
| 'real' |
|---|
| 221 |
| 'ref' |
|---|
| 222 |
| 'return' |
|---|
| 223 |
| 'scope' |
|---|
| 224 |
| 'shared' |
|---|
| 225 |
| 'short' |
|---|
| 226 |
| 'static' |
|---|
| 227 |
| 'struct' |
|---|
| 228 |
| 'super' |
|---|
| 229 |
| 'switch' |
|---|
| 230 |
| 'synchronized' |
|---|
| 231 |
| 'template' |
|---|
| 232 |
| 'this' |
|---|
| 233 |
| 'throw' |
|---|
| 234 |
| 'true' |
|---|
| 235 |
| 'try' |
|---|
| 236 |
| 'typedef' |
|---|
| 237 |
| 'typeid' |
|---|
| 238 |
| 'typeof' |
|---|
| 239 |
| 'ubyte' |
|---|
| 240 |
| 'ucent' |
|---|
| 241 |
| 'uint' |
|---|
| 242 |
| 'ulong' |
|---|
| 243 |
| 'union' |
|---|
| 244 |
| 'unittest' |
|---|
| 245 |
| 'ushort' |
|---|
| 246 |
| 'version' |
|---|
| 247 |
| 'void' |
|---|
| 248 |
| 'volatile' |
|---|
| 249 |
| 'wchar' |
|---|
| 250 |
| 'while' |
|---|
| 251 |
| 'with' |
|---|
| 252 |
| '__FILE__' |
|---|
| 253 |
| '__LINE__' |
|---|
| 254 |
| '__gshared' |
|---|
| 255 |
| '__thread' |
|---|
| 256 |
| '__traits' |
|---|
| 257 |
| '@safe' |
|---|
| 258 |
| '@trusted' |
|---|
| 259 |
| '@system' |
|---|
| 260 |
| '@property' |
|---|
| 261 |
| '__DATE__' |
|---|
| 262 |
| '__EOF__' |
|---|
| 263 |
| '__TIME__' |
|---|
| 264 |
| '__TIMESTAMP__' |
|---|
| 265 |
| '__VENDOR__' |
|---|
| 266 |
| '__VERSION__' |
|---|
| 267 |
| '#line' |
|---|