Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(lexers/go): "~" is a valid token #926

Merged
merged 2 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lexers/go.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func goRules() Rules {
{`"(\\\\|\\"|[^"])*"`, LiteralString, nil},
{`(<<=|>>=|<<|>>|<=|>=|&\^=|&\^|\+=|-=|\*=|/=|%=|&=|\|=|&&|\|\||<-|\+\+|--|==|!=|:=|\.\.\.|[+\-*/%&])`, Operator, nil},
{`([a-zA-Z_]\w*)(\s*)(\()`, ByGroups(NameFunction, UsingSelf("root"), Punctuation), nil},
{`[|^<>=!()\[\]{}.,;:]`, Punctuation, nil},
{`[|^<>=!()\[\]{}.,;:~]`, Punctuation, nil},
{`[^\W\d]\w*`, NameOther, nil},
},
}
Expand Down
6 changes: 5 additions & 1 deletion lexers/testdata/go.actual
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@ func hello(a int) {
return func() int {
return i
}
} // One last thing
} // One last thing

type Int interface {
~int | ~int8 | ~int16 | ~int32 | ~int64
}
36 changes: 35 additions & 1 deletion lexers/testdata/go.expected
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,39 @@
{"type":"Text","value":"\n"},
{"type":"Punctuation","value":"}"},
{"type":"Text","value":" "},
{"type":"CommentSingle","value":"// One last thing\n"}
{"type":"CommentSingle","value":"// One last thing\n"},
{"type":"Text","value":"\n"},
{"type":"KeywordDeclaration","value":"type"},
{"type":"Text","value":" "},
{"type":"NameOther","value":"Int"},
{"type":"Text","value":" "},
{"type":"KeywordDeclaration","value":"interface"},
{"type":"Text","value":" "},
{"type":"Punctuation","value":"{"},
{"type":"Text","value":"\n\t"},
{"type":"Punctuation","value":"~"},
{"type":"KeywordType","value":"int"},
{"type":"Text","value":" "},
{"type":"Punctuation","value":"|"},
{"type":"Text","value":" "},
{"type":"Punctuation","value":"~"},
{"type":"KeywordType","value":"int8"},
{"type":"Text","value":" "},
{"type":"Punctuation","value":"|"},
{"type":"Text","value":" "},
{"type":"Punctuation","value":"~"},
{"type":"KeywordType","value":"int16"},
{"type":"Text","value":" "},
{"type":"Punctuation","value":"|"},
{"type":"Text","value":" "},
{"type":"Punctuation","value":"~"},
{"type":"KeywordType","value":"int32"},
{"type":"Text","value":" "},
{"type":"Punctuation","value":"|"},
{"type":"Text","value":" "},
{"type":"Punctuation","value":"~"},
{"type":"KeywordType","value":"int64"},
{"type":"Text","value":"\n"},
{"type":"Punctuation","value":"}"},
{"type":"Text","value":"\n"}
]