| 1 | <?php |
| 2 | namespace Std\Lib\Syntax; |
| 3 | |
| 4 | class Go extends Language { |
| 5 | protected string $digitSep = '_'; |
| 6 | |
| 7 | protected array $rules = [ |
| 8 | // 生文字列 `…`(複数行可) |
| 9 | ['re' => '`[^`]*`?', 'class' => 'string'], |
| 10 | ]; |
| 11 | |
| 12 | protected array $tokens = [ |
| 13 | 'keyword' => [ |
| 14 | 'break', 'case', 'chan', 'const', 'continue', 'default', 'defer', 'else', 'fallthrough', 'for', 'func', 'go', 'goto', 'if', 'import', 'interface', 'map', |
| 15 | 'package', 'range', 'return', 'select', 'struct', 'switch', 'type', 'var', |
| 16 | ], |
| 17 | 'constant' => [ |
| 18 | 'true', 'false', 'iota', 'nil', |
| 19 | ], |
| 20 | 'type' => [ |
| 21 | 'uint8', 'uint16', 'uint32', 'uint64', 'int8', 'int16', 'int32', 'int64', 'float32', 'float64', 'complex64', 'complex128', |
| 22 | 'byte', 'rune', 'string', 'bool', 'uint', 'int', 'uintptr', 'error', 'any', 'comparable', |
| 23 | ], |
| 24 | 'builtin' => [ |
| 25 | 'append', 'cap', 'clear', 'close', 'complex', 'copy', 'delete', 'imag', 'len', 'make', 'max', 'min', 'new', 'panic', 'print', 'println', 'real', 'recover', |
| 26 | ], |
| 27 | ]; |
| 28 | } |