1
0
mirror of https://github.com/alecthomas/chroma.git synced 2025-03-19 21:10:15 +02:00

Update Java lexer to use Punctuation where applicable (#254) (#255)

This commit is contained in:
Devon Romanko 2019-05-29 21:19:12 -04:00 committed by Alec Thomas
parent f1ba5bf4f3
commit 399337e012
3 changed files with 16 additions and 15 deletions

View File

@ -20,7 +20,7 @@ var Java = internal.Register(MustNewLexer(
{`//.*?\n`, CommentSingle, nil}, {`//.*?\n`, CommentSingle, nil},
{`/\*.*?\*/`, CommentMultiline, nil}, {`/\*.*?\*/`, CommentMultiline, nil},
{`(assert|break|case|catch|continue|default|do|else|finally|for|if|goto|instanceof|new|return|switch|this|throw|try|while)\b`, Keyword, nil}, {`(assert|break|case|catch|continue|default|do|else|finally|for|if|goto|instanceof|new|return|switch|this|throw|try|while)\b`, Keyword, nil},
{`((?:(?:[^\W\d]|\$)[\w.\[\]$<>]*\s+)+?)((?:[^\W\d]|\$)[\w$]*)(\s*)(\()`, ByGroups(UsingSelf("root"), NameFunction, Text, Operator), nil}, {`((?:(?:[^\W\d]|\$)[\w.\[\]$<>]*\s+)+?)((?:[^\W\d]|\$)[\w$]*)(\s*)`, ByGroups(UsingSelf("root"), NameFunction, Text, Operator), nil},
{`@[^\W\d][\w.]*`, NameDecorator, nil}, {`@[^\W\d][\w.]*`, NameDecorator, nil},
{`(abstract|const|enum|extends|final|implements|native|private|protected|public|static|strictfp|super|synchronized|throws|transient|volatile)\b`, KeywordDeclaration, nil}, {`(abstract|const|enum|extends|final|implements|native|private|protected|public|static|strictfp|super|synchronized|throws|transient|volatile)\b`, KeywordDeclaration, nil},
{`(boolean|byte|char|double|float|int|long|short|void)\b`, KeywordType, nil}, {`(boolean|byte|char|double|float|int|long|short|void)\b`, KeywordType, nil},
@ -30,7 +30,7 @@ var Java = internal.Register(MustNewLexer(
{`(import(?:\s+static)?)(\s+)`, ByGroups(KeywordNamespace, Text), Push("import")}, {`(import(?:\s+static)?)(\s+)`, ByGroups(KeywordNamespace, Text), Push("import")},
{`"(\\\\|\\"|[^"])*"`, LiteralString, nil}, {`"(\\\\|\\"|[^"])*"`, LiteralString, nil},
{`'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'`, LiteralStringChar, nil}, {`'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'`, LiteralStringChar, nil},
{`(\.)((?:[^\W\d]|\$)[\w$]*)`, ByGroups(Operator, NameAttribute), nil}, {`(\.)((?:[^\W\d]|\$)[\w$]*)`, ByGroups(Punctuation, NameAttribute), nil},
{`^\s*([^\W\d]|\$)[\w$]*:`, NameLabel, nil}, {`^\s*([^\W\d]|\$)[\w$]*:`, NameLabel, nil},
{`([^\W\d]|\$)[\w$]*`, Name, nil}, {`([^\W\d]|\$)[\w$]*`, Name, nil},
{`([0-9][0-9_]*\.([0-9][0-9_]*)?|\.[0-9][0-9_]*)([eE][+\-]?[0-9][0-9_]*)?[fFdD]?|[0-9][eE][+\-]?[0-9][0-9_]*[fFdD]?|[0-9]([eE][+\-]?[0-9][0-9_]*)?[fFdD]|0[xX]([0-9a-fA-F][0-9a-fA-F_]*\.?|([0-9a-fA-F][0-9a-fA-F_]*)?\.[0-9a-fA-F][0-9a-fA-F_]*)[pP][+\-]?[0-9][0-9_]*[fFdD]?`, LiteralNumberFloat, nil}, {`([0-9][0-9_]*\.([0-9][0-9_]*)?|\.[0-9][0-9_]*)([eE][+\-]?[0-9][0-9_]*)?[fFdD]?|[0-9][eE][+\-]?[0-9][0-9_]*[fFdD]?|[0-9]([eE][+\-]?[0-9][0-9_]*)?[fFdD]|0[xX]([0-9a-fA-F][0-9a-fA-F_]*\.?|([0-9a-fA-F][0-9a-fA-F_]*)?\.[0-9a-fA-F][0-9a-fA-F_]*)[pP][+\-]?[0-9][0-9_]*[fFdD]?`, LiteralNumberFloat, nil},
@ -38,7 +38,8 @@ var Java = internal.Register(MustNewLexer(
{`0[bB][01][01_]*[lL]?`, LiteralNumberBin, nil}, {`0[bB][01][01_]*[lL]?`, LiteralNumberBin, nil},
{`0[0-7_]+[lL]?`, LiteralNumberOct, nil}, {`0[0-7_]+[lL]?`, LiteralNumberOct, nil},
{`0|[1-9][0-9_]*[lL]?`, LiteralNumberInteger, nil}, {`0|[1-9][0-9_]*[lL]?`, LiteralNumberInteger, nil},
{`[~^*!%&\[\](){}<>|+=:;,./?-]`, Operator, nil}, {`[~^*!%&<>|+=:/?-]`, Operator, nil},
{`[\[\](){};,.]`, Punctuation, nil},
{`\n`, Text, nil}, {`\n`, Text, nil},
}, },
"class": { "class": {

View File

@ -1068,17 +1068,17 @@
{"type":"Keyword","value":"return"}, {"type":"Keyword","value":"return"},
{"type":"Text","value":" "}, {"type":"Text","value":" "},
{"type":"Name","value":"Double"}, {"type":"Name","value":"Double"},
{"type":"Operator","value":"."}, {"type":"Punctuation","value":"."},
{"type":"NameAttribute","value":"valueOf"}, {"type":"NameAttribute","value":"valueOf"},
{"type":"Operator","value":"("}, {"type":"Punctuation","value":"("},
{"type":"Name","value":"Math"}, {"type":"Name","value":"Math"},
{"type":"Operator","value":"."}, {"type":"Punctuation","value":"."},
{"type":"NameAttribute","value":"log"}, {"type":"NameAttribute","value":"log"},
{"type":"Operator","value":"("}, {"type":"Punctuation","value":"("},
{"type":"Name","value":"input"}, {"type":"Name","value":"input"},
{"type":"Operator","value":"."}, {"type":"Punctuation","value":"."},
{"type":"NameAttribute","value":"doubleValue"}, {"type":"NameAttribute","value":"doubleValue"},
{"type":"Operator","value":"()));"}, {"type":"Punctuation","value":"()));"},
{"type":"LiteralStringHeredoc","value":"'"}, {"type":"LiteralStringHeredoc","value":"'"},
{"type":"Punctuation","value":";"}, {"type":"Punctuation","value":";"},
{"type":"TextWhitespace","value":"\n"} {"type":"TextWhitespace","value":"\n"}

View File

@ -119,17 +119,17 @@
{"type":"Keyword","value":"return"}, {"type":"Keyword","value":"return"},
{"type":"Text","value":" "}, {"type":"Text","value":" "},
{"type":"Name","value":"Double"}, {"type":"Name","value":"Double"},
{"type":"Operator","value":"."}, {"type":"Punctuation","value":"."},
{"type":"NameAttribute","value":"valueOf"}, {"type":"NameAttribute","value":"valueOf"},
{"type":"Operator","value":"("}, {"type":"Punctuation","value":"("},
{"type":"Name","value":"Math"}, {"type":"Name","value":"Math"},
{"type":"Operator","value":"."}, {"type":"Punctuation","value":"."},
{"type":"NameAttribute","value":"log"}, {"type":"NameAttribute","value":"log"},
{"type":"Operator","value":"("}, {"type":"Punctuation","value":"("},
{"type":"Name","value":"input"}, {"type":"Name","value":"input"},
{"type":"Operator","value":"."}, {"type":"Punctuation","value":"."},
{"type":"NameAttribute","value":"doubleValue"}, {"type":"NameAttribute","value":"doubleValue"},
{"type":"Operator","value":"()));"}, {"type":"Punctuation","value":"()));"},
{"type":"LiteralStringHeredoc","value":"'"}, {"type":"LiteralStringHeredoc","value":"'"},
{"type":"Punctuation","value":";"}, {"type":"Punctuation","value":";"},
{"type":"TextWhitespace","value":"\n"}, {"type":"TextWhitespace","value":"\n"},