Skip to content

Commit

Permalink
Update Scala keywords to support Scala 3
Browse files Browse the repository at this point in the history
Add `given`, `transparent`, and `using` keywords.
  • Loading branch information
julienrf committed Jul 26, 2022
1 parent b9512b2 commit 3e8f3b9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion components/prism-scala.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Prism.languages.scala = Prism.languages.extend('java', {
pattern: /("|')(?:\\.|(?!\1)[^\\\r\n])*\1/,
greedy: true
},
'keyword': /<-|=>|\b(?:abstract|case|catch|class|def|do|else|extends|final|finally|for|forSome|if|implicit|import|lazy|match|new|null|object|override|package|private|protected|return|sealed|self|super|this|throw|trait|try|type|val|var|while|with|yield)\b/,
'keyword': /<-|=>|\b(?:abstract|case|catch|class|def|derives|do|else|enum|extends|extension|final|finally|for|forSome|given|if|implicit|import|infix|inline|lazy|match|new|null|object|opaque|open|override|package|private|protected|return|sealed|self|super|this|throw|trait|transparent|try|type|using|val|var|while|with|yield)\b/,
'number': /\b0x(?:[\da-f]*\.)?[\da-f]+|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e\d+)?[dfl]?/i,
'builtin': /\b(?:Any|AnyRef|AnyVal|Boolean|Byte|Char|Double|Float|Int|Long|Nothing|Short|String|Unit)\b/,
'symbol': /'[^\d\s\\]\w*/
Expand Down
28 changes: 18 additions & 10 deletions tests/languages/scala/keyword_feature.test
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
<- =>

abstract case catch
class def do else
extends final finally
for forSome if
implicit import; lazy
class def derives do
else enum extends extension
final finally
for forSome given if
implicit import;
infix inline lazy
match new null object
opaque open
override package private
protected return sealed
self super this throw
trait try type val
trait transparent try
type using val
var while with yield

----------------------------------------------------
Expand All @@ -18,15 +22,19 @@ var while with yield
["keyword", "<-"], ["keyword", "=>"],

["keyword", "abstract"], ["keyword", "case"], ["keyword", "catch"],
["keyword", "class"], ["keyword", "def"], ["keyword", "do"], ["keyword", "else"],
["keyword", "extends"], ["keyword", "final"], ["keyword", "finally"],
["keyword", "for"], ["keyword", "forSome"], ["keyword", "if"],
["keyword", "implicit"], ["keyword", "import"], ["punctuation", ";"], ["keyword", "lazy"],
["keyword", "class"], ["keyword", "def"], ["keyword", "derives"], ["keyword", "do"],
["keyword", "else"], ["keyword", "enum"], ["keyword", "extends"], ["keyword", "extension"],
["keyword", "final"], ["keyword", "finally"],
["keyword", "for"], ["keyword", "forSome"], ["keyword", "given"], ["keyword", "if"],
["keyword", "implicit"], ["keyword", "import"], ["punctuation", ";"],
["keyword", "infix"], ["keyword", "inline"], ["keyword", "lazy"],
["keyword", "match"], ["keyword", "new"], ["keyword", "null"], ["keyword", "object"],
["keyword", "opaque"], ["keyword", "open"],
["keyword", "override"], ["keyword", "package"], ["keyword", "private"],
["keyword", "protected"], ["keyword", "return"], ["keyword", "sealed"],
["keyword", "self"], ["keyword", "super"], ["keyword", "this"], ["keyword", "throw"],
["keyword", "trait"], ["keyword", "try"], ["keyword", "type"], ["keyword", "val"],
["keyword", "trait"], ["keyword", "transparent"], ["keyword", "try"],
["keyword", "type"], ["keyword", "using"], ["keyword", "val"],
["keyword", "var"], ["keyword", "while"], ["keyword", "with"], ["keyword", "yield"]
]

Expand Down

0 comments on commit 3e8f3b9

Please sign in to comment.