diff options
| author | Shengyu Zhang <reg@silverrainz.me> | 2022-06-25 23:16:52 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-25 17:16:52 +0200 |
| commit | cc7388620088153eff52aad5a08eb5d76aed4c96 (patch) | |
| tree | 2f5ed256149013c9566a2be8ca8745cefee6e3b0 /pygments/lexers | |
| parent | 7c8aabf30b2305b52bf00538c7d742d4d335277f (diff) | |
| download | pygments-git-cc7388620088153eff52aad5a08eb5d76aed4c96.tar.gz | |
Add 1.18 generics support for go lexer (#2167)
- Add new predeclared identifiers: `any` and `comparable`
- Add new operator for type parameters: `~` and `|`
Ref: https://go.dev/ref/spec
Diffstat (limited to 'pygments/lexers')
| -rw-r--r-- | pygments/lexers/go.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/pygments/lexers/go.py b/pygments/lexers/go.py index ce214bc5..a5de48af 100644 --- a/pygments/lexers/go.py +++ b/pygments/lexers/go.py @@ -52,7 +52,7 @@ class GoLexer(RegexLexer): 'int', 'int8', 'int16', 'int32', 'int64', 'float', 'float32', 'float64', 'complex64', 'complex128', 'byte', 'rune', - 'string', 'bool', 'error', 'uintptr', + 'string', 'bool', 'error', 'uintptr', 'any', 'comparable', 'print', 'println', 'panic', 'recover', 'close', 'complex', 'real', 'imag', 'len', 'cap', 'append', 'copy', 'delete', 'new', 'make'), suffix=r'\b(\()'), @@ -62,7 +62,7 @@ class GoLexer(RegexLexer): 'int', 'int8', 'int16', 'int32', 'int64', 'float', 'float32', 'float64', 'complex64', 'complex128', 'byte', 'rune', - 'string', 'bool', 'error', 'uintptr'), suffix=r'\b'), + 'string', 'bool', 'error', 'uintptr', 'any', 'comparable'), suffix=r'\b'), Keyword.Type), # imaginary_lit (r'\d+i', Number), @@ -91,7 +91,8 @@ class GoLexer(RegexLexer): (r'"(\\\\|\\[^\\]|[^"\\])*"', String), # Tokens (r'(<<=|>>=|<<|>>|<=|>=|&\^=|&\^|\+=|-=|\*=|/=|%=|&=|\|=|&&|\|\|' - r'|<-|\+\+|--|==|!=|:=|\.\.\.|[+\-*/%&])', Operator), + r'|<-|\+\+|--|==|!=|:=|\.\.\.|[+\-*/%&]' + r'|~|\|)', Operator), (r'[|^<>=!()\[\]{}.,;:]', Punctuation), # identifier (r'[^\W\d]\w*', Name.Other), |
