diff options
author | Maxime Kjaer <maxime.kjaer@gmail.com> | 2021-03-01 11:39:20 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-01 11:39:20 +0100 |
commit | 37113b095ee9a445187a8478589010347b7a9687 (patch) | |
tree | 29538f8314345a1a4bcb62406dd58b336107f0a2 | |
parent | c1a0d82acbe6fa026a1f6843fee00cc1df626549 (diff) | |
download | pygments-git-37113b095ee9a445187a8478589010347b7a9687.tar.gz |
Rewrite Scala lexer for Scala 3 (#1694)
74 files changed, 6083 insertions, 553 deletions
diff --git a/pygments/lexers/jvm.py b/pygments/lexers/jvm.py index f6e12031..77083c82 100644 --- a/pygments/lexers/jvm.py +++ b/pygments/lexers/jvm.py @@ -156,226 +156,278 @@ class ScalaLexer(RegexLexer): flags = re.MULTILINE | re.DOTALL - # don't use raw unicode strings! - op = ('[-~\\^\\*!%&\\\\<>\\|+=:/?@\u00a6-\u00a7\u00a9\u00ac\u00ae\u00b0-\u00b1' - '\u00b6\u00d7\u00f7\u03f6\u0482\u0606-\u0608\u060e-\u060f\u06e9' - '\u06fd-\u06fe\u07f6\u09fa\u0b70\u0bf3-\u0bf8\u0bfa\u0c7f\u0cf1-\u0cf2' - '\u0d79\u0f01-\u0f03\u0f13-\u0f17\u0f1a-\u0f1f\u0f34\u0f36\u0f38' - '\u0fbe-\u0fc5\u0fc7-\u0fcf\u109e-\u109f\u1360\u1390-\u1399\u1940' - '\u19e0-\u19ff\u1b61-\u1b6a\u1b74-\u1b7c\u2044\u2052\u207a-\u207c' - '\u208a-\u208c\u2100-\u2101\u2103-\u2106\u2108-\u2109\u2114\u2116-\u2118' - '\u211e-\u2123\u2125\u2127\u2129\u212e\u213a-\u213b\u2140-\u2144' - '\u214a-\u214d\u214f\u2190-\u2328\u232b-\u244a\u249c-\u24e9\u2500-\u2767' - '\u2794-\u27c4\u27c7-\u27e5\u27f0-\u2982\u2999-\u29d7\u29dc-\u29fb' - '\u29fe-\u2b54\u2ce5-\u2cea\u2e80-\u2ffb\u3004\u3012-\u3013\u3020' - '\u3036-\u3037\u303e-\u303f\u3190-\u3191\u3196-\u319f\u31c0-\u31e3' - '\u3200-\u321e\u322a-\u3250\u3260-\u327f\u328a-\u32b0\u32c0-\u33ff' - '\u4dc0-\u4dff\ua490-\ua4c6\ua828-\ua82b\ufb29\ufdfd\ufe62\ufe64-\ufe66' - '\uff0b\uff1c-\uff1e\uff5c\uff5e\uffe2\uffe4\uffe8-\uffee\ufffc-\ufffd]+') - - letter = ('[a-zA-Z\\$_\u00aa\u00b5\u00ba\u00c0-\u00d6\u00d8-\u00f6' - '\u00f8-\u02af\u0370-\u0373\u0376-\u0377\u037b-\u037d\u0386' - '\u0388-\u03f5\u03f7-\u0481\u048a-\u0556\u0561-\u0587\u05d0-\u05f2' - '\u0621-\u063f\u0641-\u064a\u066e-\u066f\u0671-\u06d3\u06d5' - '\u06ee-\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5' - '\u07b1\u07ca-\u07ea\u0904-\u0939\u093d\u0950\u0958-\u0961' - '\u0972-\u097f\u0985-\u09b9\u09bd\u09ce\u09dc-\u09e1\u09f0-\u09f1' - '\u0a05-\u0a39\u0a59-\u0a5e\u0a72-\u0a74\u0a85-\u0ab9\u0abd' - '\u0ad0-\u0ae1\u0b05-\u0b39\u0b3d\u0b5c-\u0b61\u0b71\u0b83-\u0bb9' - '\u0bd0\u0c05-\u0c3d\u0c58-\u0c61\u0c85-\u0cb9\u0cbd\u0cde-\u0ce1' - '\u0d05-\u0d3d\u0d60-\u0d61\u0d7a-\u0d7f\u0d85-\u0dc6\u0e01-\u0e30' - '\u0e32-\u0e33\u0e40-\u0e45\u0e81-\u0eb0\u0eb2-\u0eb3\u0ebd-\u0ec4' - '\u0edc-\u0f00\u0f40-\u0f6c\u0f88-\u0f8b\u1000-\u102a\u103f' - '\u1050-\u1055\u105a-\u105d\u1061\u1065-\u1066\u106e-\u1070' - '\u1075-\u1081\u108e\u10a0-\u10fa\u1100-\u135a\u1380-\u138f' - '\u13a0-\u166c\u166f-\u1676\u1681-\u169a\u16a0-\u16ea\u16ee-\u1711' - '\u1720-\u1731\u1740-\u1751\u1760-\u1770\u1780-\u17b3\u17dc' - '\u1820-\u1842\u1844-\u18a8\u18aa-\u191c\u1950-\u19a9\u19c1-\u19c7' - '\u1a00-\u1a16\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae-\u1baf' - '\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c77\u1d00-\u1d2b\u1d62-\u1d77' - '\u1d79-\u1d9a\u1e00-\u1fbc\u1fbe\u1fc2-\u1fcc\u1fd0-\u1fdb' - '\u1fe0-\u1fec\u1ff2-\u1ffc\u2071\u207f\u2102\u2107\u210a-\u2113' - '\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139' - '\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c7c' - '\u2c80-\u2ce4\u2d00-\u2d65\u2d80-\u2dde\u3006-\u3007\u3021-\u3029' - '\u3038-\u303a\u303c\u3041-\u3096\u309f\u30a1-\u30fa\u30ff-\u318e' - '\u31a0-\u31b7\u31f0-\u31ff\u3400-\u4db5\u4e00-\ua014\ua016-\ua48c' - '\ua500-\ua60b\ua610-\ua61f\ua62a-\ua66e\ua680-\ua697\ua722-\ua76f' - '\ua771-\ua787\ua78b-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822' - '\ua840-\ua873\ua882-\ua8b3\ua90a-\ua925\ua930-\ua946\uaa00-\uaa28' - '\uaa40-\uaa42\uaa44-\uaa4b\uac00-\ud7a3\uf900-\ufb1d\ufb1f-\ufb28' - '\ufb2a-\ufd3d\ufd50-\ufdfb\ufe70-\ufefc\uff21-\uff3a\uff41-\uff5a' - '\uff66-\uff6f\uff71-\uff9d\uffa0-\uffdc]') - - upper = ('[A-Z\\$_\u00c0-\u00d6\u00d8-\u00de\u0100\u0102\u0104\u0106\u0108' - '\u010a\u010c\u010e\u0110\u0112\u0114\u0116\u0118\u011a\u011c' - '\u011e\u0120\u0122\u0124\u0126\u0128\u012a\u012c\u012e\u0130' - '\u0132\u0134\u0136\u0139\u013b\u013d\u013f\u0141\u0143\u0145' - '\u0147\u014a\u014c\u014e\u0150\u0152\u0154\u0156\u0158\u015a' - '\u015c\u015e\u0160\u0162\u0164\u0166\u0168\u016a\u016c\u016e' - '\u0170\u0172\u0174\u0176\u0178-\u0179\u017b\u017d\u0181-\u0182' - '\u0184\u0186-\u0187\u0189-\u018b\u018e-\u0191\u0193-\u0194' - '\u0196-\u0198\u019c-\u019d\u019f-\u01a0\u01a2\u01a4\u01a6-\u01a7' - '\u01a9\u01ac\u01ae-\u01af\u01b1-\u01b3\u01b5\u01b7-\u01b8\u01bc' - '\u01c4\u01c7\u01ca\u01cd\u01cf\u01d1\u01d3\u01d5\u01d7\u01d9' - '\u01db\u01de\u01e0\u01e2\u01e4\u01e6\u01e8\u01ea\u01ec\u01ee' - '\u01f1\u01f4\u01f6-\u01f8\u01fa\u01fc\u01fe\u0200\u0202\u0204' - '\u0206\u0208\u020a\u020c\u020e\u0210\u0212\u0214\u0216\u0218' - '\u021a\u021c\u021e\u0220\u0222\u0224\u0226\u0228\u022a\u022c' - '\u022e\u0230\u0232\u023a-\u023b\u023d-\u023e\u0241\u0243-\u0246' - '\u0248\u024a\u024c\u024e\u0370\u0372\u0376\u0386\u0388-\u038f' - '\u0391-\u03ab\u03cf\u03d2-\u03d4\u03d8\u03da\u03dc\u03de\u03e0' - '\u03e2\u03e4\u03e6\u03e8\u03ea\u03ec\u03ee\u03f4\u03f7' - '\u03f9-\u03fa\u03fd-\u042f\u0460\u0462\u0464\u0466\u0468\u046a' - '\u046c\u046e\u0470\u0472\u0474\u0476\u0478\u047a\u047c\u047e' - '\u0480\u048a\u048c\u048e\u0490\u0492\u0494\u0496\u0498\u049a' - '\u049c\u049e\u04a0\u04a2\u04a4\u04a6\u04a8\u04aa\u04ac\u04ae' - '\u04b0\u04b2\u04b4\u04b6\u04b8\u04ba\u04bc\u04be\u04c0-\u04c1' - '\u04c3\u04c5\u04c7\u04c9\u04cb\u04cd\u04d0\u04d2\u04d4\u04d6' - '\u04d8\u04da\u04dc\u04de\u04e0\u04e2\u04e4\u04e6\u04e8\u04ea' - '\u04ec\u04ee\u04f0\u04f2\u04f4\u04f6\u04f8\u04fa\u04fc\u04fe' - '\u0500\u0502\u0504\u0506\u0508\u050a\u050c\u050e\u0510\u0512' - '\u0514\u0516\u0518\u051a\u051c\u051e\u0520\u0522\u0531-\u0556' - '\u10a0-\u10c5\u1e00\u1e02\u1e04\u1e06\u1e08\u1e0a\u1e0c\u1e0e' - '\u1e10\u1e12\u1e14\u1e16\u1e18\u1e1a\u1e1c\u1e1e\u1e20\u1e22' - '\u1e24\u1e26\u1e28\u1e2a\u1e2c\u1e2e\u1e30\u1e32\u1e34\u1e36' - '\u1e38\u1e3a\u1e3c\u1e3e\u1e40\u1e42\u1e44\u1e46\u1e48\u1e4a' - '\u1e4c\u1e4e\u1e50\u1e52\u1e54\u1e56\u1e58\u1e5a\u1e5c\u1e5e' - '\u1e60\u1e62\u1e64\u1e66\u1e68\u1e6a\u1e6c\u1e6e\u1e70\u1e72' - '\u1e74\u1e76\u1e78\u1e7a\u1e7c\u1e7e\u1e80\u1e82\u1e84\u1e86' - '\u1e88\u1e8a\u1e8c\u1e8e\u1e90\u1e92\u1e94\u1e9e\u1ea0\u1ea2' - '\u1ea4\u1ea6\u1ea8\u1eaa\u1eac\u1eae\u1eb0\u1eb2\u1eb4\u1eb6' - '\u1eb8\u1eba\u1ebc\u1ebe\u1ec0\u1ec2\u1ec4\u1ec6\u1ec8\u1eca' - '\u1ecc\u1ece\u1ed0\u1ed2\u1ed4\u1ed6\u1ed8\u1eda\u1edc\u1ede' - '\u1ee0\u1ee2\u1ee4\u1ee6\u1ee8\u1eea\u1eec\u1eee\u1ef0\u1ef2' - '\u1ef4\u1ef6\u1ef8\u1efa\u1efc\u1efe\u1f08-\u1f0f\u1f18-\u1f1d' - '\u1f28-\u1f2f\u1f38-\u1f3f\u1f48-\u1f4d\u1f59-\u1f5f' - '\u1f68-\u1f6f\u1fb8-\u1fbb\u1fc8-\u1fcb\u1fd8-\u1fdb' - '\u1fe8-\u1fec\u1ff8-\u1ffb\u2102\u2107\u210b-\u210d\u2110-\u2112' - '\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u2130-\u2133' - '\u213e-\u213f\u2145\u2183\u2c00-\u2c2e\u2c60\u2c62-\u2c64\u2c67' - '\u2c69\u2c6b\u2c6d-\u2c6f\u2c72\u2c75\u2c80\u2c82\u2c84\u2c86' - '\u2c88\u2c8a\u2c8c\u2c8e\u2c90\u2c92\u2c94\u2c96\u2c98\u2c9a' - '\u2c9c\u2c9e\u2ca0\u2ca2\u2ca4\u2ca6\u2ca8\u2caa\u2cac\u2cae' - '\u2cb0\u2cb2\u2cb4\u2cb6\u2cb8\u2cba\u2cbc\u2cbe\u2cc0\u2cc2' - '\u2cc4\u2cc6\u2cc8\u2cca\u2ccc\u2cce\u2cd0\u2cd2\u2cd4\u2cd6' - '\u2cd8\u2cda\u2cdc\u2cde\u2ce0\u2ce2\ua640\ua642\ua644\ua646' - '\ua648\ua64a\ua64c\ua64e\ua650\ua652\ua654\ua656\ua658\ua65a' - '\ua65c\ua65e\ua662\ua664\ua666\ua668\ua66a\ua66c\ua680\ua682' - '\ua684\ua686\ua688\ua68a\ua68c\ua68e\ua690\ua692\ua694\ua696' - '\ua722\ua724\ua726\ua728\ua72a\ua72c\ua72e\ua732\ua734\ua736' - '\ua738\ua73a\ua73c\ua73e\ua740\ua742\ua744\ua746\ua748\ua74a' - '\ua74c\ua74e\ua750\ua752\ua754\ua756\ua758\ua75a\ua75c\ua75e' - '\ua760\ua762\ua764\ua766\ua768\ua76a\ua76c\ua76e\ua779\ua77b' - '\ua77d-\ua77e\ua780\ua782\ua784\ua786\ua78b\uff21-\uff3a]') - - idrest = '%s(?:%s|[0-9])*(?:(?<=_)%s)?' % (letter, letter, op) - letter_letter_digit = '%s(?:%s|\\d)*' % (letter, letter) + opchar = '[!#%&*\\-\\/:?@^' + uni.combine('Sm', 'So') + ']' + letter = '[_\\$' + uni.combine('Ll', 'Lu', 'Lo', 'Nl', 'Lt') + ']' + upperLetter = '[' + uni.combine('Lu', 'Lt') + ']' + letterOrDigit = '(?:%s|[0-9])' % letter + letterOrDigitNoDollarSign = '(?:%s|[0-9])' % letter.replace('\\$', '') + alphaId = '%s+' % letter + simpleInterpolatedVariable = '%s%s*' % (letter, letterOrDigitNoDollarSign) + idrest = '%s%s*(?:(?<=_)%s+)?' % (letter, letterOrDigit, opchar) + idUpper = '%s%s*(?:(?<=_)%s+)?' % (upperLetter, letterOrDigit, opchar) + plainid = '(?:%s|%s+)' % (idrest, opchar) + backQuotedId = r'`[^`]+`' + anyId = r'(?:%s|%s)' % (plainid, backQuotedId) + notStartOfComment = r'(?!//|/\*)' + endOfLineMaybeWithComment = r'(?=\s*(//|$))' + + keywords = ( + 'new', 'return', 'throw', 'classOf', 'isInstanceOf', 'asInstanceOf', + 'else', 'if', 'then', 'do', 'while', 'for', 'yield', 'match', 'case', + 'catch', 'finally', 'try' + ) + + operators = ( + '<%', '=:=', '<:<', '<%<', '>:', '<:', '=', '==', '!=', '<=', '>=', + '<>', '<', '>', '<-', '←', '->', '→', '=>', '⇒', '?', '@', '|', '-', + '+', '*', '%', '~' + ) + + storage_modifiers = ( + 'private', 'protected', 'synchronized', '@volatile', 'abstract', + 'final', 'lazy', 'sealed', 'implicit', 'override', '@transient', + '@native' + ) tokens = { 'root': [ - # method names - (r'(class|trait|object)(\s+)', bygroups(Keyword, Text), 'class'), - (r'[^\S\n]+', Text), + include('whitespace'), include('comments'), - (r'@%s' % idrest, Name.Decorator), - (r'(abstract|ca(?:se|tch)|d(?:ef|o)|e(?:lse|xtends)|' - r'f(?:inal(?:ly)?|or(?:Some)?)|i(?:f|mplicit)|' - r'lazy|match|new|override|pr(?:ivate|otected)' - r'|re(?:quires|turn)|s(?:ealed|uper)|' - r't(?:h(?:is|row)|ry)|va[lr]|w(?:hile|ith)|yield)\b|' - r'(<[%:-]|=>|>:|[#=@_\u21D2\u2190])\b', Keyword), - (r':(?!%s)' % op, Keyword, 'type'), - (r'%s%s\b' % (upper, idrest), Name.Class), - (r'(true|false|null)\b', Keyword.Constant), - (r'(import|package)(\s+)', bygroups(Keyword, Text), 'import'), - (r'(type)(\s+)', bygroups(Keyword, Text), 'type'), - (r'""".*?"""(?!")', String), - (r'"(\\\\|\\[^\\]|[^"\\])*"', String), - (r"'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'", String.Char), - (r"'%s" % idrest, Text.Symbol), - (r'[fs]"""', String, 'interptriplestring'), # interpolated strings - (r'[fs]"', String, 'interpstring'), # interpolated strings - (r'raw"(\\\\|\\[^\\]|[^"\\])*"', String), # raw strings - # (r'(\.)(%s|%s|`[^`]+`)' % (idrest, op), bygroups(Operator, - # Name.Attribute)), - (idrest, Name), - (r'`[^`]+`', Name), - (r'\[', Operator, 'typeparam'), - (r'[(){};,.#]', Operator), - (op, Operator), - (r'([0-9][0-9]*\.[0-9]*|\.[0-9]+)([eE][+-]?[0-9]+)?[fFdD]?', - Number.Float), - (r'0x[0-9a-fA-F]+', Number.Hex), - (r'[0-9]+L?', Number.Integer), - (r'\n', Text) - ], - 'class': [ - (r'(%s|%s|`[^`]+`)(\s*)(\[)' % (idrest, op), - bygroups(Name.Class, Text, Operator), ('#pop', 'typeparam')), - (r'\s+', Text), - include('comments'), - (r'\{', Operator, '#pop'), - (r'\(', Operator, '#pop'), - (r'%s|%s|`[^`]+`' % (idrest, op), Name.Class, '#pop'), + include('script-header'), + include('imports'), + include('exports'), + include('storage-modifiers'), + include('annotations'), + include('using'), + include('declarations'), + include('inheritance'), + include('extension'), + include('end'), + include('constants'), + include('strings'), + include('symbols'), + include('singleton-type'), + include('inline'), + include('quoted'), + include('keywords'), + include('operators'), + include('punctuation'), + include('names'), ], - 'type': [ - (r'\s+', Text), - include('comments'), - (r'<[%:]|>:|[#_]|\bforSome\b|\btype\b', Keyword), - (r'([,);}]|=>|=|\u21d2)(\s*)', bygroups(Operator, Text), '#pop'), - (r'[({]', Operator, '#push'), - (r'((?:%s|%s|`[^`]+`)(?:\.(?:%s|%s|`[^`]+`))*)(\s*)(\[)' % - (idrest, op, idrest, op), - bygroups(Keyword.Type, Text, Operator), ('#pop', 'typeparam')), - (r'((?:%s|%s|`[^`]+`)(?:\.(?:%s|%s|`[^`]+`))*)(\s*)$' % - (idrest, op, idrest, op), - bygroups(Keyword.Type, Text), '#pop'), - (r'\.|%s|%s|`[^`]+`' % (idrest, op), Keyword.Type) - ], - 'typeparam': [ + + # Includes: + 'whitespace': [ (r'\s+', Text), - include('comments'), - (r',+', Punctuation), - (r'<[%:]|=>|>:|[#_\u21D2]|\bforSome\b|\btype\b', Keyword), - (r'([\])}])', Operator, '#pop'), - (r'[(\[{]', Operator, '#push'), - (r'\.|%s|%s|`[^`]+`' % (idrest, op), Keyword.Type) ], 'comments': [ (r'//.*?\n', Comment.Single), (r'/\*', Comment.Multiline, 'comment'), ], + 'script-header': [ + (r'^#!([^\n]*)$', Comment.Hashbang), + ], + 'imports': [ + (r'\b(import)(\s+)', bygroups(Keyword, Text), 'import-path'), + ], + 'exports': [ + (r'\b(export)(\s+)(given)(\s+)', + bygroups(Keyword, Text, Keyword, Text), 'export-path'), + (r'\b(export)(\s+)', bygroups(Keyword, Text), 'export-path'), + ], + 'storage-modifiers': [ + (words(storage_modifiers, prefix=r'\b', suffix=r'\b'), Keyword), + # Only highlight soft modifiers if they are eventually followed by + # the correct keyword. Note that soft modifiers can be followed by a + # sequence of regular modifiers; [a-z\s]* skips those, and we just + # check that the soft modifier is applied to a supported statement. + (r'\b(transparent|opaque|infix|open|inline)\b(?=[a-z\s]*\b' + r'(def|val|var|given|type|class|trait|object|enum)\b)', Keyword), + ], + 'annotations': [ + (r'@%s' % idrest, Name.Decorator), + ], + 'using': [ + # using is a soft keyword, can only be used in the first position of + # a parameter or argument list. + (r'(\()(\s*)(using)(\s)', bygroups(Punctuation, Text, Keyword, Text)), + ], + 'declarations': [ + (r'\b(def)\b(\s*)%s(%s)?' % (notStartOfComment, anyId), + bygroups(Keyword, Text, Name.Function)), + (r'\b(trait)\b(\s*)%s(%s)?' % (notStartOfComment, anyId), + bygroups(Keyword, Text, Name.Class)), + (r'\b(?:(case)(\s+))?(class|object|enum)\b(\s*)%s(%s)?' % + (notStartOfComment, anyId), + bygroups(Keyword, Text, Keyword, Text, Name.Class)), + (r'(?<!\.)\b(type)\b(\s*)%s(%s)?' % (notStartOfComment, anyId), + bygroups(Keyword, Text, Name.Class)), + (r'\b(val|var)\b', Keyword.Declaration), + (r'\b(package)(\s+)(object)\b(\s*)%s(%s)?' % + (notStartOfComment, anyId), + bygroups(Keyword, Text, Keyword, Text, Name.Namespace)), + (r'\b(package)(\s+)', bygroups(Keyword, Text), 'package'), + (r'\b(given)\b(\s*)(%s)' % idUpper, + bygroups(Keyword, Text, Name.Class)), + (r'\b(given)\b(\s*)(%s)?' % anyId, + bygroups(Keyword, Text, Name)), + ], + 'inheritance': [ + (r'\b(extends|with|derives)\b(\s*)' + r'(%s|%s|(?=\([^\)]+=>)|(?=%s)|(?="))?' % + (idUpper, backQuotedId, plainid), + bygroups(Keyword, Text, Name.Class)), + ], + 'extension': [ + (r'\b(extension)(\s+)(?=[\[\(])', bygroups(Keyword, Text)), + ], + 'end': [ + # end is a soft keyword, should only be highlighted in certain cases + (r'\b(end)(\s+)(if|while|for|match|new|extension|val|var)\b', + bygroups(Keyword, Text, Keyword)), + (r'\b(end)(\s+)(%s)%s' % (idUpper, endOfLineMaybeWithComment), + bygroups(Keyword, Text, Name.Class)), + (r'\b(end)(\s+)(%s|%s)?%s' % + (backQuotedId, plainid, endOfLineMaybeWithComment), + bygroups(Keyword, Text, Name.Namespace)), + ], + 'punctuation': [ + (r'[{}()\[\];,.]', Punctuation), + (r'(?<!:):(?!:)', Punctuation), + ], + 'keywords': [ + (words(keywords, prefix=r'\b', suffix=r'\b'), Keyword), + ], + 'operators': [ + (r'(%s{2,})(\s+)' % opchar, bygroups(Operator, Text)), + (r'/(?![/*])', Operator), + (words(operators), Operator), + (r'(?<!%s)(!|&&|\|\|)(?!%s)' % (opchar, opchar), Operator), + ], + 'constants': [ + (r'\b(this|super)\b', Name.Builtin.Pseudo), + (r'(true|false|null)\b', Keyword.Constant), + (r'0[xX][0-9a-fA-F_]*', Number.Hex), + (r'([0-9][0-9_]*\.[0-9][0-9_]*|\.[0-9][0-9_]*)' + r'([eE][+-]?[0-9][0-9_]*)?[fFdD]?', Number.Float), + (r'[0-9]+([eE][+-]?[0-9]+)?[fFdD]', Number.Float), + (r'[0-9]+([eE][+-]?[0-9]+)[fFdD]?', Number.Float), + (r'[0-9]+[lL]', Number.Integer.Long), + (r'[0-9]+', Number.Integer), + (r'""".*?"""(?!")', String), + (r'"(\\\\|\\"|[^"])*"', String), + (r"(')(\\.)(')", bygroups(String.Char, String.Escape, String.Char)), + (r"'[^\\]'|'\\u[0-9a-fA-F]{4}'", String.Char), + ], + "strings": [ + (r'[fs]"""', String, 'interpolated-string-triple'), + (r'[fs]"', String, 'interpolated-string'), + (r'raw"(\\\\|\\"|[^"])*"', String), + ], + 'symbols': [ + (r"('%s)(?!')" % plainid, String.Symbol), + ], + 'singleton-type': [ + (r'(\.)(type)\b', bygroups(Punctuation, Keyword)), + ], + 'inline': [ + # inline is a soft modifer, only highlighted if followed by if, + # match or parameters. + (r'\b(inline)(?=\s+(%s|%s)\s*:)' % (plainid, backQuotedId), + Keyword), + (r'\b(inline)\b(?=(?:.(?!\b(?:val|def|given)\b))*\b(if|match)\b)', + Keyword), + ], + 'quoted': [ + # '{...} or ${...} + (r"['$]\{(?!')", Punctuation), + # '[...] + (r"'\[(?!')", Punctuation), + ], + 'names': [ + (idUpper, Name.Class), + (anyId, Name), + ], + + # States 'comment': [ (r'[^/*]+', Comment.Multiline), (r'/\*', Comment.Multiline, '#push'), (r'\*/', Comment.Multiline, '#pop'), - (r'[*/]', Comment.Multiline) + (r'[*/]', Comment.Multiline), ], - 'import': [ - (r'(%s|\.)+' % idrest, Name.Namespace, '#pop') + 'import-path': [ + (r'(?<=[\n;:])', Text, '#pop'), + include('comments'), + (r'\b(given)\b', Keyword), + include('qualified-name'), + (r'\{', Punctuation, 'import-path-curly-brace'), ], - 'interpstringcommon': [ - (r'[^"$\\]+', String), - (r'\$\$', String), - (r'\$' + letter_letter_digit, String.Interpol), - (r'\$\{', String.Interpol, 'interpbrace'), - (r'\\.', String), + 'import-path-curly-brace': [ + include('whitespace'), + include('comments'), + (r'\b(given)\b', Keyword), + (r'=>', Operator), + (r'\}', Punctuation, '#pop'), + (r',', Punctuation), + (r'[\[\]]', Punctuation), + include('qualified-name'), + ], + 'export-path': [ + (r'(?<=[\n;:])', Text, '#pop'), + include('comments'), + include('qualified-name'), + (r'\{', Punctuation, 'export-path-curly-brace'), + ], + 'export-path-curly-brace': [ + include('whitespace'), + include('comments'), + (r'=>', Operator), + (r'\}', Punctuation, '#pop'), + (r',', Punctuation), + include('qualified-name'), + ], + 'package': [ + (r'(?<=[\n;])', Text, '#pop'), + (r':', Punctuation, '#pop'), + include('comments'), + include('qualified-name'), ], - 'interptriplestring': [ + 'interpolated-string-triple': [ (r'"""(?!")', String, '#pop'), (r'"', String), - include('interpstringcommon'), + include('interpolated-string-common'), ], - 'interpstring': [ + 'interpolated-string': [ (r'"', String, '#pop'), - include('interpstringcommon'), + include('interpolated-string-common'), ], - 'interpbrace': [ + 'interpolated-string-brace': [ (r'\}', String.Interpol, '#pop'), - (r'\{', String.Interpol, '#push'), + (r'\{', Punctuation, 'interpolated-string-nested-brace'), include('root'), ], + 'interpolated-string-nested-brace': [ + (r'\{', Punctuation, '#push'), + (r'\}', Punctuation, '#pop'), + include('root'), + ], + + # Helpers + 'qualified-name': [ + (idUpper, Name.Class), + (r'(%s)(\.)' % anyId, bygroups(Name.Namespace, Punctuation)), + (r'\.', Punctuation), + (anyId, Name), + (r'[^\S\n]+', Text), + ], + 'interpolated-string-common': [ + (r'[^"$\\]+', String), + (r'\$\$', String.Escape), + (r'(\$)(%s)' % simpleInterpolatedVariable, + bygroups(String.Interpol, Name)), + (r'\$\{', String.Interpol, 'interpolated-string-brace'), + (r'\\.', String), + ], } diff --git a/tests/examplefiles/scala/Errors.scala b/tests/examplefiles/scala/Errors.scala deleted file mode 100644 index 7af70280..00000000 --- a/tests/examplefiles/scala/Errors.scala +++ /dev/null @@ -1,23 +0,0 @@ -/* This file /* which is totally legal scala */ will not be highlighted - correcty by pygments */ - -object ⌘ { - val `interface` = """ -A -"Multiline" -String -""" - - val foo_+ = "foo plus" - val foo_⌬⌬ = "double benzene" - - // Test some interpolated strings - val mu = s"${if (true) "a:b" else "c" {with "braces"}}" - val mu2 = f"${if (true) "a:b" else "c" {with "braces"}}" - val raw = raw"a raw\nstring\"with escaped quotes" - - def main(argv: Array[String]) { - println(⌘.interface + " " + foo_+ + " " + foo_⌬⌬ ) - } -} - diff --git a/tests/examplefiles/scala/Errors.scala.output b/tests/examplefiles/scala/Errors.scala.output deleted file mode 100644 index f8b61043..00000000 --- a/tests/examplefiles/scala/Errors.scala.output +++ /dev/null @@ -1,176 +0,0 @@ -'/*' Comment.Multiline -' This file ' Comment.Multiline -'/*' Comment.Multiline -' which is totally legal scala ' Comment.Multiline -'*/' Comment.Multiline -' will not be highlighted\n correcty by pygments ' Comment.Multiline -'*/' Comment.Multiline -'\n' Text - -'\n' Text - -'object' Keyword -' ' Text -'⌘' Name.Class -' ' Text -'{' Operator -'\n' Text - -' ' Text -'val' Keyword -' ' Text -'`interface`' Name -' ' Text -'=' Operator -' ' Text -'"""\nA\n"Multiline"\nString\n"""' Literal.String -'\n' Text - -'\n' Text - -' ' Text -'val' Keyword -' ' Text -'foo_+' Name -' ' Text -'=' Operator -' ' Text -'"foo plus"' Literal.String -'\n' Text - -' ' Text -'val' Keyword -' ' Text -'foo_⌬⌬' Name -' ' Text -'=' Operator -' ' Text -'"double benzene"' Literal.String -'\n' Text - -'\n' Text - -' ' Text -'// Test some interpolated strings\n' Comment.Single - -' ' Text -'val' Keyword -' ' Text -'mu' Name -' ' Text -'=' Operator -' ' Text -'s"' Literal.String -'${' Literal.String.Interpol -'if' Keyword -' ' Text -'(' Operator -'true' Keyword.Constant -')' Operator -' ' Text -'"a:b"' Literal.String -' ' Text -'else' Keyword -' ' Text -'"c"' Literal.String -' ' Text -'{' Literal.String.Interpol -'with' Keyword -' ' Text -'"braces"' Literal.String -'}' Literal.String.Interpol -'}' Literal.String.Interpol -'"' Literal.String -'\n' Text - -' ' Text -'val' Keyword -' ' Text -'mu2' Name -' ' Text -'=' Operator -' ' Text -'f"' Literal.String -'${' Literal.String.Interpol -'if' Keyword -' ' Text -'(' Operator -'true' Keyword.Constant -')' Operator -' ' Text -'"a:b"' Literal.String -' ' Text -'else' Keyword -' ' Text -'"c"' Literal.String -' ' Text -'{' Literal.String.Interpol -'with' Keyword -' ' Text -'"braces"' Literal.String -'}' Literal.String.Interpol -'}' Literal.String.Interpol -'"' Literal.String -'\n' Text - -' ' Text -'val' Keyword -' ' Text -'raw' Name -' ' Text -'=' Operator -' ' Text -'raw"a raw\\nstring\\"with escaped quotes"' Literal.String -'\n' Text - -'\n' Text - -' ' Text -'def' Keyword -' ' Text -'main' Name -'(' Operator -'argv' Name -':' Keyword -' ' Text -'Array' Keyword.Type -'[' Operator -'String' Keyword.Type -']' Operator -')' Operator -' ' Text -'{' Operator -'\n' Text - -' ' Text -'println' Name -'(' Operator -'⌘' Operator -'.' Operator -'interface' Name -' ' Text -'+' Operator -' ' Text -'" "' Literal.String -' ' Text -'+' Operator -' ' Text -'foo_+' Name -' ' Text -'+' Operator -' ' Text -'" "' Literal.String -' ' Text -'+' Operator -' ' Text -'foo_⌬⌬' Name -' ' Text -')' Operator -'\n' Text - -' ' Text -'}' Operator -'\n' Text - -'}' Operator -'\n' Text diff --git a/tests/examplefiles/scala/char.scala.output b/tests/examplefiles/scala/char.scala.output index 5912ddbd..fff499fc 100644 --- a/tests/examplefiles/scala/char.scala.output +++ b/tests/examplefiles/scala/char.scala.output @@ -1,4 +1,4 @@ -"'symbol" Text.Symbol +"'symbol" Literal.String.Symbol '\n' Text "'a'" Literal.String.Char @@ -7,5 +7,7 @@ "'\\u1234'" Literal.String.Char '\n' Text -"'\\n'" Literal.String.Char +"'" Literal.String.Char +'\\n' Literal.String.Escape +"'" Literal.String.Char '\n' Text diff --git a/tests/examplefiles/scala/comments.scala b/tests/examplefiles/scala/comments.scala new file mode 100644 index 00000000..be712b30 --- /dev/null +++ b/tests/examplefiles/scala/comments.scala @@ -0,0 +1,9 @@ +// Comments +/* Comment block */ +/* Multi-line + * comment block + */ +/* /**/ /** */ /* comments within comments */ */ +/** /* */ /** **/ **/ +// /* Commented-out comment block +// Line comment
\ No newline at end of file diff --git a/tests/examplefiles/scala/comments.scala.output b/tests/examplefiles/scala/comments.scala.output new file mode 100644 index 00000000..ccf7c077 --- /dev/null +++ b/tests/examplefiles/scala/comments.scala.output @@ -0,0 +1,51 @@ +'// Comments\n' Comment.Single + +'/*' Comment.Multiline +' Comment block ' Comment.Multiline +'*/' Comment.Multiline +'\n' Text + +'/*' Comment.Multiline +' Multi-line \n ' Comment.Multiline +'*' Comment.Multiline +' comment block\n ' Comment.Multiline +'*/' Comment.Multiline +'\n' Text + +'/*' Comment.Multiline +' ' Comment.Multiline +'/*' Comment.Multiline +'*/' Comment.Multiline +' ' Comment.Multiline +'/*' Comment.Multiline +'*' Comment.Multiline +' ' Comment.Multiline +'*/' Comment.Multiline +' ' Comment.Multiline +'/*' Comment.Multiline +' comments within comments ' Comment.Multiline +'*/' Comment.Multiline +' ' Comment.Multiline +'*/' Comment.Multiline +'\n' Text + +'/*' Comment.Multiline +'*' Comment.Multiline +' ' Comment.Multiline +'/*' Comment.Multiline +' ' Comment.Multiline +'*/' Comment.Multiline +' ' Comment.Multiline +'/*' Comment.Multiline +'*' Comment.Multiline +' ' Comment.Multiline +'*' Comment.Multiline +'*/' Comment.Multiline +' ' Comment.Multiline +'*' Comment.Multiline +'*/' Comment.Multiline +'\n' Text + +'// /* Commented-out comment block\n' Comment.Single + +'// Line comment\n' Comment.Single diff --git a/tests/examplefiles/scala/constants.scala b/tests/examplefiles/scala/constants.scala new file mode 100644 index 00000000..f1bd8d98 --- /dev/null +++ b/tests/examplefiles/scala/constants.scala @@ -0,0 +1,18 @@ +true false null +1 2 3 4 +1L 1l 10L 12123123L +3.0 12.345 +3f 3.0f 3F 3.0F +3d 3.0d 3D 3.0D +110_222_795_799.99 110.9499_999 2_000.343_999e561_100 +1e12 1e+34 1e-56 1e12f 1e+34f 1e-56f 1e12d 1e+34d 1e-56d +1E12 1E+34 1E-56 1E12f 1E+34f 1E-56f 1E12d 1E+34d 1E-56d +.1e12 .1e+34 .1e-56 .1e12f .1e+34f .1e-56f .1e12d .1e+34d .1e-56d +.1E12 .1E+34 .1E-56 .1E12f .1E+34f .1E-56f .1E12d .1E+34d .1E-56d +0x // Can still be highlighted correctly! +0x1234567890ABCDEF 0x1234567890abcdef +0x123_abc 0x123_ABC +"test" "\"test\"" "'test'" // comment +"""test: one ", two "", three """""" // comment +'t' '"' '\'' '\n' ' ' +super this
\ No newline at end of file diff --git a/tests/examplefiles/scala/constants.scala.output b/tests/examplefiles/scala/constants.scala.output new file mode 100644 index 00000000..98c0b6c0 --- /dev/null +++ b/tests/examplefiles/scala/constants.scala.output @@ -0,0 +1,176 @@ +'true' Keyword.Constant +' ' Text +'false' Keyword.Constant +' ' Text +'null' Keyword.Constant +'\n' Text + +'1' Literal.Number.Integer +' ' Text +'2' Literal.Number.Integer +' ' Text +'3' Literal.Number.Integer +' ' Text +'4' Literal.Number.Integer +'\n' Text + +'1L' Literal.Number.Integer.Long +' ' Text +'1l' Literal.Number.Integer.Long +' ' Text +'10L' Literal.Number.Integer.Long +' ' Text +'12123123L' Literal.Number.Integer.Long +'\n' Text + +'3.0' Literal.Number.Float +' ' Text +'12.345' Literal.Number.Float +'\n' Text + +'3f' Literal.Number.Float +' ' Text +'3.0f' Literal.Number.Float +' ' Text +'3F' Literal.Number.Float +' ' Text +'3.0F' Literal.Number.Float +'\n' Text + +'3d' Literal.Number.Float +' ' Text +'3.0d' Literal.Number.Float +' ' Text +'3D' Literal.Number.Float +' ' Text +'3.0D' Literal.Number.Float +'\n' Text + +'110_222_795_799.99' Literal.Number.Float +' ' Text +'110.9499_999' Literal.Number.Float +' ' Text +'2_000.343_999e561_100' Literal.Number.Float +'\n' Text + +'1e12' Literal.Number.Float +' ' Text +'1e+34' Literal.Number.Float +' ' Text +'1e-56' Literal.Number.Float +' ' Text +'1e12f' Literal.Number.Float +' ' Text +'1e+34f' Literal.Number.Float +' ' Text +'1e-56f' Literal.Number.Float +' ' Text +'1e12d' Literal.Number.Float +' ' Text +'1e+34d' Literal.Number.Float +' ' Text +'1e-56d' Literal.Number.Float +'\n' Text + +'1E12' Literal.Number.Float +' ' Text +'1E+34' Literal.Number.Float +' ' Text +'1E-56' Literal.Number.Float +' ' Text +'1E12f' Literal.Number.Float +' ' Text +'1E+34f' Literal.Number.Float +' ' Text +'1E-56f' Literal.Number.Float +' ' Text +'1E12d' Literal.Number.Float +' ' Text +'1E+34d' Literal.Number.Float +' ' Text +'1E-56d' Literal.Number.Float +'\n' Text + +'.1e12' Literal.Number.Float +' ' Text +'.1e+34' Literal.Number.Float +' ' Text +'.1e-56' Literal.Number.Float +' ' Text +'.1e12f' Literal.Number.Float +' ' Text +'.1e+34f' Literal.Number.Float +' ' Text +'.1e-56f' Literal.Number.Float +' ' Text +'.1e12d' Literal.Number.Float +' ' Text +'.1e+34d' Literal.Number.Float +' ' Text +'.1e-56d' Literal.Number.Float +'\n' Text + +'.1E12' Literal.Number.Float +' ' Text +'.1E+34' Literal.Number.Float +' ' Text +'.1E-56' Literal.Number.Float +' ' Text +'.1E12f' Literal.Number.Float +' ' Text +'.1E+34f' Literal.Number.Float +' ' Text +'.1E-56f' Literal.Number.Float +' ' Text +'.1E12d' Literal.Number.Float +' ' Text +'.1E+34d' Literal.Number.Float +' ' Text +'.1E-56d' Literal.Number.Float +'\n' Text + +'0x' Literal.Number.Hex +' ' Text +'// Can still be highlighted correctly!\n' Comment.Single + +'0x1234567890ABCDEF' Literal.Number.Hex +' ' Text +'0x1234567890abcdef' Literal.Number.Hex +'\n' Text + +'0x123_abc' Literal.Number.Hex +' ' Text +'0x123_ABC' Literal.Number.Hex +'\n' Text + +'"test"' Literal.String +' ' Text +'"\\"test\\""' Literal.String +' ' Text +'"\'test\'"' Literal.String +' ' Text +'// comment\n' Comment.Single + +'"""test: one ", two "", three """"""' Literal.String +' ' Text +'// comment\n' Comment.Single + +"'t'" Literal.String.Char +' ' Text +'\'"\'' Literal.String.Char +' ' Text +"'" Literal.String.Char +"\\'" Literal.String.Escape +"'" Literal.String.Char +' ' Text +"'" Literal.String.Char +'\\n' Literal.String.Escape +"'" Literal.String.Char +' ' Text +"' '" Literal.String.Char +'\n' Text + +'super' Name.Builtin.Pseudo +' ' Text +'this' Name.Builtin.Pseudo +'\n' Text diff --git a/tests/examplefiles/scala/declarations.scala b/tests/examplefiles/scala/declarations.scala new file mode 100644 index 00000000..3d690ae4 --- /dev/null +++ b/tests/examplefiles/scala/declarations.scala @@ -0,0 +1,177 @@ +val x: Int +val y: Int = 1 +val z = 1 +var x: Int +var y: Int = 1 +var z = 1 +val (a, b) = (1, 2) +val Some(a) = Some(1, 2) +var Pair(a, b) = Pair(1, 2) +val Test.Pair(a) = Test.Pair(1, 2) +val a :: b = x :: Nil +var a :: b = x :: Nil +val a +: rest = ??? +val foo_+ = "foo plus" +val foo_⌬⌬ = "double benzene" + +def abs[T](x: Int): Int = if x >= 0 then new x else now -x +def abs(x: Int) = if x >= 0 then new x else now -x +def sum[A](xs: List[A])(implicit m: Monoid[A]): A = ??? +def sum[A](xs: List[A])(implicit Monoid[A]): A = ??? +def sum[A](xs: List[A])(using m: Monoid[A]): A = ??? +def sum[A](xs: List[A])(using Monoid[A]): A = ??? +def reduceRight(op: (T, T) => T): T = ??? +def foldRight[](z: U)(op: (T, U) => U): U = ??? +def obj(fields: (String, Any)*, test: String): Json +def :: (xs: List[T]): List[T] = ::(x, xs) +def ::(xs: List[T]): List[T] = ::(x, xs) + +trait X {} +object X +class Y +open object X: +open class Y: +case object X +case class Y() +package object x {} +package object y: + +type X +type X <: Y +type X = Y +type X[Y] = Y with Z +type X[Y] = Y => (1 | 2, 3) +type X[Y] = (Y, 3) => (1 | 2, 3) +type Foo = Bar.Baz + +given Foo = ??? +given foo = ??? +given foo: Foo with +given listOrd[T: Ordering]: Ordering[List[T]] with +given listOrd(using ev: Ev): Foo with +given Ordering[Int] with +given Foo with +given [T: Ordering]: Ordering[List[T]] with +given (using ev: Ev): Foo with +given intOrd: Ordering[Int] with +given foo: Foo = ??? +given `foo`: Foo = ??? +given listOrd[T: Ordering]: Ordering[List[T]] = ??? +given listOrd(using ev: Ev): Foo = ??? +given Ordering[Int] = ??? +given Foo = ??? +given [T: Ordering]: Ordering[List[T]] = ??? +given (using ev: Ev): Foo = ??? + +given sumMonoid: Monoid[Int] with + extension (x: Int) def combine(y: Int) : Int = x + y + def unit: Int = 0 + +trait Ord[T]: + def compare(x: T, y: T): Int + extension (x: T) def < (y: T) = compare(x, y) < 0 + extension (x: T) def > (y: T) = compare(x, y) > 0 +given intOrd: Ord[Int] with + def compare(x: Int, y: Int) = + if x < y then -1 else if x > y then +1 else 0 +given listOrd[T](using ord: Ord[T]): Ord[List[T]] with + def compare(xs: List[T], ys: List[T]): Int = (xs, ys) match + case (Nil, Nil) => 0 + case (Nil, _) => -1 + case (_, Nil) => +1 + case (x :: xs1, y :: ys1) => + val fst = ord.compare(x, y) + if fst != 0 then fst else compare(xs1, ys1) +trait A with + given ac: C +trait B extends A with + given bc: C +object O extends B with + val x = summon[C] + +// Classes +class A +class B +class Bar with +class Foo with +class :: with +class Rational(x: Int, y: Int) with + def numer = x + def denom = y +class Cons(_head: Int, _tail: IntList) extends IntList with + val head = _head + val tail = _tail +class Int with + def + (that: Double): Double + def + (that: Float): Float + def + (that: Long): Long + def + (that: Int): Int // same for -, *, /, % + def << (cnt: Int): Int // same for >>, >>> */ + def & (that: Long): Long + def & (that: Int): Int // same for |, ^ */ + def == (that: Double): Boolean + def == (that: Float): Boolean + def == (that: Long): Boolean // same for !=, <, >, <=, >= +end Int +class Sub extends Base with Something { + override def foo = 2 + def bar = 3 +} +class Succ(n: Nat) extends Nat with + // ... +open class Writer[T] { + /** Sends to stdout, can be overridden */ + def send(x: T) = println(x) + /** Sends all arguments using `send` */ + def sendAll(xs: T*) = xs.foreach(send) +} +class LazyList[+T](init: => State[T]) with + lazy val state: State[T] = init + +trait Foo with +trait Bar with +trait *: with +trait *: with +trait :: with +1 :: Nil +1 :: + +object ⌘ { + +} +object Foo with +object Bar with +object Zero extends Nat with + ... + +object Enum extends Enumeration { + val Foo, Bar, Baz = Value +} +enum Color with + case Red, Green, Blue, Magenta +enum Color(val test: Int) with + case Red, Green, Blue, Magenta + def isPrimary(color: Color): Boolean = + color match + case Red | Green | Blue => true + case Magenta => false +enum State[T] with + case Empty + case Cons(hd: T, tl: LazyList[T]) +abstract class Color +object Color { + val Red = Color() + val Green = Color() + val Blue = Color() + val Magenta = Color() + ... +} +enum Vehicle(val numberOfWheels: Int) { + case Unicycle extends Vehicle(1) + case Bicycle extends Vehicle(2) + case Car extends Vehicle(4) +} +enum Vehicle(val numberOfWheels: Int): + case Unicycle extends Vehicle(1) + case Bicycle extends Vehicle(2) + case Car extends Vehicle(4)
\ No newline at end of file diff --git a/tests/examplefiles/scala/declarations.scala.output b/tests/examplefiles/scala/declarations.scala.output new file mode 100644 index 00000000..d63c86ec --- /dev/null +++ b/tests/examplefiles/scala/declarations.scala.output @@ -0,0 +1,2251 @@ +'val' Keyword.Declaration +' ' Text +'x' Name +':' Punctuation +' ' Text +'Int' Name.Class +'\n' Text + +'val' Keyword.Declaration +' ' Text +'y' Name +':' Punctuation +' ' Text +'Int' Name.Class +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'val' Keyword.Declaration +' ' Text +'z' Name +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'var' Keyword.Declaration +' ' Text +'x' Name +':' Punctuation +' ' Text +'Int' Name.Class +'\n' Text + +'var' Keyword.Declaration +' ' Text +'y' Name +':' Punctuation +' ' Text +'Int' Name.Class +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'var' Keyword.Declaration +' ' Text +'z' Name +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'val' Keyword.Declaration +' ' Text +'(' Punctuation +'a' Name +',' Punctuation +' ' Text +'b' Name +')' Punctuation +' ' Text +'=' Operator +' ' Text +'(' Punctuation +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'2' Literal.Number.Integer +')' Punctuation +'\n' Text + +'val' Keyword.Declaration +' ' Text +'Some' Name.Class +'(' Punctuation +'a' Name +')' Punctuation +' ' Text +'=' Operator +' ' Text +'Some' Name.Class +'(' Punctuation +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'2' Literal.Number.Integer +')' Punctuation +'\n' Text + +'var' Keyword.Declaration +' ' Text +'Pair' Name.Class +'(' Punctuation +'a' Name +',' Punctuation +' ' Text +'b' Name +')' Punctuation +' ' Text +'=' Operator +' ' Text +'Pair' Name.Class +'(' Punctuation +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'2' Literal.Number.Integer +')' Punctuation +'\n' Text + +'val' Keyword.Declaration +' ' Text +'Test' Name.Class +'.' Punctuation +'Pair' Name.Class +'(' Punctuation +'a' Name +')' Punctuation +' ' Text +'=' Operator +' ' Text +'Test' Name.Class +'.' Punctuation +'Pair' Name.Class +'(' Punctuation +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'2' Literal.Number.Integer +')' Punctuation +'\n' Text + +'val' Keyword.Declaration +' ' Text +'a' Name +' ' Text +'::' Operator +' ' Text +'b' Name +' ' Text +'=' Operator +' ' Text +'x' Name +' ' Text +'::' Operator +' ' Text +'Nil' Name.Class +'\n' Text + +'var' Keyword.Declaration +' ' Text +'a' Name +' ' Text +'::' Operator +' ' Text +'b' Name +' ' Text +'=' Operator +' ' Text +'x' Name +' ' Text +'::' Operator +' ' Text +'Nil' Name.Class +'\n' Text + +'val' Keyword.Declaration +' ' Text +'a' Name +' ' Text +'+:' Operator +' ' Text +'rest' Name +' ' Text +'=' Operator +' ' Text +'???' Operator +'\n' Text + +'val' Keyword.Declaration +' ' Text +'foo_+' Name +' ' Text +'=' Operator +' ' Text +'"foo plus"' Literal.String +'\n' Text + +'val' Keyword.Declaration +' ' Text +'foo_⌬⌬' Name +' ' Text +'=' Operator +' ' Text +'"double benzene"' Literal.String +'\n\n' Text + +'def' Keyword +' ' Text +'abs' Name.Function +'[' Punctuation +'T' Name.Class +']' Punctuation +'(' Punctuation +'x' Name +':' Punctuation +' ' Text +'Int' Name.Class +')' Punctuation +':' Punctuation +' ' Text +'Int' Name.Class +' ' Text +'=' Operator +' ' Text +'if' Keyword +' ' Text +'x' Name +' ' Text +'>=' Operator +' ' Text +'0' Literal.Number.Integer +' ' Text +'then' Keyword +' ' Text +'new' Keyword +' ' Text +'x' Name +' ' Text +'else' Keyword +' ' Text +'now' Name +' ' Text +'-' Operator +'x' Name +'\n' Text + +'def' Keyword +' ' Text +'abs' Name.Function +'(' Punctuation +'x' Name +':' Punctuation +' ' Text +'Int' Name.Class +')' Punctuation +' ' Text +'=' Operator +' ' Text +'if' Keyword +' ' Text +'x' Name +' ' Text +'>=' Operator +' ' Text +'0' Literal.Number.Integer +' ' Text +'then' Keyword +' ' Text +'new' Keyword +' ' Text +'x' Name +' ' Text +'else' Keyword +' ' Text +'now' Name +' ' Text +'-' Operator +'x' Name +'\n' Text + +'def' Keyword +' ' Text +'sum' Name.Function +'[' Punctuation +'A' Name.Class +']' Punctuation +'(' Punctuation +'xs' Name +':' Punctuation +' ' Text +'List' Name.Class +'[' Punctuation +'A' Name.Class +']' Punctuation +')' Punctuation +'(' Punctuation +'implicit' Keyword +' ' Text +'m' Name +':' Punctuation +' ' Text +'Monoid' Name.Class +'[' Punctuation +'A' Name.Class +']' Punctuation +')' Punctuation +':' Punctuation +' ' Text +'A' Name.Class +' ' Text +'=' Operator +' ' Text +'???' Operator +'\n' Text + +'def' Keyword +' ' Text +'sum' Name.Function +'[' Punctuation +'A' Name.Class +']' Punctuation +'(' Punctuation +'xs' Name +':' Punctuation +' ' Text +'List' Name.Class +'[' Punctuation +'A' Name.Class +']' Punctuation +')' Punctuation +'(' Punctuation +'implicit' Keyword +' ' Text +'Monoid' Name.Class +'[' Punctuation +'A' Name.Class +']' Punctuation +')' Punctuation +':' Punctuation +' ' Text +'A' Name.Class +' ' Text +'=' Operator +' ' Text +'???' Operator +'\n' Text + +'def' Keyword +' ' Text +'sum' Name.Function +'[' Punctuation +'A' Name.Class +']' Punctuation +'(' Punctuation +'xs' Name +':' Punctuation +' ' Text +'List' Name.Class +'[' Punctuation +'A' Name.Class +']' Punctuation +')' Punctuation +'(' Punctuation +'using' Keyword +' ' Text +'m' Name +':' Punctuation +' ' Text +'Monoid' Name.Class +'[' Punctuation +'A' Name.Class +']' Punctuation +')' Punctuation +':' Punctuation +' ' Text +'A' Name.Class +' ' Text +'=' Operator +' ' Text +'???' Operator +'\n' Text + +'def' Keyword +' ' Text +'sum' Name.Function +'[' Punctuation +'A' Name.Class +']' Punctuation +'(' Punctuation +'xs' Name +':' Punctuation +' ' Text +'List' Name.Class +'[' Punctuation +'A' Name.Class +']' Punctuation +')' Punctuation +'(' Punctuation +'using' Keyword +' ' Text +'Monoid' Name.Class +'[' Punctuation +'A' Name.Class +']' Punctuation +')' Punctuation +':' Punctuation +' ' Text +'A' Name.Class +' ' Text +'=' Operator +' ' Text +'???' Operator +'\n' Text + +'def' Keyword +' ' Text +'reduceRight' Name.Function +'(' Punctuation +'op' Name +':' Punctuation +' ' Text +'(' Punctuation +'T' Name.Class +',' Punctuation +' ' Text +'T' Name.Class +')' Punctuation +' ' Text +'=>' Operator +' ' Text +'T' Name.Class +')' Punctuation +':' Punctuation +' ' Text +'T' Name.Class +' ' Text +'=' Operator +' ' Text +'???' Operator +'\n' Text + +'def' Keyword +' ' Text +'foldRight' Name.Function +'[' Punctuation +']' Punctuation +'(' Punctuation +'z' Name +':' Punctuation +' ' Text +'U' Name.Class +')' Punctuation +'(' Punctuation +'op' Name +':' Punctuation +' ' Text +'(' Punctuation +'T' Name.Class +',' Punctuation +' ' Text +'U' Name.Class +')' Punctuation +' ' Text +'=>' Operator +' ' Text +'U' Name.Class +')' Punctuation +':' Punctuation +' ' Text +'U' Name.Class +' ' Text +'=' Operator +' ' Text +'???' Operator +'\n' Text + +'def' Keyword +' ' Text +'obj' Name.Function +'(' Punctuation +'fields' Name +':' Punctuation +' ' Text +'(' Punctuation +'String' Name.Class +',' Punctuation +' ' Text +'Any' Name.Class +')' Punctuation +'*' Operator +',' Punctuation +' ' Text +'test' Name +':' Punctuation +' ' Text +'String' Name.Class +')' Punctuation +':' Punctuation +' ' Text +'Json' Name.Class +'\n' Text + +'def' Keyword +' ' Text +'::' Name.Function +' ' Text +'(' Punctuation +'xs' Name +':' Punctuation +' ' Text +'List' Name.Class +'[' Punctuation +'T' Name.Class +']' Punctuation +')' Punctuation +':' Punctuation +' ' Text +'List' Name.Class +'[' Punctuation +'T' Name.Class +']' Punctuation +' ' Text +'=' Operator +' ' Text +'::' Name +'(' Punctuation +'x' Name +',' Punctuation +' ' Text +'xs' Name +')' Punctuation +'\n' Text + +'def' Keyword +' ' Text +'::' Name.Function +'(' Punctuation +'xs' Name +':' Punctuation +' ' Text +'List' Name.Class +'[' Punctuation +'T' Name.Class +']' Punctuation +')' Punctuation +':' Punctuation +' ' Text +'List' Name.Class +'[' Punctuation +'T' Name.Class +']' Punctuation +' ' Text +'=' Operator +' ' Text +'::' Name +'(' Punctuation +'x' Name +',' Punctuation +' ' Text +'xs' Name +')' Punctuation +'\n\n' Text + +'trait' Keyword +' ' Text +'X' Name.Class +' ' Text +'{' Punctuation +'}' Punctuation +'\n' Text + +'object' Keyword +' ' Text +'X' Name.Class +'\n' Text + +'class' Keyword +' ' Text +'Y' Name.Class +'\n' Text + +'open' Keyword +' ' Text +'object' Keyword +' ' Text +'X' Name.Class +':' Punctuation +'\n' Text + +'open' Keyword +' ' Text +'class' Keyword +' ' Text +'Y' Name.Class +':' Punctuation +'\n' Text + +'case' Keyword +' ' Text +'object' Keyword +' ' Text +'X' Name.Class +'\n' Text + +'case' Keyword +' ' Text +'class' Keyword +' ' Text +'Y' Name.Class +'(' Punctuation +')' Punctuation +'\n' Text + +'package' Keyword +' ' Text +'object' Keyword +' ' Text +'x' Name.Namespace +' ' Text +'{' Punctuation +'}' Punctuation +'\n' Text + +'package' Keyword +' ' Text +'object' Keyword +' ' Text +'y' Name.Namespace +':' Punctuation +'\n\n' Text + +'type' Keyword +' ' Text +'X' Name.Class +'\n' Text + +'type' Keyword +' ' Text +'X' Name.Class +' ' Text +'<:' Operator +' ' Text +'Y' Name.Class +'\n' Text + +'type' Keyword +' ' Text +'X' Name.Class +' ' Text +'=' Operator +' ' Text +'Y' Name.Class +'\n' Text + +'type' Keyword +' ' Text +'X' Name.Class +'[' Punctuation +'Y' Name.Class +']' Punctuation +' ' Text +'=' Operator +' ' Text +'Y' Name.Class +' ' Text +'with' Keyword +' ' Text +'Z' Name.Class +'\n' Text + +'type' Keyword +' ' Text +'X' Name.Class +'[' Punctuation +'Y' Name.Class +']' Punctuation +' ' Text +'=' Operator +' ' Text +'Y' Name.Class +' ' Text +'=>' Operator +' ' Text +'(' Punctuation +'1' Literal.Number.Integer +' ' Text +'|' Operator +' ' Text +'2' Literal.Number.Integer +',' Punctuation +' ' Text +'3' Literal.Number.Integer +')' Punctuation +'\n' Text + +'type' Keyword +' ' Text +'X' Name.Class +'[' Punctuation +'Y' Name.Class +']' Punctuation +' ' Text +'=' Operator +' ' Text +'(' Punctuation +'Y' Name.Class +',' Punctuation +' ' Text +'3' Literal.Number.Integer +')' Punctuation +' ' Text +'=>' Operator +' ' Text +'(' Punctuation +'1' Literal.Number.Integer +' ' Text +'|' Operator +' ' Text +'2' Literal.Number.Integer +',' Punctuation +' ' Text +'3' Literal.Number.Integer +')' Punctuation +'\n' Text + +'type' Keyword +' ' Text +'Foo' Name.Class +' ' Text +'=' Operator +' ' Text +'Bar' Name.Class +'.' Punctuation +'Baz' Name.Class +'\n\n' Text + +'given' Keyword +' ' Text +'Foo' Name.Class +' ' Text +'=' Operator +' ' Text +'???' Operator +'\n' Text + +'given' Keyword +' ' Text +'foo' Name +' ' Text +'=' Operator +' ' Text +'???' Operator +'\n' Text + +'given' Keyword +' ' Text +'foo' Name +':' Punctuation +' ' Text +'Foo' Name.Class +' ' Text +'with' Keyword +'\n' Text + +'given' Keyword +' ' Text +'listOrd' Name +'[' Punctuation +'T' Name.Class +':' Punctuation +' ' Text +'Ordering' Name.Class +']' Punctuation +':' Punctuation +' ' Text +'Ordering' Name.Class +'[' Punctuation +'List' Name.Class +'[' Punctuation +'T' Name.Class +']' Punctuation +']' Punctuation +' ' Text +'with' Keyword +'\n' Text + +'given' Keyword +' ' Text +'listOrd' Name +'(' Punctuation +'using' Keyword +' ' Text +'ev' Name +':' Punctuation +' ' Text +'Ev' Name.Class +')' Punctuation +':' Punctuation +' ' Text +'Foo' Name.Class +' ' Text +'with' Keyword +'\n' Text + +'given' Keyword +' ' Text +'Ordering' Name.Class +'[' Punctuation +'Int' Name.Class +']' Punctuation +' ' Text +'with' Keyword +'\n' Text + +'given' Keyword +' ' Text +'Foo' Name.Class +' ' Text +'with' Keyword +'\n' Text + +'given' Keyword +' ' Text +'[' Punctuation +'T' Name.Class +':' Punctuation +' ' Text +'Ordering' Name.Class +']' Punctuation +':' Punctuation +' ' Text +'Ordering' Name.Class +'[' Punctuation +'List' Name.Class +'[' Punctuation +'T' Name.Class +']' Punctuation +']' Punctuation +' ' Text +'with' Keyword +'\n' Text + +'given' Keyword +' ' Text +'(' Punctuation +'using' Keyword +' ' Text +'ev' Name +':' Punctuation +' ' Text +'Ev' Name.Class +')' Punctuation +':' Punctuation +' ' Text +'Foo' Name.Class +' ' Text +'with' Keyword +'\n' Text + +'given' Keyword +' ' Text +'intOrd' Name +':' Punctuation +' ' Text +'Ordering' Name.Class +'[' Punctuation +'Int' Name.Class +']' Punctuation +' ' Text +'with' Keyword +'\n' Text + +'given' Keyword +' ' Text +'foo' Name +':' Punctuation +' ' Text +'Foo' Name.Class +' ' Text +'=' Operator +' ' Text +'???' Operator +'\n' Text + +'given' Keyword +' ' Text +'`foo`' Name +':' Punctuation +' ' Text +'Foo' Name.Class +' ' Text +'=' Operator +' ' Text +'???' Operator +'\n' Text + +'given' Keyword +' ' Text +'listOrd' Name +'[' Punctuation +'T' Name.Class +':' Punctuation +' ' Text +'Ordering' Name.Class +']' Punctuation +':' Punctuation +' ' Text +'Ordering' Name.Class +'[' Punctuation +'List' Name.Class +'[' Punctuation +'T' Name.Class +']' Punctuation +']' Punctuation +' ' Text +'=' Operator +' ' Text +'???' Operator +'\n' Text + +'given' Keyword +' ' Text +'listOrd' Name +'(' Punctuation +'using' Keyword +' ' Text +'ev' Name +':' Punctuation +' ' Text +'Ev' Name.Class +')' Punctuation +':' Punctuation +' ' Text +'Foo' Name.Class +' ' Text +'=' Operator +' ' Text +'???' Operator +'\n' Text + +'given' Keyword +' ' Text +'Ordering' Name.Class +'[' Punctuation +'Int' Name.Class +']' Punctuation +' ' Text +'=' Operator +' ' Text +'???' Operator +'\n' Text + +'given' Keyword +' ' Text +'Foo' Name.Class +' ' Text +'=' Operator +' ' Text +'???' Operator +'\n' Text + +'given' Keyword +' ' Text +'[' Punctuation +'T' Name.Class +':' Punctuation +' ' Text +'Ordering' Name.Class +']' Punctuation +':' Punctuation +' ' Text +'Ordering' Name.Class +'[' Punctuation +'List' Name.Class +'[' Punctuation +'T' Name.Class +']' Punctuation +']' Punctuation +' ' Text +'=' Operator +' ' Text +'???' Operator +'\n' Text + +'given' Keyword +' ' Text +'(' Punctuation +'using' Keyword +' ' Text +'ev' Name +':' Punctuation +' ' Text +'Ev' Name.Class +')' Punctuation +':' Punctuation +' ' Text +'Foo' Name.Class +' ' Text +'=' Operator +' ' Text +'???' Operator +'\n\n' Text + +'given' Keyword +' ' Text +'sumMonoid' Name +':' Punctuation +' ' Text +'Monoid' Name.Class +'[' Punctuation +'Int' Name.Class +']' Punctuation +' ' Text +'with' Keyword +'\n ' Text +'extension' Keyword +' ' Text +'(' Punctuation +'x' Name +':' Punctuation +' ' Text +'Int' Name.Class +')' Punctuation +' ' Text +'def' Keyword +' ' Text +'combine' Name.Function +'(' Punctuation +'y' Name +':' Punctuation +' ' Text +'Int' Name.Class +')' Punctuation +' ' Text +':' Punctuation +' ' Text +'Int' Name.Class +' ' Text +'=' Operator +' ' Text +'x' Name +' ' Text +'+' Operator +' ' Text +'y' Name +' \n ' Text +'def' Keyword +' ' Text +'unit' Name.Function +':' Punctuation +' ' Text +'Int' Name.Class +' ' Text +'=' Operator +' ' Text +'0' Literal.Number.Integer +'\n\n' Text + +'trait' Keyword +' ' Text +'Ord' Name.Class +'[' Punctuation +'T' Name.Class +']' Punctuation +':' Punctuation +'\n ' Text +'def' Keyword +' ' Text +'compare' Name.Function +'(' Punctuation +'x' Name +':' Punctuation +' ' Text +'T' Name.Class +',' Punctuation +' ' Text +'y' Name +':' Punctuation +' ' Text +'T' Name.Class +')' Punctuation +':' Punctuation +' ' Text +'Int' Name.Class +'\n ' Text +'extension' Keyword +' ' Text +'(' Punctuation +'x' Name +':' Punctuation +' ' Text +'T' Name.Class +')' Punctuation +' ' Text +'def' Keyword +' ' Text +'<' Name.Function +' ' Text +'(' Punctuation +'y' Name +':' Punctuation +' ' Text +'T' Name.Class +')' Punctuation +' ' Text +'=' Operator +' ' Text +'compare' Name +'(' Punctuation +'x' Name +',' Punctuation +' ' Text +'y' Name +')' Punctuation +' ' Text +'<' Operator +' ' Text +'0' Literal.Number.Integer +'\n ' Text +'extension' Keyword +' ' Text +'(' Punctuation +'x' Name +':' Punctuation +' ' Text +'T' Name.Class +')' Punctuation +' ' Text +'def' Keyword +' ' Text +'>' Name.Function +' ' Text +'(' Punctuation +'y' Name +':' Punctuation +' ' Text +'T' Name.Class +')' Punctuation +' ' Text +'=' Operator +' ' Text +'compare' Name +'(' Punctuation +'x' Name +',' Punctuation +' ' Text +'y' Name +')' Punctuation +' ' Text +'>' Operator +' ' Text +'0' Literal.Number.Integer +'\n' Text + +'given' Keyword +' ' Text +'intOrd' Name +':' Punctuation +' ' Text +'Ord' Name.Class +'[' Punctuation +'Int' Name.Class +']' Punctuation +' ' Text +'with' Keyword +'\n ' Text +'def' Keyword +' ' Text +'compare' Name.Function +'(' Punctuation +'x' Name +':' Punctuation +' ' Text +'Int' Name.Class +',' Punctuation +' ' Text +'y' Name +':' Punctuation +' ' Text +'Int' Name.Class +')' Punctuation +' ' Text +'=' Operator +'\n ' Text +'if' Keyword +' ' Text +'x' Name +' ' Text +'<' Operator +' ' Text +'y' Name +' ' Text +'then' Keyword +' ' Text +'-' Operator +'1' Literal.Number.Integer +' ' Text +'else' Keyword +' ' Text +'if' Keyword +' ' Text +'x' Name +' ' Text +'>' Operator +' ' Text +'y' Name +' ' Text +'then' Keyword +' ' Text +'+' Operator +'1' Literal.Number.Integer +' ' Text +'else' Keyword +' ' Text +'0' Literal.Number.Integer +'\n' Text + +'given' Keyword +' ' Text +'listOrd' Name +'[' Punctuation +'T' Name.Class +']' Punctuation +'(' Punctuation +'using' Keyword +' ' Text +'ord' Name +':' Punctuation +' ' Text +'Ord' Name.Class +'[' Punctuation +'T' Name.Class +']' Punctuation +')' Punctuation +':' Punctuation +' ' Text +'Ord' Name.Class +'[' Punctuation +'List' Name.Class +'[' Punctuation +'T' Name.Class +']' Punctuation +']' Punctuation +' ' Text +'with' Keyword +'\n ' Text +'def' Keyword +' ' Text +'compare' Name.Function +'(' Punctuation +'xs' Name +':' Punctuation +' ' Text +'List' Name.Class +'[' Punctuation +'T' Name.Class +']' Punctuation +',' Punctuation +' ' Text +'ys' Name +':' Punctuation +' ' Text +'List' Name.Class +'[' Punctuation +'T' Name.Class +']' Punctuation +')' Punctuation +':' Punctuation +' ' Text +'Int' Name.Class +' ' Text +'=' Operator +' ' Text +'(' Punctuation +'xs' Name +',' Punctuation +' ' Text +'ys' Name +')' Punctuation +' ' Text +'match' Keyword +'\n ' Text +'case' Keyword +' ' Text +'(' Punctuation +'Nil' Name.Class +',' Punctuation +' ' Text +'Nil' Name.Class +')' Punctuation +' ' Text +'=>' Operator +' ' Text +'0' Literal.Number.Integer +'\n ' Text +'case' Keyword +' ' Text +'(' Punctuation +'Nil' Name.Class +',' Punctuation +' ' Text +'_' Name +')' Punctuation +' ' Text +'=>' Operator +' ' Text +'-' Operator +'1' Literal.Number.Integer +'\n ' Text +'case' Keyword +' ' Text +'(' Punctuation +'_' Name +',' Punctuation +' ' Text +'Nil' Name.Class +')' Punctuation +' ' Text +'=>' Operator +' ' Text +'+' Operator +'1' Literal.Number.Integer +'\n ' Text +'case' Keyword +' ' Text +'(' Punctuation +'x' Name +' ' Text +'::' Operator +' ' Text +'xs1' Name +',' Punctuation +' ' Text +'y' Name +' ' Text +'::' Operator +' ' Text +'ys1' Name +')' Punctuation +' ' Text +'=>' Operator +'\n ' Text +'val' Keyword.Declaration +' ' Text +'fst' Name +' ' Text +'=' Operator +' ' Text +'ord' Name +'.' Punctuation +'compare' Name +'(' Punctuation +'x' Name +',' Punctuation +' ' Text +'y' Name +')' Punctuation +'\n ' Text +'if' Keyword +' ' Text +'fst' Name +' ' Text +'!=' Operator +' ' Text +'0' Literal.Number.Integer +' ' Text +'then' Keyword +' ' Text +'fst' Name +' ' Text +'else' Keyword +' ' Text +'compare' Name +'(' Punctuation +'xs1' Name +',' Punctuation +' ' Text +'ys1' Name +')' Punctuation +'\n' Text + +'trait' Keyword +' ' Text +'A' Name.Class +' ' Text +'with' Keyword +'\n ' Text +'given' Keyword +' ' Text +'ac' Name +':' Punctuation +' ' Text +'C' Name.Class +'\n' Text + +'trait' Keyword +' ' Text +'B' Name.Class +' ' Text +'extends' Keyword +' ' Text +'A' Name.Class +' ' Text +'with' Keyword +'\n ' Text +'given' Keyword +' ' Text +'bc' Name +':' Punctuation +' ' Text +'C' Name.Class +'\n' Text + +'object' Keyword +' ' Text +'O' Name.Class +' ' Text +'extends' Keyword +' ' Text +'B' Name.Class +' ' Text +'with' Keyword +'\n ' Text +'val' Keyword.Declaration +' ' Text +'x' Name +' ' Text +'=' Operator +' ' Text +'summon' Name +'[' Punctuation +'C' Name.Class +']' Punctuation +'\n\n' Text + +'// Classes\n' Comment.Single + +'class' Keyword +' ' Text +'A' Name.Class +'\n' Text + +'class' Keyword +' ' Text +'B' Name.Class +'\n' Text + +'class' Keyword +' ' Text +'Bar' Name.Class +' ' Text +'with' Keyword +'\n' Text + +'class' Keyword +' ' Text +'Foo' Name.Class +' ' Text +'with' Keyword +'\n' Text + +'class' Keyword +' ' Text +'::' Name.Class +' ' Text +'with' Keyword +'\n' Text + +'class' Keyword +' ' Text +'Rational' Name.Class +'(' Punctuation +'x' Name +':' Punctuation +' ' Text +'Int' Name.Class +',' Punctuation +' ' Text +'y' Name +':' Punctuation +' ' Text +'Int' Name.Class +')' Punctuation +' ' Text +'with' Keyword +'\n ' Text +'def' Keyword +' ' Text +'numer' Name.Function +' ' Text +'=' Operator +' ' Text +'x' Name +'\n ' Text +'def' Keyword +' ' Text +'denom' Name.Function +' ' Text +'=' Operator +' ' Text +'y' Name +'\n' Text + +'class' Keyword +' ' Text +'Cons' Name.Class +'(' Punctuation +'_head' Name +':' Punctuation +' ' Text +'Int' Name.Class +',' Punctuation +' ' Text +'_tail' Name +':' Punctuation +' ' Text +'IntList' Name.Class +')' Punctuation +' ' Text +'extends' Keyword +' ' Text +'IntList' Name.Class +' ' Text +'with' Keyword +'\n ' Text +'val' Keyword.Declaration +' ' Text +'head' Name +' ' Text +'=' Operator +' ' Text +'_head' Name +'\n ' Text +'val' Keyword.Declaration +' ' Text +'tail' Name +' ' Text +'=' Operator +' ' Text +'_tail' Name +'\n' Text + +'class' Keyword +' ' Text +'Int' Name.Class +' ' Text +'with' Keyword +'\n ' Text +'def' Keyword +' ' Text +'+' Name.Function +' ' Text +'(' Punctuation +'that' Name +':' Punctuation +' ' Text +'Double' Name.Class +')' Punctuation +':' Punctuation +' ' Text +'Double' Name.Class +'\n ' Text +'def' Keyword +' ' Text +'+' Name.Function +' ' Text +'(' Punctuation +'that' Name +':' Punctuation +' ' Text +'Float' Name.Class +')' Punctuation +':' Punctuation +' ' Text +'Float' Name.Class +'\n ' Text +'def' Keyword +' ' Text +'+' Name.Function +' ' Text +'(' Punctuation +'that' Name +':' Punctuation +' ' Text +'Long' Name.Class +')' Punctuation +':' Punctuation +' ' Text +'Long' Name.Class +'\n ' Text +'def' Keyword +' ' Text +'+' Name.Function +' ' Text +'(' Punctuation +'that' Name +':' Punctuation +' ' Text +'Int' Name.Class +')' Punctuation +':' Punctuation +' ' Text +'Int' Name.Class +' ' Text +'// same for -, *, /, %\n' Comment.Single + +' ' Text +'def' Keyword +' ' Text +'<<' Name.Function +' ' Text +'(' Punctuation +'cnt' Name +':' Punctuation +' ' Text +'Int' Name.Class +')' Punctuation +':' Punctuation +' ' Text +'Int' Name.Class +' ' Text +'// same for >>, >>> */\n' Comment.Single + +' ' Text +'def' Keyword +' ' Text +'&' Name.Function +' ' Text +'(' Punctuation +'that' Name +':' Punctuation +' ' Text +'Long' Name.Class +')' Punctuation +':' Punctuation +' ' Text +'Long' Name.Class +'\n ' Text +'def' Keyword +' ' Text +'&' Name.Function +' ' Text +'(' Punctuation +'that' Name +':' Punctuation +' ' Text +'Int' Name.Class +')' Punctuation +':' Punctuation +' ' Text +'Int' Name.Class +' ' Text +'// same for |, ^ */\n' Comment.Single + +' ' Text +'def' Keyword +' ' Text +'==' Name.Function +' ' Text +'(' Punctuation +'that' Name +':' Punctuation +' ' Text +'Double' Name.Class +')' Punctuation +':' Punctuation +' ' Text +'Boolean' Name.Class +'\n ' Text +'def' Keyword +' ' Text +'==' Name.Function +' ' Text +'(' Punctuation +'that' Name +':' Punctuation +' ' Text +'Float' Name.Class +')' Punctuation +':' Punctuation +' ' Text +'Boolean' Name.Class +'\n ' Text +'def' Keyword +' ' Text +'==' Name.Function +' ' Text +'(' Punctuation +'that' Name +':' Punctuation +' ' Text +'Long' Name.Class +')' Punctuation +':' Punctuation +' ' Text +'Boolean' Name.Class +' ' Text +'// same for !=, <, >, <=, >=\n' Comment.Single + +'end' Keyword +' ' Text +'Int' Name.Class +'\n' Text + +'class' Keyword +' ' Text +'Sub' Name.Class +' ' Text +'extends' Keyword +' ' Text +'Base' Name.Class +' ' Text +'with' Keyword +' ' Text +'Something' Name.Class +' ' Text +'{' Punctuation +'\n ' Text +'override' Keyword +' ' Text +'def' Keyword +' ' Text +'foo' Name.Function +' ' Text +'=' Operator +' ' Text +'2' Literal.Number.Integer +'\n ' Text +'def' Keyword +' ' Text +'bar' Name.Function +' ' Text +'=' Operator +' ' Text +'3' Literal.Number.Integer +'\n' Text + +'}' Punctuation +'\n' Text + +'class' Keyword +' ' Text +'Succ' Name.Class +'(' Punctuation +'n' Name +':' Punctuation +' ' Text +'Nat' Name.Class +')' Punctuation +' ' Text +'extends' Keyword +' ' Text +'Nat' Name.Class +' ' Text +'with' Keyword +'\n ' Text +'// ...\n' Comment.Single + +'open' Keyword +' ' Text +'class' Keyword +' ' Text +'Writer' Name.Class +'[' Punctuation +'T' Name.Class +']' Punctuation +' ' Text +'{' Punctuation +'\n ' Text +'/*' Comment.Multiline +'*' Comment.Multiline +' Sends to stdout, can be overridden ' Comment.Multiline +'*/' Comment.Multiline +'\n ' Text +'def' Keyword +' ' Text +'send' Name.Function +'(' Punctuation +'x' Name +':' Punctuation +' ' Text +'T' Name.Class +')' Punctuation +' ' Text +'=' Operator +' ' Text +'println' Name +'(' Punctuation +'x' Name +')' Punctuation +'\n ' Text +'/*' Comment.Multiline +'*' Comment.Multiline +' Sends all arguments using `send` ' Comment.Multiline +'*/' Comment.Multiline +'\n ' Text +'def' Keyword +' ' Text +'sendAll' Name.Function +'(' Punctuation +'xs' Name +':' Punctuation +' ' Text +'T' Name.Class +'*' Operator +')' Punctuation +' ' Text +'=' Operator +' ' Text +'xs' Name +'.' Punctuation +'foreach' Name +'(' Punctuation +'send' Name +')' Punctuation +'\n' Text + +'}' Punctuation +'\n' Text + +'class' Keyword +' ' Text +'LazyList' Name.Class +'[' Punctuation +'+' Operator +'T' Name.Class +']' Punctuation +'(' Punctuation +'init' Name +':' Punctuation +' ' Text +'=>' Operator +' ' Text +'State' Name.Class +'[' Punctuation +'T' Name.Class +']' Punctuation +')' Punctuation +' ' Text +'with' Keyword +'\n ' Text +'lazy' Keyword +' ' Text +'val' Keyword.Declaration +' ' Text +'state' Name +':' Punctuation +' ' Text +'State' Name.Class +'[' Punctuation +'T' Name.Class +']' Punctuation +' ' Text +'=' Operator +' ' Text +'init' Name +'\t\t\t\n\n' Text + +'trait' Keyword +' ' Text +'Foo' Name.Class +' ' Text +'with' Keyword +'\n' Text + +'trait' Keyword +' ' Text +'Bar' Name.Class +' ' Text +'with' Keyword +'\n' Text + +'trait' Keyword +' ' Text +'*:' Name.Class +' ' Text +'with' Keyword +'\n' Text + +'trait' Keyword +' ' Text +'*:' Name.Class +' ' Text +'with' Keyword +'\n' Text + +'trait' Keyword +' ' Text +'::' Name.Class +' ' Text +'with' Keyword +'\n' Text + +'1' Literal.Number.Integer +' ' Text +'::' Operator +' ' Text +'Nil' Name.Class +'\n' Text + +'1' Literal.Number.Integer +' ' Text +'::' Operator +'\n\n' Text + +'object' Keyword +' ' Text +'⌘' Name.Class +' ' Text +'{' Punctuation +'\n \n' Text + +'}' Punctuation +'\n' Text + +'object' Keyword +' ' Text +'Foo' Name.Class +' ' Text +'with' Keyword +'\n' Text + +'object' Keyword +' ' Text +'Bar' Name.Class +' ' Text +'with' Keyword +'\n' Text + +'object' Keyword +' ' Text +'Zero' Name.Class +' ' Text +'extends' Keyword +' ' Text +'Nat' Name.Class +' ' Text +'with' Keyword +'\n ' Text +'.' Punctuation +'.' Punctuation +'.' Punctuation +'\n\n' Text + +'object' Keyword +' ' Text +'Enum' Name.Class +' ' Text +'extends' Keyword +' ' Text +'Enumeration' Name.Class +' ' Text +'{' Punctuation +'\n ' Text +'val' Keyword.Declaration +' ' Text +'Foo' Name.Class +',' Punctuation +' ' Text +'Bar' Name.Class +',' Punctuation +' ' Text +'Baz' Name.Class +' ' Text +'=' Operator +' ' Text +'Value' Name.Class +'\n' Text + +'}' Punctuation +'\n' Text + +'enum' Keyword +' ' Text +'Color' Name.Class +' ' Text +'with' Keyword +'\n ' Text +'case' Keyword +' ' Text +'Red' Name.Class +',' Punctuation +' ' Text +'Green' Name.Class +',' Punctuation +' ' Text +'Blue' Name.Class +',' Punctuation +' ' Text +'Magenta' Name.Class +'\n' Text + +'enum' Keyword +' ' Text +'Color' Name.Class +'(' Punctuation +'val' Keyword.Declaration +' ' Text +'test' Name +':' Punctuation +' ' Text +'Int' Name.Class +')' Punctuation +' ' Text +'with' Keyword +'\n ' Text +'case' Keyword +' ' Text +'Red' Name.Class +',' Punctuation +' ' Text +'Green' Name.Class +',' Punctuation +' ' Text +'Blue' Name.Class +',' Punctuation +' ' Text +'Magenta' Name.Class +'\n ' Text +'def' Keyword +' ' Text +'isPrimary' Name.Function +'(' Punctuation +'color' Name +':' Punctuation +' ' Text +'Color' Name.Class +')' Punctuation +':' Punctuation +' ' Text +'Boolean' Name.Class +' ' Text +'=' Operator +'\n ' Text +'color' Name +' ' Text +'match' Keyword +'\n ' Text +'case' Keyword +' ' Text +'Red' Name.Class +' ' Text +'|' Operator +' ' Text +'Green' Name.Class +' ' Text +'|' Operator +' ' Text +'Blue' Name.Class +' ' Text +'=>' Operator +' ' Text +'true' Keyword.Constant +'\n ' Text +'case' Keyword +' ' Text +'Magenta' Name.Class +' ' Text +'=>' Operator +' ' Text +'false' Keyword.Constant +'\n' Text + +'enum' Keyword +' ' Text +'State' Name.Class +'[' Punctuation +'T' Name.Class +']' Punctuation +' ' Text +'with' Keyword +'\n ' Text +'case' Keyword +' ' Text +'Empty' Name.Class +'\n ' Text +'case' Keyword +' ' Text +'Cons' Name.Class +'(' Punctuation +'hd' Name +':' Punctuation +' ' Text +'T' Name.Class +',' Punctuation +' ' Text +'tl' Name +':' Punctuation +' ' Text +'LazyList' Name.Class +'[' Punctuation +'T' Name.Class +']' Punctuation +')' Punctuation +'\n' Text + +'abstract' Keyword +' ' Text +'class' Keyword +' ' Text +'Color' Name.Class +'\n' Text + +'object' Keyword +' ' Text +'Color' Name.Class +' ' Text +'{' Punctuation +'\n ' Text +'val' Keyword.Declaration +' ' Text +'Red' Name.Class +' ' Text +'=' Operator +' ' Text +'Color' Name.Class +'(' Punctuation +')' Punctuation +'\n ' Text +'val' Keyword.Declaration +' ' Text +'Green' Name.Class +' ' Text +'=' Operator +' ' Text +'Color' Name.Class +'(' Punctuation +')' Punctuation +'\n ' Text +'val' Keyword.Declaration +' ' Text +'Blue' Name.Class +' ' Text +'=' Operator +' ' Text +'Color' Name.Class +'(' Punctuation +')' Punctuation +'\n ' Text +'val' Keyword.Declaration +' ' Text +'Magenta' Name.Class +' ' Text +'=' Operator +' ' Text +'Color' Name.Class +'(' Punctuation +')' Punctuation +'\n ' Text +'.' Punctuation +'.' Punctuation +'.' Punctuation +'\n' Text + +'}' Punctuation +'\n' Text + +'enum' Keyword +' ' Text +'Vehicle' Name.Class +'(' Punctuation +'val' Keyword.Declaration +' ' Text +'numberOfWheels' Name +':' Punctuation +' ' Text +'Int' Name.Class +')' Punctuation +' ' Text +'{' Punctuation +'\n ' Text +'case' Keyword +' ' Text +'Unicycle' Name.Class +' ' Text +'extends' Keyword +' ' Text +'Vehicle' Name.Class +'(' Punctuation +'1' Literal.Number.Integer +')' Punctuation +'\n ' Text +'case' Keyword +' ' Text +'Bicycle' Name.Class +' ' Text +'extends' Keyword +' ' Text +'Vehicle' Name.Class +'(' Punctuation +'2' Literal.Number.Integer +')' Punctuation +'\n ' Text +'case' Keyword +' ' Text +'Car' Name.Class +' ' Text +'extends' Keyword +' ' Text +'Vehicle' Name.Class +'(' Punctuation +'4' Literal.Number.Integer +')' Punctuation +'\n' Text + +'}' Punctuation +'\n' Text + +'enum' Keyword +' ' Text +'Vehicle' Name.Class +'(' Punctuation +'val' Keyword.Declaration +' ' Text +'numberOfWheels' Name +':' Punctuation +' ' Text +'Int' Name.Class +')' Punctuation +':' Punctuation +'\n ' Text +'case' Keyword +' ' Text +'Unicycle' Name.Class +' ' Text +'extends' Keyword +' ' Text +'Vehicle' Name.Class +'(' Punctuation +'1' Literal.Number.Integer +')' Punctuation +'\n ' Text +'case' Keyword +' ' Text +'Bicycle' Name.Class +' ' Text +'extends' Keyword +' ' Text +'Vehicle' Name.Class +'(' Punctuation +'2' Literal.Number.Integer +')' Punctuation +'\n ' Text +'case' Keyword +' ' Text +'Car' Name.Class +' ' Text +'extends' Keyword +' ' Text +'Vehicle' Name.Class +'(' Punctuation +'4' Literal.Number.Integer +')' Punctuation +'\n' Text diff --git a/tests/examplefiles/scala/dependent-types.scala b/tests/examplefiles/scala/dependent-types.scala new file mode 100644 index 00000000..8ac232b1 --- /dev/null +++ b/tests/examplefiles/scala/dependent-types.scala @@ -0,0 +1,6 @@ +trait Entry { type Key; val key: Key } +def extractKey(e: Entry): e.Key = e.key +val extractor: (e: Entry) => e.Key = extractKey +type Extractor = Function1[Entry, Entry#Key] { + def apply(e: Entry): e.Key +}
\ No newline at end of file diff --git a/tests/examplefiles/scala/dependent-types.scala.output b/tests/examplefiles/scala/dependent-types.scala.output new file mode 100644 index 00000000..70f2ad52 --- /dev/null +++ b/tests/examplefiles/scala/dependent-types.scala.output @@ -0,0 +1,102 @@ +'trait' Keyword +' ' Text +'Entry' Name.Class +' ' Text +'{' Punctuation +' ' Text +'type' Keyword +' ' Text +'Key' Name.Class +';' Punctuation +' ' Text +'val' Keyword.Declaration +' ' Text +'key' Name +':' Punctuation +' ' Text +'Key' Name.Class +' ' Text +'}' Punctuation +'\n' Text + +'def' Keyword +' ' Text +'extractKey' Name.Function +'(' Punctuation +'e' Name +':' Punctuation +' ' Text +'Entry' Name.Class +')' Punctuation +':' Punctuation +' ' Text +'e' Name +'.' Punctuation +'Key' Name.Class +' ' Text +'=' Operator +' ' Text +'e' Name +'.' Punctuation +'key' Name +'\n' Text + +'val' Keyword.Declaration +' ' Text +'extractor' Name +':' Punctuation +' ' Text +'(' Punctuation +'e' Name +':' Punctuation +' ' Text +'Entry' Name.Class +')' Punctuation +' ' Text +'=>' Operator +' ' Text +'e' Name +'.' Punctuation +'Key' Name.Class +' ' Text +'=' Operator +' ' Text +'extractKey' Name +'\n' Text + +'type' Keyword +' ' Text +'Extractor' Name.Class +' ' Text +'=' Operator +' ' Text +'Function1' Name.Class +'[' Punctuation +'Entry' Name.Class +',' Punctuation +' ' Text +'Entry' Name.Class +'#' Name +'Key' Name.Class +']' Punctuation +' ' Text +'{' Punctuation +'\n ' Text +'def' Keyword +' ' Text +'apply' Name.Function +'(' Punctuation +'e' Name +':' Punctuation +' ' Text +'Entry' Name.Class +')' Punctuation +':' Punctuation +' ' Text +'e' Name +'.' Punctuation +'Key' Name.Class +'\n' Text + +'}' Punctuation +'\n' Text diff --git a/tests/examplefiles/scala/end-soft-keyword.scala b/tests/examplefiles/scala/end-soft-keyword.scala new file mode 100644 index 00000000..f734e423 --- /dev/null +++ b/tests/examplefiles/scala/end-soft-keyword.scala @@ -0,0 +1 @@ +end + 2
\ No newline at end of file diff --git a/tests/examplefiles/scala/end-soft-keyword.scala.output b/tests/examplefiles/scala/end-soft-keyword.scala.output new file mode 100644 index 00000000..39ead49c --- /dev/null +++ b/tests/examplefiles/scala/end-soft-keyword.scala.output @@ -0,0 +1,6 @@ +'end' Name +' ' Text +'+' Operator +' ' Text +'2' Literal.Number.Integer +'\n' Text diff --git a/tests/examplefiles/scala/end.scala b/tests/examplefiles/scala/end.scala new file mode 100644 index 00000000..b09bf2dc --- /dev/null +++ b/tests/examplefiles/scala/end.scala @@ -0,0 +1,52 @@ +new Foo: + // ... +end new +end extension +end if +end while +end for +end match +class Foo +end Foo +end bar +end `bar` +end // test comment +package p1.p2: + abstract class C(): + def this(x: Int) = + this() + if x > 0 then + val a :: b = + x :: Nil + end val // test comment + var y = + x + end y // test comment + while y > 0 do + println(y) + y -= 1 + end while // test comment + try + x match + case 0 => println("0") + case _ => + end match // test comment + finally + println("done") + end try // test comment + end if // test comment + end this // test comment + def f: String + end C // test comment + object C: + given C = + new C: + def f = "!" + end f // test comment + end new // test comment + end given // test comment + end C // test comment + extension (x: C) + def ff: String = x.f ++ x.f + end extension // test comment +end p2 // test comment
\ No newline at end of file diff --git a/tests/examplefiles/scala/end.scala.output b/tests/examplefiles/scala/end.scala.output new file mode 100644 index 00000000..3f3205c5 --- /dev/null +++ b/tests/examplefiles/scala/end.scala.output @@ -0,0 +1,332 @@ +'new' Keyword +' ' Text +'Foo' Name.Class +':' Punctuation +'\n ' Text +'// ...\n' Comment.Single + +'end' Keyword +' ' Text +'new' Keyword +'\n' Text + +'end' Keyword +' ' Text +'extension' Keyword +'\n' Text + +'end' Keyword +' ' Text +'if' Keyword +'\n' Text + +'end' Keyword +' ' Text +'while' Keyword +'\n' Text + +'end' Keyword +' ' Text +'for' Keyword +'\n' Text + +'end' Keyword +' ' Text +'match' Keyword +'\n' Text + +'class' Keyword +' ' Text +'Foo' Name.Class +'\n' Text + +'end' Keyword +' ' Text +'Foo' Name.Class +'\n' Text + +'end' Keyword +' ' Text +'bar' Name.Namespace +'\n' Text + +'end' Keyword +' ' Text +'`bar`' Name.Namespace +'\n' Text + +'end' Keyword +' ' Text +'// test comment\n' Comment.Single + +'package' Keyword +' ' Text +'p1' Name.Namespace +'.' Punctuation +'p2' Name +':' Punctuation +'\n ' Text +'abstract' Keyword +' ' Text +'class' Keyword +' ' Text +'C' Name.Class +'(' Punctuation +')' Punctuation +':' Punctuation +'\n ' Text +'def' Keyword +' ' Text +'this' Name.Function +'(' Punctuation +'x' Name +':' Punctuation +' ' Text +'Int' Name.Class +')' Punctuation +' ' Text +'=' Operator +'\n ' Text +'this' Name.Builtin.Pseudo +'(' Punctuation +')' Punctuation +'\n ' Text +'if' Keyword +' ' Text +'x' Name +' ' Text +'>' Operator +' ' Text +'0' Literal.Number.Integer +' ' Text +'then' Keyword +'\n ' Text +'val' Keyword.Declaration +' ' Text +'a' Name +' ' Text +'::' Operator +' ' Text +'b' Name +' ' Text +'=' Operator +'\n ' Text +'x' Name +' ' Text +'::' Operator +' ' Text +'Nil' Name.Class +'\n ' Text +'end' Keyword +' ' Text +'val' Keyword +' ' Text +'// test comment\n' Comment.Single + +' ' Text +'var' Keyword.Declaration +' ' Text +'y' Name +' ' Text +'=' Operator +'\n ' Text +'x' Name +'\n ' Text +'end' Keyword +' ' Text +'y' Name.Namespace +' ' Text +'// test comment\n' Comment.Single + +' ' Text +'while' Keyword +' ' Text +'y' Name +' ' Text +'>' Operator +' ' Text +'0' Literal.Number.Integer +' ' Text +'do' Keyword +'\n ' Text +'println' Name +'(' Punctuation +'y' Name +')' Punctuation +'\n ' Text +'y' Name +' ' Text +'-=' Operator +' ' Text +'1' Literal.Number.Integer +'\n ' Text +'end' Keyword +' ' Text +'while' Keyword +' ' Text +'// test comment\n' Comment.Single + +' ' Text +'try' Keyword +'\n ' Text +'x' Name +' ' Text +'match' Keyword +'\n ' Text +'case' Keyword +' ' Text +'0' Literal.Number.Integer +' ' Text +'=>' Operator +' ' Text +'println' Name +'(' Punctuation +'"0"' Literal.String +')' Punctuation +'\n ' Text +'case' Keyword +' ' Text +'_' Name +' ' Text +'=>' Operator +'\n ' Text +'end' Keyword +' ' Text +'match' Keyword +' ' Text +'// test comment\n' Comment.Single + +' ' Text +'finally' Keyword +'\n ' Text +'println' Name +'(' Punctuation +'"done"' Literal.String +')' Punctuation +'\n ' Text +'end' Keyword +' ' Text +'try' Name.Namespace +' ' Text +'// test comment\n' Comment.Single + +' ' Text +'end' Keyword +' ' Text +'if' Keyword +' ' Text +'// test comment\n' Comment.Single + +' ' Text +'end' Keyword +' ' Text +'this' Name.Namespace +' ' Text +'// test comment\n' Comment.Single + +' ' Text +'def' Keyword +' ' Text +'f' Name.Function +':' Punctuation +' ' Text +'String' Name.Class +'\n ' Text +'end' Keyword +' ' Text +'C' Name.Class +' ' Text +'// test comment\n' Comment.Single + +' ' Text +'object' Keyword +' ' Text +'C' Name.Class +':' Punctuation +'\n ' Text +'given' Keyword +' ' Text +'C' Name.Class +' ' Text +'=' Operator +'\n ' Text +'new' Keyword +' ' Text +'C' Name.Class +':' Punctuation +'\n ' Text +'def' Keyword +' ' Text +'f' Name.Function +' ' Text +'=' Operator +' ' Text +'"!"' Literal.String +'\n ' Text +'end' Keyword +' ' Text +'f' Name.Namespace +' ' Text +'// test comment\n' Comment.Single + +' ' Text +'end' Keyword +' ' Text +'new' Keyword +' ' Text +'// test comment\n' Comment.Single + +' ' Text +'end' Keyword +' ' Text +'given' Name.Namespace +' ' Text +'// test comment\n' Comment.Single + +' ' Text +'end' Keyword +' ' Text +'C' Name.Class +' ' Text +'// test comment\n' Comment.Single + +' ' Text +'extension' Keyword +' ' Text +'(' Punctuation +'x' Name +':' Punctuation +' ' Text +'C' Name.Class +')' Punctuation +'\n ' Text +'def' Keyword +' ' Text +'ff' Name.Function +':' Punctuation +' ' Text +'String' Name.Class +' ' Text +'=' Operator +' ' Text +'x' Name +'.' Punctuation +'f' Name +' ' Text +'++' Operator +' ' Text +'x' Name +'.' Punctuation +'f' Name +'\n ' Text +'end' Keyword +' ' Text +'extension' Keyword +' ' Text +'// test comment\n' Comment.Single + +'end' Keyword +' ' Text +'p2' Name.Namespace +' ' Text +'// test comment\n' Comment.Single diff --git a/tests/examplefiles/scala/exports.scala b/tests/examplefiles/scala/exports.scala new file mode 100644 index 00000000..3223150b --- /dev/null +++ b/tests/examplefiles/scala/exports.scala @@ -0,0 +1,17 @@ +export // This is incorrect Scala but can still be highlighted correctly +export a._ +export a.x // Test comment +export a.x.y.z // Test comment +export a.{x, y} +export a.{x => y} +export a.{x => } // This is incorrect Scala but can still be highlighted correctly +export a.{x => `test-name`} // Test comment +export given +export given a // Test comment +export given a.x // Test comment +export given a._ +export given a.{x, y} // Test comment +export given a.{x => y} +export given a.{x => `test-name`} + export scanUnit.scan + export printUnit.{status => _, _} diff --git a/tests/examplefiles/scala/exports.scala.output b/tests/examplefiles/scala/exports.scala.output new file mode 100644 index 00000000..cb8f8a86 --- /dev/null +++ b/tests/examplefiles/scala/exports.scala.output @@ -0,0 +1,193 @@ +'export' Keyword +' ' Text +'// This is incorrect Scala but can still be highlighted correctly\n' Comment.Single + +'' Text +'export' Keyword +' ' Text +'a' Name.Namespace +'.' Punctuation +'_' Name +'\n' Text + +'export' Keyword +' ' Text +'a' Name.Namespace +'.' Punctuation +'x' Name +' ' Text +'// Test comment\n' Comment.Single + +'' Text +'export' Keyword +' ' Text +'a' Name.Namespace +'.' Punctuation +'x' Name.Namespace +'.' Punctuation +'y' Name.Namespace +'.' Punctuation +'z' Name +' ' Text +'// Test comment\n' Comment.Single + +'' Text +'export' Keyword +' ' Text +'a' Name.Namespace +'.' Punctuation +'{' Punctuation +'x' Name +',' Punctuation +' ' Text +'y' Name +'}' Punctuation +'\n' Text + +'export' Keyword +' ' Text +'a' Name.Namespace +'.' Punctuation +'{' Punctuation +'x' Name +' ' Text +'=>' Operator +' ' Text +'y' Name +'}' Punctuation +'\n' Text + +'export' Keyword +' ' Text +'a' Name.Namespace +'.' Punctuation +'{' Punctuation +'x' Name +' ' Text +'=>' Operator +' ' Text +'}' Punctuation +' ' Text +'// This is incorrect Scala but can still be highlighted correctly\n' Comment.Single + +'' Text +'export' Keyword +' ' Text +'a' Name.Namespace +'.' Punctuation +'{' Punctuation +'x' Name +' ' Text +'=>' Operator +' ' Text +'`test-name`' Name +'}' Punctuation +' ' Text +'// Test comment\n' Comment.Single + +'' Text +'export' Keyword +' ' Text +'given' Keyword +'\n' Text + +'' Text +'export' Keyword +' ' Text +'given' Keyword +' ' Text +'a' Name +' ' Text +'// Test comment\n' Comment.Single + +'' Text +'export' Keyword +' ' Text +'given' Keyword +' ' Text +'a' Name.Namespace +'.' Punctuation +'x' Name +' ' Text +'// Test comment\n' Comment.Single + +'' Text +'export' Keyword +' ' Text +'given' Keyword +' ' Text +'a' Name.Namespace +'.' Punctuation +'_' Name +'\n' Text + +'export' Keyword +' ' Text +'given' Keyword +' ' Text +'a' Name.Namespace +'.' Punctuation +'{' Punctuation +'x' Name +',' Punctuation +' ' Text +'y' Name +'}' Punctuation +' ' Text +'// Test comment\n' Comment.Single + +'' Text +'export' Keyword +' ' Text +'given' Keyword +' ' Text +'a' Name.Namespace +'.' Punctuation +'{' Punctuation +'x' Name +' ' Text +'=>' Operator +' ' Text +'y' Name +'}' Punctuation +'\n' Text + +'export' Keyword +' ' Text +'given' Keyword +' ' Text +'a' Name.Namespace +'.' Punctuation +'{' Punctuation +'x' Name +' ' Text +'=>' Operator +' ' Text +'`test-name`' Name +'}' Punctuation +'\n' Text + +' ' Text +'export' Keyword +' ' Text +'scanUnit' Name.Namespace +'.' Punctuation +'scan' Name +'\n' Text + +' ' Text +'export' Keyword +' ' Text +'printUnit' Name.Namespace +'.' Punctuation +'{' Punctuation +'status' Name +' ' Text +'=>' Operator +' ' Text +'_' Name +',' Punctuation +' ' Text +'_' Name +'}' Punctuation +'\n' Text diff --git a/tests/examplefiles/scala/extensions.scala b/tests/examplefiles/scala/extensions.scala new file mode 100644 index 00000000..25420906 --- /dev/null +++ b/tests/examplefiles/scala/extensions.scala @@ -0,0 +1,25 @@ +extension (x: String) + def < (y: String): Boolean = ... +extension (x: Elem) + def +: (xs: Seq[Elem]): Seq[Elem] = ... +extension (x: Number) + infix def min (y: Number): Number = ... +extension (ss: Seq[String]) + def longestStrings: Seq[String] = + val maxLength = ss.map(_.length).max + ss.filter(_.length == maxLength) + def longestString: String = longestStrings.head +extension (ss: Seq[String]) { + def longestStrings: Seq[String] = { + val maxLength = ss.map(_.length).max + ss.filter(_.length == maxLength) + } + def longestString: String = longestStrings.head +} +extension (i: Int) def isZero: Boolean = i == 0 +extension (i: Int) def divide(d: Int): Option[(Int, Int)] = ??? +extension (x: Rational) + infix def min(that Rational): Rational = ... +given [T: Ordering]: Ordering[List[T]] with + extension (xs: List[T]) + def < (ys: List[T]): Boolean = ...
\ No newline at end of file diff --git a/tests/examplefiles/scala/extensions.scala.output b/tests/examplefiles/scala/extensions.scala.output new file mode 100644 index 00000000..b9255151 --- /dev/null +++ b/tests/examplefiles/scala/extensions.scala.output @@ -0,0 +1,388 @@ +'extension' Keyword +' ' Text +'(' Punctuation +'x' Name +':' Punctuation +' ' Text +'String' Name.Class +')' Punctuation +'\n ' Text +'def' Keyword +' ' Text +'<' Name.Function +' ' Text +'(' Punctuation +'y' Name +':' Punctuation +' ' Text +'String' Name.Class +')' Punctuation +':' Punctuation +' ' Text +'Boolean' Name.Class +' ' Text +'=' Operator +' ' Text +'.' Punctuation +'.' Punctuation +'.' Punctuation +'\n' Text + +'extension' Keyword +' ' Text +'(' Punctuation +'x' Name +':' Punctuation +' ' Text +'Elem' Name.Class +')' Punctuation +'\n ' Text +'def' Keyword +' ' Text +'+:' Name.Function +' ' Text +'(' Punctuation +'xs' Name +':' Punctuation +' ' Text +'Seq' Name.Class +'[' Punctuation +'Elem' Name.Class +']' Punctuation +')' Punctuation +':' Punctuation +' ' Text +'Seq' Name.Class +'[' Punctuation +'Elem' Name.Class +']' Punctuation +' ' Text +'=' Operator +' ' Text +'.' Punctuation +'.' Punctuation +'.' Punctuation +'\n' Text + +'extension' Keyword +' ' Text +'(' Punctuation +'x' Name +':' Punctuation +' ' Text +'Number' Name.Class +')' Punctuation +'\n ' Text +'infix' Keyword +' ' Text +'def' Keyword +' ' Text +'min' Name.Function +' ' Text +'(' Punctuation +'y' Name +':' Punctuation +' ' Text +'Number' Name.Class +')' Punctuation +':' Punctuation +' ' Text +'Number' Name.Class +' ' Text +'=' Operator +' ' Text +'.' Punctuation +'.' Punctuation +'.' Punctuation +'\n' Text + +'extension' Keyword +' ' Text +'(' Punctuation +'ss' Name +':' Punctuation +' ' Text +'Seq' Name.Class +'[' Punctuation +'String' Name.Class +']' Punctuation +')' Punctuation +'\n ' Text +'def' Keyword +' ' Text +'longestStrings' Name.Function +':' Punctuation +' ' Text +'Seq' Name.Class +'[' Punctuation +'String' Name.Class +']' Punctuation +' ' Text +'=' Operator +'\n ' Text +'val' Keyword.Declaration +' ' Text +'maxLength' Name +' ' Text +'=' Operator +' ' Text +'ss' Name +'.' Punctuation +'map' Name +'(' Punctuation +'_' Name +'.' Punctuation +'length' Name +')' Punctuation +'.' Punctuation +'max' Name +'\n ' Text +'ss' Name +'.' Punctuation +'filter' Name +'(' Punctuation +'_' Name +'.' Punctuation +'length' Name +' ' Text +'==' Operator +' ' Text +'maxLength' Name +')' Punctuation +'\n ' Text +'def' Keyword +' ' Text +'longestString' Name.Function +':' Punctuation +' ' Text +'String' Name.Class +' ' Text +'=' Operator +' ' Text +'longestStrings' Name +'.' Punctuation +'head' Name +'\n' Text + +'extension' Keyword +' ' Text +'(' Punctuation +'ss' Name +':' Punctuation +' ' Text +'Seq' Name.Class +'[' Punctuation +'String' Name.Class +']' Punctuation +')' Punctuation +' ' Text +'{' Punctuation +'\n ' Text +'def' Keyword +' ' Text +'longestStrings' Name.Function +':' Punctuation +' ' Text +'Seq' Name.Class +'[' Punctuation +'String' Name.Class +']' Punctuation +' ' Text +'=' Operator +' ' Text +'{' Punctuation +'\n ' Text +'val' Keyword.Declaration +' ' Text +'maxLength' Name +' ' Text +'=' Operator +' ' Text +'ss' Name +'.' Punctuation +'map' Name +'(' Punctuation +'_' Name +'.' Punctuation +'length' Name +')' Punctuation +'.' Punctuation +'max' Name +'\n ' Text +'ss' Name +'.' Punctuation +'filter' Name +'(' Punctuation +'_' Name +'.' Punctuation +'length' Name +' ' Text +'==' Operator +' ' Text +'maxLength' Name +')' Punctuation +'\n ' Text +'}' Punctuation +'\n ' Text +'def' Keyword +' ' Text +'longestString' Name.Function +':' Punctuation +' ' Text +'String' Name.Class +' ' Text +'=' Operator +' ' Text +'longestStrings' Name +'.' Punctuation +'head' Name +'\n' Text + +'}' Punctuation +'\n' Text + +'extension' Keyword +' ' Text +'(' Punctuation +'i' Name +':' Punctuation +' ' Text +'Int' Name.Class +')' Punctuation +' ' Text +'def' Keyword +' ' Text +'isZero' Name.Function +':' Punctuation +' ' Text +'Boolean' Name.Class +' ' Text +'=' Operator +' ' Text +'i' Name +' ' Text +'==' Operator +' ' Text +'0' Literal.Number.Integer +'\n' Text + +'extension' Keyword +' ' Text +'(' Punctuation +'i' Name +':' Punctuation +' ' Text +'Int' Name.Class +')' Punctuation +' ' Text +'def' Keyword +' ' Text +'divide' Name.Function +'(' Punctuation +'d' Name +':' Punctuation +' ' Text +'Int' Name.Class +')' Punctuation +':' Punctuation +' ' Text +'Option' Name.Class +'[' Punctuation +'(' Punctuation +'Int' Name.Class +',' Punctuation +' ' Text +'Int' Name.Class +')' Punctuation +']' Punctuation +' ' Text +'=' Operator +' ' Text +'???' Operator +'\n' Text + +'extension' Keyword +' ' Text +'(' Punctuation +'x' Name +':' Punctuation +' ' Text +'Rational' Name.Class +')' Punctuation +'\n ' Text +'infix' Keyword +' ' Text +'def' Keyword +' ' Text +'min' Name.Function +'(' Punctuation +'that' Name +' ' Text +'Rational' Name.Class +')' Punctuation +':' Punctuation +' ' Text +'Rational' Name.Class +' ' Text +'=' Operator +' ' Text +'.' Punctuation +'.' Punctuation +'.' Punctuation +'\n' Text + +'given' Keyword +' ' Text +'[' Punctuation +'T' Name.Class +':' Punctuation +' ' Text +'Ordering' Name.Class +']' Punctuation +':' Punctuation +' ' Text +'Ordering' Name.Class +'[' Punctuation +'List' Name.Class +'[' Punctuation +'T' Name.Class +']' Punctuation +']' Punctuation +' ' Text +'with' Keyword +'\n ' Text +'extension' Keyword +' ' Text +'(' Punctuation +'xs' Name +':' Punctuation +' ' Text +'List' Name.Class +'[' Punctuation +'T' Name.Class +']' Punctuation +')' Punctuation +'\n ' Text +'def' Keyword +' ' Text +'<' Name.Function +' ' Text +'(' Punctuation +'ys' Name +':' Punctuation +' ' Text +'List' Name.Class +'[' Punctuation +'T' Name.Class +']' Punctuation +')' Punctuation +':' Punctuation +' ' Text +'Boolean' Name.Class +' ' Text +'=' Operator +' ' Text +'.' Punctuation +'.' Punctuation +'.' Punctuation +'\n' Text diff --git a/tests/examplefiles/scala/for-comprehension.scala b/tests/examplefiles/scala/for-comprehension.scala new file mode 100644 index 00000000..053e554f --- /dev/null +++ b/tests/examplefiles/scala/for-comprehension.scala @@ -0,0 +1,2 @@ +for ( i <- 1 to 10 ) +for (user <- userBase if user.age >= 20 && user.age < 30) yield user.name
\ No newline at end of file diff --git a/tests/examplefiles/scala/for-comprehension.scala.output b/tests/examplefiles/scala/for-comprehension.scala.output new file mode 100644 index 00000000..55147d57 --- /dev/null +++ b/tests/examplefiles/scala/for-comprehension.scala.output @@ -0,0 +1,53 @@ +'for' Keyword +' ' Text +'(' Punctuation +' ' Text +'i' Name +' ' Text +'<-' Operator +' ' Text +'1' Literal.Number.Integer +' ' Text +'to' Name +' ' Text +'10' Literal.Number.Integer +' ' Text +')' Punctuation +'\n' Text + +'for' Keyword +' ' Text +'(' Punctuation +'user' Name +' ' Text +'<-' Operator +' ' Text +'userBase' Name +' ' Text +'if' Keyword +' ' Text +'user' Name +'.' Punctuation +'age' Name +' ' Text +'>=' Operator +' ' Text +'20' Literal.Number.Integer +' ' Text +'&&' Operator +' ' Text +'user' Name +'.' Punctuation +'age' Name +' ' Text +'<' Operator +' ' Text +'30' Literal.Number.Integer +')' Punctuation +' ' Text +'yield' Keyword +' ' Text +'user' Name +'.' Punctuation +'name' Name +'\n' Text diff --git a/tests/examplefiles/scala/imports.scala b/tests/examplefiles/scala/imports.scala new file mode 100644 index 00000000..357a2f83 --- /dev/null +++ b/tests/examplefiles/scala/imports.scala @@ -0,0 +1,16 @@ +import // This is incorrect Scala but can still be highlighted correctly +import a.{x => y} // Test comment +import a.{x => } // This is incorrect Scala but can still be highlighted correctly +import a.{x => `test-name`} +import a.given +import a.{given a} +import a.{x, y} +import a._ +import a.x +import a.x.y.z +import java.io.{File, IOException, FileNotFoundException} +import java.io.File +import scala.math.{given Ordering[Int]} +import scala.math.{given Ordering[?]} +import a.givenSomething +import givenPackage diff --git a/tests/examplefiles/scala/imports.scala.output b/tests/examplefiles/scala/imports.scala.output new file mode 100644 index 00000000..408e910c --- /dev/null +++ b/tests/examplefiles/scala/imports.scala.output @@ -0,0 +1,171 @@ +'import' Keyword +' ' Text +'// This is incorrect Scala but can still be highlighted correctly\n' Comment.Single + +'' Text +'import' Keyword +' ' Text +'a' Name.Namespace +'.' Punctuation +'{' Punctuation +'x' Name +' ' Text +'=>' Operator +' ' Text +'y' Name +'}' Punctuation +' ' Text +'// Test comment\n' Comment.Single + +'' Text +'import' Keyword +' ' Text +'a' Name.Namespace +'.' Punctuation +'{' Punctuation +'x' Name +' ' Text +'=>' Operator +' ' Text +'}' Punctuation +' ' Text +'// This is incorrect Scala but can still be highlighted correctly\n' Comment.Single + +'' Text +'import' Keyword +' ' Text +'a' Name.Namespace +'.' Punctuation +'{' Punctuation +'x' Name +' ' Text +'=>' Operator +' ' Text +'`test-name`' Name +'}' Punctuation +'\n' Text + +'import' Keyword +' ' Text +'a' Name.Namespace +'.' Punctuation +'given' Keyword +'\n' Text + +'import' Keyword +' ' Text +'a' Name.Namespace +'.' Punctuation +'{' Punctuation +'given' Keyword +' ' Text +'a' Name +'}' Punctuation +'\n' Text + +'import' Keyword +' ' Text +'a' Name.Namespace +'.' Punctuation +'{' Punctuation +'x' Name +',' Punctuation +' ' Text +'y' Name +'}' Punctuation +'\n' Text + +'import' Keyword +' ' Text +'a' Name.Namespace +'.' Punctuation +'_' Name +'\n' Text + +'import' Keyword +' ' Text +'a' Name.Namespace +'.' Punctuation +'x' Name +'\n' Text + +'import' Keyword +' ' Text +'a' Name.Namespace +'.' Punctuation +'x' Name.Namespace +'.' Punctuation +'y' Name.Namespace +'.' Punctuation +'z' Name +'\n' Text + +'import' Keyword +' ' Text +'java' Name.Namespace +'.' Punctuation +'io' Name.Namespace +'.' Punctuation +'{' Punctuation +'File' Name.Class +',' Punctuation +' ' Text +'IOException' Name.Class +',' Punctuation +' ' Text +'FileNotFoundException' Name.Class +'}' Punctuation +'\n' Text + +'import' Keyword +' ' Text +'java' Name.Namespace +'.' Punctuation +'io' Name.Namespace +'.' Punctuation +'File' Name.Class +'\n' Text + +'import' Keyword +' ' Text +'scala' Name.Namespace +'.' Punctuation +'math' Name.Namespace +'.' Punctuation +'{' Punctuation +'given' Keyword +' ' Text +'Ordering' Name.Class +'[' Punctuation +'Int' Name.Class +']' Punctuation +'}' Punctuation +'\n' Text + +'import' Keyword +' ' Text +'scala' Name.Namespace +'.' Punctuation +'math' Name.Namespace +'.' Punctuation +'{' Punctuation +'given' Keyword +' ' Text +'Ordering' Name.Class +'[' Punctuation +'?' Name +']' Punctuation +'}' Punctuation +'\n' Text + +'import' Keyword +' ' Text +'a' Name.Namespace +'.' Punctuation +'givenSomething' Name +'\n' Text + +'import' Keyword +' ' Text +'givenPackage' Name +'\n' Text diff --git a/tests/examplefiles/scala/inheritance.scala b/tests/examplefiles/scala/inheritance.scala new file mode 100644 index 00000000..a9d24946 --- /dev/null +++ b/tests/examplefiles/scala/inheritance.scala @@ -0,0 +1,11 @@ +// Extends +trait A extends B +trait A extends (B => B){} +trait Color +object Red extends Color + +// Derives +enum Tree[T] derives Eq, Ordering, Show { + case Branch[T](left: Tree[T], right: Tree[T]) + case Leaf[T](elem: T) +}
\ No newline at end of file diff --git a/tests/examplefiles/scala/inheritance.scala.output b/tests/examplefiles/scala/inheritance.scala.output new file mode 100644 index 00000000..c55eec64 --- /dev/null +++ b/tests/examplefiles/scala/inheritance.scala.output @@ -0,0 +1,104 @@ +'// Extends\n' Comment.Single + +'trait' Keyword +' ' Text +'A' Name.Class +' ' Text +'extends' Keyword +' ' Text +'B' Name.Class +'\n' Text + +'trait' Keyword +' ' Text +'A' Name.Class +' ' Text +'extends' Keyword +' ' Text +'(' Punctuation +'B' Name.Class +' ' Text +'=>' Operator +' ' Text +'B' Name.Class +')' Punctuation +'{' Punctuation +'}' Punctuation +'\n' Text + +'trait' Keyword +' ' Text +'Color' Name.Class +'\n' Text + +'object' Keyword +' ' Text +'Red' Name.Class +' ' Text +'extends' Keyword +' ' Text +'Color' Name.Class +'\n\n' Text + +'// Derives\n' Comment.Single + +'enum' Keyword +' ' Text +'Tree' Name.Class +'[' Punctuation +'T' Name.Class +']' Punctuation +' ' Text +'derives' Keyword +' ' Text +'Eq' Name.Class +',' Punctuation +' ' Text +'Ordering' Name.Class +',' Punctuation +' ' Text +'Show' Name.Class +' ' Text +'{' Punctuation +'\n ' Text +'case' Keyword +' ' Text +'Branch' Name.Class +'[' Punctuation +'T' Name.Class +']' Punctuation +'(' Punctuation +'left' Name +':' Punctuation +' ' Text +'Tree' Name.Class +'[' Punctuation +'T' Name.Class +']' Punctuation +',' Punctuation +' ' Text +'right' Name +':' Punctuation +' ' Text +'Tree' Name.Class +'[' Punctuation +'T' Name.Class +']' Punctuation +')' Punctuation +'\n ' Text +'case' Keyword +' ' Text +'Leaf' Name.Class +'[' Punctuation +'T' Name.Class +']' Punctuation +'(' Punctuation +'elem' Name +':' Punctuation +' ' Text +'T' Name.Class +')' Punctuation +'\n' Text + +'}' Punctuation +'\n' Text diff --git a/tests/examplefiles/scala/inline.scala b/tests/examplefiles/scala/inline.scala new file mode 100644 index 00000000..fce07bb4 --- /dev/null +++ b/tests/examplefiles/scala/inline.scala @@ -0,0 +1,4 @@ +inline def inline(inline x: Int): Double = ??? +inline def power(x: Double, inline n: Int): Double = +inline if (n == 0) 1 else 2 +inline val c = 0
\ No newline at end of file diff --git a/tests/examplefiles/scala/inline.scala.output b/tests/examplefiles/scala/inline.scala.output new file mode 100644 index 00000000..4104d2bd --- /dev/null +++ b/tests/examplefiles/scala/inline.scala.output @@ -0,0 +1,77 @@ +'inline' Keyword +' ' Text +'def' Keyword +' ' Text +'inline' Name.Function +'(' Punctuation +'inline' Keyword +' ' Text +'x' Name +':' Punctuation +' ' Text +'Int' Name.Class +')' Punctuation +':' Punctuation +' ' Text +'Double' Name.Class +' ' Text +'=' Operator +' ' Text +'???' Operator +'\n' Text + +'inline' Keyword +' ' Text +'def' Keyword +' ' Text +'power' Name.Function +'(' Punctuation +'x' Name +':' Punctuation +' ' Text +'Double' Name.Class +',' Punctuation +' ' Text +'inline' Keyword +' ' Text +'n' Name +':' Punctuation +' ' Text +'Int' Name.Class +')' Punctuation +':' Punctuation +' ' Text +'Double' Name.Class +' ' Text +'=' Operator +'\n' Text + +'inline' Keyword +' ' Text +'if' Keyword +' ' Text +'(' Punctuation +'n' Name +' ' Text +'==' Operator +' ' Text +'0' Literal.Number.Integer +')' Punctuation +' ' Text +'1' Literal.Number.Integer +' ' Text +'else' Keyword +' ' Text +'2' Literal.Number.Integer +'\n' Text + +'inline' Keyword +' ' Text +'val' Keyword.Declaration +' ' Text +'c' Name +' ' Text +'=' Operator +' ' Text +'0' Literal.Number.Integer +'\n' Text diff --git a/tests/examplefiles/scala/interp.scala b/tests/examplefiles/scala/interp.scala deleted file mode 100644 index 4131b75e..00000000 --- a/tests/examplefiles/scala/interp.scala +++ /dev/null @@ -1,10 +0,0 @@ -val n = 123; -val a = s"n=$n"; -val a2 = s"n=$n''"; -val b = s"""n=$n"""; -val c = f"n=$n%f"; -val d = f"""n=$n%f"""; -val d2 = s"""a""""; -val e = s"abc\u00e9"; -val f = s"a${n}b"; -val g = s"a${n + 1}b"; diff --git a/tests/examplefiles/scala/interp.scala.output b/tests/examplefiles/scala/interp.scala.output deleted file mode 100644 index 4c4c2d17..00000000 --- a/tests/examplefiles/scala/interp.scala.output +++ /dev/null @@ -1,140 +0,0 @@ -'val' Keyword -' ' Text -'n' Name -' ' Text -'=' Operator -' ' Text -'123' Literal.Number.Integer -';' Operator -'\n' Text - -'val' Keyword -' ' Text -'a' Name -' ' Text -'=' Operator -' ' Text -'s"' Literal.String -'n=' Literal.String -'$n' Literal.String.Interpol -'"' Literal.String -';' Operator -'\n' Text - -'val' Keyword -' ' Text -'a2' Name -' ' Text -'=' Operator -' ' Text -'s"' Literal.String -'n=' Literal.String -'$n' Literal.String.Interpol -"''" Literal.String -'"' Literal.String -';' Operator -'\n' Text - -'val' Keyword -' ' Text -'b' Name -' ' Text -'=' Operator -' ' Text -'s"""' Literal.String -'n=' Literal.String -'$n' Literal.String.Interpol -'"""' Literal.String -';' Operator -'\n' Text - -'val' Keyword -' ' Text -'c' Name -' ' Text -'=' Operator -' ' Text -'f"' Literal.String -'n=' Literal.String -'$n' Literal.String.Interpol -'%f' Literal.String -'"' Literal.String -';' Operator -'\n' Text - -'val' Keyword -' ' Text -'d' Name -' ' Text -'=' Operator -' ' Text -'f"""' Literal.String -'n=' Literal.String -'$n' Literal.String.Interpol -'%f' Literal.String -'"""' Literal.String -';' Operator -'\n' Text - -'val' Keyword -' ' Text -'d2' Name -' ' Text -'=' Operator -' ' Text -'s"""' Literal.String -'a' Literal.String -'"' Literal.String -'"""' Literal.String -';' Operator -'\n' Text - -'val' Keyword -' ' Text -'e' Name -' ' Text -'=' Operator -' ' Text -'s"' Literal.String -'abc' Literal.String -'\\u' Literal.String -'00e9' Literal.String -'"' Literal.String -';' Operator -'\n' Text - -'val' Keyword -' ' Text -'f' Name -' ' Text -'=' Operator -' ' Text -'s"' Literal.String -'a' Literal.String -'${' Literal.String.Interpol -'n' Name -'}' Literal.String.Interpol -'b' Literal.String -'"' Literal.String -';' Operator -'\n' Text - -'val' Keyword -' ' Text -'g' Name -' ' Text -'=' Operator -' ' Text -'s"' Literal.String -'a' Literal.String -'${' Literal.String.Interpol -'n' Name -' ' Text -'+' Operator -' ' Text -'1' Literal.Number.Integer -'}' Literal.String.Interpol -'b' Literal.String -'"' Literal.String -';' Operator -'\n' Text diff --git a/tests/examplefiles/scala/interpolated-string.scala b/tests/examplefiles/scala/interpolated-string.scala new file mode 100644 index 00000000..71ab34bb --- /dev/null +++ b/tests/examplefiles/scala/interpolated-string.scala @@ -0,0 +1,25 @@ +val n = 123; +val a = s"n=$n"; +val a2 = s"n=$n''"; +val b = s"""n=$n"""; +val c = f"n=$n%f"; +val d = f"""n=$n%f"""; +val d2 = s"""a""""; +val e = s"abc\u00e9"; +val f = s"a${n}b"; +val g = s"a${n + 1}b"; + +s"1 + 2 = ${ 1 + { val x = 2; x } }." +s"""1 + 2 = ${ + def add(x: Int, y: Int) = { + x + y + } + add(1, 2) +}.""" +s"$first$second" +s"$safeTagMarker${mtch.matched}$safeTagMarker" +s"$a$a$a${b}$a${b}${b}" +s"${x$}" +s"$a$$$a" // $$ is an escape +val a = 4; foo(a) +s"$safeTagMarker${val a = 4; foo(a)}$safeTagMarker" diff --git a/tests/examplefiles/scala/interpolated-string.scala.output b/tests/examplefiles/scala/interpolated-string.scala.output new file mode 100644 index 00000000..9c650371 --- /dev/null +++ b/tests/examplefiles/scala/interpolated-string.scala.output @@ -0,0 +1,316 @@ +'val' Keyword.Declaration +' ' Text +'n' Name +' ' Text +'=' Operator +' ' Text +'123' Literal.Number.Integer +';' Punctuation +'\n' Text + +'val' Keyword.Declaration +' ' Text +'a' Name +' ' Text +'=' Operator +' ' Text +'s"' Literal.String +'n=' Literal.String +'$' Literal.String.Interpol +'n' Name +'"' Literal.String +';' Punctuation +'\n' Text + +'val' Keyword.Declaration +' ' Text +'a2' Name +' ' Text +'=' Operator +' ' Text +'s"' Literal.String +'n=' Literal.String +'$' Literal.String.Interpol +'n' Name +"''" Literal.String +'"' Literal.String +';' Punctuation +'\n' Text + +'val' Keyword.Declaration +' ' Text +'b' Name +' ' Text +'=' Operator +' ' Text +'s"""' Literal.String +'n=' Literal.String +'$' Literal.String.Interpol +'n' Name +'"""' Literal.String +';' Punctuation +'\n' Text + +'val' Keyword.Declaration +' ' Text +'c' Name +' ' Text +'=' Operator +' ' Text +'f"' Literal.String +'n=' Literal.String +'$' Literal.String.Interpol +'n' Name +'%f' Literal.String +'"' Literal.String +';' Punctuation +'\n' Text + +'val' Keyword.Declaration +' ' Text +'d' Name +' ' Text +'=' Operator +' ' Text +'f"""' Literal.String +'n=' Literal.String +'$' Literal.String.Interpol +'n' Name +'%f' Literal.String +'"""' Literal.String +';' Punctuation +'\n' Text + +'val' Keyword.Declaration +' ' Text +'d2' Name +' ' Text +'=' Operator +' ' Text +'s"""' Literal.String +'a' Literal.String +'"' Literal.String +'"""' Literal.String +';' Punctuation +'\n' Text + +'val' Keyword.Declaration +' ' Text +'e' Name +' ' Text +'=' Operator +' ' Text +'s"' Literal.String +'abc' Literal.String +'\\u' Literal.String +'00e9' Literal.String +'"' Literal.String +';' Punctuation +'\n' Text + +'val' Keyword.Declaration +' ' Text +'f' Name +' ' Text +'=' Operator +' ' Text +'s"' Literal.String +'a' Literal.String +'${' Literal.String.Interpol +'n' Name +'}' Literal.String.Interpol +'b' Literal.String +'"' Literal.String +';' Punctuation +'\n' Text + +'val' Keyword.Declaration +' ' Text +'g' Name +' ' Text +'=' Operator +' ' Text +'s"' Literal.String +'a' Literal.String +'${' Literal.String.Interpol +'n' Name +' ' Text +'+' Operator +' ' Text +'1' Literal.Number.Integer +'}' Literal.String.Interpol +'b' Literal.String +'"' Literal.String +';' Punctuation +'\n\n' Text + +'s"' Literal.String +'1 + 2 = ' Literal.String +'${' Literal.String.Interpol +' ' Text +'1' Literal.Number.Integer +' ' Text +'+' Operator +' ' Text +'{' Punctuation +' ' Text +'val' Keyword.Declaration +' ' Text +'x' Name +' ' Text +'=' Operator +' ' Text +'2' Literal.Number.Integer +';' Punctuation +' ' Text +'x' Name +' ' Text +'}' Punctuation +' ' Text +'}' Literal.String.Interpol +'.' Literal.String +'"' Literal.String +'\n' Text + +'s"""' Literal.String +'1 + 2 = ' Literal.String +'${' Literal.String.Interpol +'\n ' Text +'def' Keyword +' ' Text +'add' Name.Function +'(' Punctuation +'x' Name +':' Punctuation +' ' Text +'Int' Name.Class +',' Punctuation +' ' Text +'y' Name +':' Punctuation +' ' Text +'Int' Name.Class +')' Punctuation +' ' Text +'=' Operator +' ' Text +'{' Punctuation +'\n ' Text +'x' Name +' ' Text +'+' Operator +' ' Text +'y' Name +'\n ' Text +'}' Punctuation +'\n ' Text +'add' Name +'(' Punctuation +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'2' Literal.Number.Integer +')' Punctuation +'\n' Text + +'}' Literal.String.Interpol +'.' Literal.String +'"""' Literal.String +'\n' Text + +'s"' Literal.String +'$' Literal.String.Interpol +'first' Name +'$' Literal.String.Interpol +'second' Name +'"' Literal.String +'\n' Text + +'s"' Literal.String +'$' Literal.String.Interpol +'safeTagMarker' Name +'${' Literal.String.Interpol +'mtch' Name +'.' Punctuation +'matched' Name +'}' Literal.String.Interpol +'$' Literal.String.Interpol +'safeTagMarker' Name +'"' Literal.String +'\n' Text + +'s"' Literal.String +'$' Literal.String.Interpol +'a' Name +'$' Literal.String.Interpol +'a' Name +'$' Literal.String.Interpol +'a' Name +'${' Literal.String.Interpol +'b' Name +'}' Literal.String.Interpol +'$' Literal.String.Interpol +'a' Name +'${' Literal.String.Interpol +'b' Name +'}' Literal.String.Interpol +'${' Literal.String.Interpol +'b' Name +'}' Literal.String.Interpol +'"' Literal.String +'\n' Text + +'s"' Literal.String +'${' Literal.String.Interpol +'x$' Name +'}' Literal.String.Interpol +'"' Literal.String +'\n' Text + +'s"' Literal.String +'$' Literal.String.Interpol +'a' Name +'$$' Literal.String.Escape +'$' Literal.String.Interpol +'a' Name +'"' Literal.String +' ' Text +'// $$ is an escape\n' Comment.Single + +'val' Keyword.Declaration +' ' Text +'a' Name +' ' Text +'=' Operator +' ' Text +'4' Literal.Number.Integer +';' Punctuation +' ' Text +'foo' Name +'(' Punctuation +'a' Name +')' Punctuation +'\n' Text + +'s"' Literal.String +'$' Literal.String.Interpol +'safeTagMarker' Name +'${' Literal.String.Interpol +'val' Keyword.Declaration +' ' Text +'a' Name +' ' Text +'=' Operator +' ' Text +'4' Literal.Number.Integer +';' Punctuation +' ' Text +'foo' Name +'(' Punctuation +'a' Name +')' Punctuation +'}' Literal.String.Interpol +'$' Literal.String.Interpol +'safeTagMarker' Name +'"' Literal.String +'\n' Text diff --git a/tests/examplefiles/scala/match-types.scala b/tests/examplefiles/scala/match-types.scala new file mode 100644 index 00000000..380a5984 --- /dev/null +++ b/tests/examplefiles/scala/match-types.scala @@ -0,0 +1,10 @@ +type Elem[X] = X match { + case String => Char + case Array[t] => t + case Iterable[t] => t +} + +type Concat[Xs <: Tuple, +Ys <: Tuple] <: Tuple = Xs match { + case Unit => Ys + case x *: xs => x *: Concat[xs, Ys] +}
\ No newline at end of file diff --git a/tests/examplefiles/scala/match-types.scala.output b/tests/examplefiles/scala/match-types.scala.output new file mode 100644 index 00000000..a1d58235 --- /dev/null +++ b/tests/examplefiles/scala/match-types.scala.output @@ -0,0 +1,113 @@ +'type' Keyword +' ' Text +'Elem' Name.Class +'[' Punctuation +'X' Name.Class +']' Punctuation +' ' Text +'=' Operator +' ' Text +'X' Name.Class +' ' Text +'match' Keyword +' ' Text +'{' Punctuation +'\n ' Text +'case' Keyword +' ' Text +'String' Name.Class +' ' Text +'=>' Operator +' ' Text +'Char' Name.Class +'\n ' Text +'case' Keyword +' ' Text +'Array' Name.Class +'[' Punctuation +'t' Name +']' Punctuation +' ' Text +'=>' Operator +' ' Text +'t' Name +'\n ' Text +'case' Keyword +' ' Text +'Iterable' Name.Class +'[' Punctuation +'t' Name +']' Punctuation +' ' Text +'=>' Operator +' ' Text +'t' Name +'\n' Text + +'}' Punctuation +'\n\n' Text + +'type' Keyword +' ' Text +'Concat' Name.Class +'[' Punctuation +'Xs' Name.Class +' ' Text +'<:' Operator +' ' Text +'Tuple' Name.Class +',' Punctuation +' ' Text +'+' Operator +'Ys' Name.Class +' ' Text +'<:' Operator +' ' Text +'Tuple' Name.Class +']' Punctuation +' ' Text +'<:' Operator +' ' Text +'Tuple' Name.Class +' ' Text +'=' Operator +' ' Text +'Xs' Name.Class +' ' Text +'match' Keyword +' ' Text +'{' Punctuation +'\n ' Text +'case' Keyword +' ' Text +'Unit' Name.Class +' ' Text +'=>' Operator +' ' Text +'Ys' Name.Class +'\n ' Text +'case' Keyword +' ' Text +'x' Name +' ' Text +'*:' Operator +' ' Text +'xs' Name +' ' Text +'=>' Operator +' ' Text +'x' Name +' ' Text +'*:' Operator +' ' Text +'Concat' Name.Class +'[' Punctuation +'xs' Name +',' Punctuation +' ' Text +'Ys' Name.Class +']' Punctuation +'\n' Text + +'}' Punctuation +'\n' Text diff --git a/tests/examplefiles/scala/new.scala b/tests/examplefiles/scala/new.scala new file mode 100644 index 00000000..df34bf82 --- /dev/null +++ b/tests/examplefiles/scala/new.scala @@ -0,0 +1,7 @@ +new A +new { } +new Foo +new foo.Foo +new Foo.Foo +new A: + def f = 3
\ No newline at end of file diff --git a/tests/examplefiles/scala/new.scala.output b/tests/examplefiles/scala/new.scala.output new file mode 100644 index 00000000..809c2188 --- /dev/null +++ b/tests/examplefiles/scala/new.scala.output @@ -0,0 +1,44 @@ +'new' Keyword +' ' Text +'A' Name.Class +'\n' Text + +'new' Keyword +' ' Text +'{' Punctuation +' ' Text +'}' Punctuation +'\n' Text + +'new' Keyword +' ' Text +'Foo' Name.Class +'\n' Text + +'new' Keyword +' ' Text +'foo' Name +'.' Punctuation +'Foo' Name.Class +'\n' Text + +'new' Keyword +' ' Text +'Foo' Name.Class +'.' Punctuation +'Foo' Name.Class +'\n' Text + +'new' Keyword +' ' Text +'A' Name.Class +':' Punctuation +'\n ' Text +'def' Keyword +' ' Text +'f' Name.Function +' ' Text +'=' Operator +' ' Text +'3' Literal.Number.Integer +'\n' Text diff --git a/tests/examplefiles/scala/operators.scala b/tests/examplefiles/scala/operators.scala new file mode 100644 index 00000000..632ecfc4 --- /dev/null +++ b/tests/examplefiles/scala/operators.scala @@ -0,0 +1,7 @@ +1 :: 2 :: Nil +a ++ b +a :+ b +a +: b +a :++ b +a ++: b +a + b
\ No newline at end of file diff --git a/tests/examplefiles/scala/operators.scala.output b/tests/examplefiles/scala/operators.scala.output new file mode 100644 index 00000000..19449e0e --- /dev/null +++ b/tests/examplefiles/scala/operators.scala.output @@ -0,0 +1,52 @@ +'1' Literal.Number.Integer +' ' Text +'::' Operator +' ' Text +'2' Literal.Number.Integer +' ' Text +'::' Operator +' ' Text +'Nil' Name.Class +'\n' Text + +'a' Name +' ' Text +'++' Operator +' ' Text +'b' Name +'\n' Text + +'a' Name +' ' Text +':+' Operator +' ' Text +'b' Name +'\n' Text + +'a' Name +' ' Text +'+:' Operator +' ' Text +'b' Name +'\n' Text + +'a' Name +' ' Text +':++' Operator +' ' Text +'b' Name +'\n' Text + +'a' Name +' ' Text +'++:' Operator +' ' Text +'b' Name +'\n' Text + +'a' Name +' ' Text +'+' Operator +' ' Text +'b' Name +'\n' Text diff --git a/tests/examplefiles/scala/package.scala b/tests/examplefiles/scala/package.scala new file mode 100644 index 00000000..f27704f8 --- /dev/null +++ b/tests/examplefiles/scala/package.scala @@ -0,0 +1,3 @@ +package +package com +package com.example diff --git a/tests/examplefiles/scala/package.scala.output b/tests/examplefiles/scala/package.scala.output new file mode 100644 index 00000000..79d03b7a --- /dev/null +++ b/tests/examplefiles/scala/package.scala.output @@ -0,0 +1,15 @@ +'package' Keyword +'\n' Text + +'' Text +'package' Keyword +' ' Text +'com' Name +'\n' Text + +'package' Keyword +' ' Text +'com' Name.Namespace +'.' Punctuation +'example' Name +'\n' Text diff --git a/tests/examplefiles/scala/pattern-matching.scala b/tests/examplefiles/scala/pattern-matching.scala new file mode 100644 index 00000000..54197c81 --- /dev/null +++ b/tests/examplefiles/scala/pattern-matching.scala @@ -0,0 +1,11 @@ +def f(x: Int, y: Int) = x match { + case `y` => + case s @ Seq(_, _, _) => + case Seq(first, tail @ _*) => + case first +: tail => + case 3 | 5 | 6 => + case y: Number => y.n + case Lit(n) => n + case IsZero(u) => eval(u) == 0 + case _ => 15 +}
\ No newline at end of file diff --git a/tests/examplefiles/scala/pattern-matching.scala.output b/tests/examplefiles/scala/pattern-matching.scala.output new file mode 100644 index 00000000..0a22da0c --- /dev/null +++ b/tests/examplefiles/scala/pattern-matching.scala.output @@ -0,0 +1,142 @@ +'def' Keyword +' ' Text +'f' Name.Function +'(' Punctuation +'x' Name +':' Punctuation +' ' Text +'Int' Name.Class +',' Punctuation +' ' Text +'y' Name +':' Punctuation +' ' Text +'Int' Name.Class +')' Punctuation +' ' Text +'=' Operator +' ' Text +'x' Name +' ' Text +'match' Keyword +' ' Text +'{' Punctuation +'\n ' Text +'case' Keyword +' ' Text +'`y`' Name +' ' Text +'=>' Operator +' \n ' Text +'case' Keyword +' ' Text +'s' Name +' ' Text +'@' Operator +' ' Text +'Seq' Name.Class +'(' Punctuation +'_' Name +',' Punctuation +' ' Text +'_' Name +',' Punctuation +' ' Text +'_' Name +')' Punctuation +' ' Text +'=>' Operator +' \n ' Text +'case' Keyword +' ' Text +'Seq' Name.Class +'(' Punctuation +'first' Name +',' Punctuation +' ' Text +'tail' Name +' ' Text +'@' Operator +' ' Text +'_*' Name +')' Punctuation +' ' Text +'=>' Operator +'\n ' Text +'case' Keyword +' ' Text +'first' Name +' ' Text +'+:' Operator +' ' Text +'tail' Name +' ' Text +'=>' Operator +'\n ' Text +'case' Keyword +' ' Text +'3' Literal.Number.Integer +' ' Text +'|' Operator +' ' Text +'5' Literal.Number.Integer +' ' Text +'|' Operator +' ' Text +'6' Literal.Number.Integer +' ' Text +'=>' Operator +'\n ' Text +'case' Keyword +' ' Text +'y' Name +':' Punctuation +' ' Text +'Number' Name.Class +' ' Text +'=>' Operator +' ' Text +'y' Name +'.' Punctuation +'n' Name +'\n ' Text +'case' Keyword +' ' Text +'Lit' Name.Class +'(' Punctuation +'n' Name +')' Punctuation +' ' Text +'=>' Operator +' ' Text +'n' Name +'\n ' Text +'case' Keyword +' ' Text +'IsZero' Name.Class +'(' Punctuation +'u' Name +')' Punctuation +' ' Text +'=>' Operator +' ' Text +'eval' Name +'(' Punctuation +'u' Name +')' Punctuation +' ' Text +'==' Operator +' ' Text +'0' Literal.Number.Integer +'\n ' Text +'case' Keyword +' ' Text +'_' Name +' ' Text +'=>' Operator +' ' Text +'15' Literal.Number.Integer +'\n' Text + +'}' Punctuation +'\n' Text diff --git a/tests/examplefiles/scala/quoted.scala b/tests/examplefiles/scala/quoted.scala new file mode 100644 index 00000000..cdd3c153 --- /dev/null +++ b/tests/examplefiles/scala/quoted.scala @@ -0,0 +1,2 @@ +'{ 2 } +'[ String ]
\ No newline at end of file diff --git a/tests/examplefiles/scala/quoted.scala.output b/tests/examplefiles/scala/quoted.scala.output new file mode 100644 index 00000000..755821c1 --- /dev/null +++ b/tests/examplefiles/scala/quoted.scala.output @@ -0,0 +1,13 @@ +"'{" Punctuation +' ' Text +'2' Literal.Number.Integer +' ' Text +'}' Punctuation +'\n' Text + +"'[" Punctuation +' ' Text +'String' Name.Class +' ' Text +']' Punctuation +'\n' Text diff --git a/tests/examplefiles/scala/singleton-types.scala b/tests/examplefiles/scala/singleton-types.scala new file mode 100644 index 00000000..90923636 --- /dev/null +++ b/tests/examplefiles/scala/singleton-types.scala @@ -0,0 +1,9 @@ +val x = ??? +trait Foo[T <: x.type] +val a: x.type = ??? +val b: Foo[x.type] = ??? + +type Test[A] = Int +type MyTest = Test[1] + +val one: 1 = 1
\ No newline at end of file diff --git a/tests/examplefiles/scala/singleton-types.scala.output b/tests/examplefiles/scala/singleton-types.scala.output new file mode 100644 index 00000000..dbfe9e47 --- /dev/null +++ b/tests/examplefiles/scala/singleton-types.scala.output @@ -0,0 +1,89 @@ +'val' Keyword.Declaration +' ' Text +'x' Name +' ' Text +'=' Operator +' ' Text +'???' Operator +'\n' Text + +'trait' Keyword +' ' Text +'Foo' Name.Class +'[' Punctuation +'T' Name.Class +' ' Text +'<:' Operator +' ' Text +'x' Name +'.' Punctuation +'type' Keyword +']' Punctuation +'\n' Text + +'val' Keyword.Declaration +' ' Text +'a' Name +':' Punctuation +' ' Text +'x' Name +'.' Punctuation +'type' Keyword +' ' Text +'=' Operator +' ' Text +'???' Operator +'\n' Text + +'val' Keyword.Declaration +' ' Text +'b' Name +':' Punctuation +' ' Text +'Foo' Name.Class +'[' Punctuation +'x' Name +'.' Punctuation +'type' Keyword +']' Punctuation +' ' Text +'=' Operator +' ' Text +'???' Operator +'\n\n' Text + +'type' Keyword +' ' Text +'Test' Name.Class +'[' Punctuation +'A' Name.Class +']' Punctuation +' ' Text +'=' Operator +' ' Text +'Int' Name.Class +'\n' Text + +'type' Keyword +' ' Text +'MyTest' Name.Class +' ' Text +'=' Operator +' ' Text +'Test' Name.Class +'[' Punctuation +'1' Literal.Number.Integer +']' Punctuation +'\n\n' Text + +'val' Keyword.Declaration +' ' Text +'one' Name +':' Punctuation +' ' Text +'1' Literal.Number.Integer +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n' Text diff --git a/tests/examplefiles/scala/soft-keywords.scala b/tests/examplefiles/scala/soft-keywords.scala new file mode 100644 index 00000000..187468ad --- /dev/null +++ b/tests/examplefiles/scala/soft-keywords.scala @@ -0,0 +1,6 @@ +val open = true +val inline = true +inline xval +val x = inline + 2 +(using) +(usingSomething) diff --git a/tests/examplefiles/scala/soft-keywords.scala.output b/tests/examplefiles/scala/soft-keywords.scala.output new file mode 100644 index 00000000..e8f3c5db --- /dev/null +++ b/tests/examplefiles/scala/soft-keywords.scala.output @@ -0,0 +1,45 @@ +'val' Keyword.Declaration +' ' Text +'open' Name +' ' Text +'=' Operator +' ' Text +'true' Keyword.Constant +'\n' Text + +'val' Keyword.Declaration +' ' Text +'inline' Name +' ' Text +'=' Operator +' ' Text +'true' Keyword.Constant +'\n' Text + +'inline' Keyword +' ' Text +'xval' Name +'\n' Text + +'val' Keyword.Declaration +' ' Text +'x' Name +' ' Text +'=' Operator +' ' Text +'inline' Name +' ' Text +'+' Operator +' ' Text +'2' Literal.Number.Integer +'\n' Text + +'(' Punctuation +'using' Name +')' Punctuation +'\n' Text + +'(' Punctuation +'usingSomething' Name +')' Punctuation +'\n' Text diff --git a/tests/examplefiles/scala/storage-modifiers.scala b/tests/examplefiles/scala/storage-modifiers.scala new file mode 100644 index 00000000..083a59e1 --- /dev/null +++ b/tests/examplefiles/scala/storage-modifiers.scala @@ -0,0 +1,17 @@ +private object a {} +private[com] object b {} +private[com.example] object c {} +protected object d {} +protected[com] object e {} +protected[com.example] object f {} +synchronized {} +abstract class g {} +final val h = ??? +lazy val i = ??? +sealed trait j +implicit val k = ??? +enum m {} +inline val n = ??? +opaque type o = Unit +@volatile @transient @native +override def p = ???
\ No newline at end of file diff --git a/tests/examplefiles/scala/storage-modifiers.scala.output b/tests/examplefiles/scala/storage-modifiers.scala.output new file mode 100644 index 00000000..a013e455 --- /dev/null +++ b/tests/examplefiles/scala/storage-modifiers.scala.output @@ -0,0 +1,179 @@ +'private' Keyword +' ' Text +'object' Keyword +' ' Text +'a' Name.Class +' ' Text +'{' Punctuation +'}' Punctuation +'\n' Text + +'private' Keyword +'[' Punctuation +'com' Name +']' Punctuation +' ' Text +'object' Keyword +' ' Text +'b' Name.Class +' ' Text +'{' Punctuation +'}' Punctuation +'\n' Text + +'private' Keyword +'[' Punctuation +'com' Name +'.' Punctuation +'example' Name +']' Punctuation +' ' Text +'object' Keyword +' ' Text +'c' Name.Class +' ' Text +'{' Punctuation +'}' Punctuation +'\n' Text + +'protected' Keyword +' ' Text +'object' Keyword +' ' Text +'d' Name.Class +' ' Text +'{' Punctuation +'}' Punctuation +'\n' Text + +'protected' Keyword +'[' Punctuation +'com' Name +']' Punctuation +' ' Text +'object' Keyword +' ' Text +'e' Name.Class +' ' Text +'{' Punctuation +'}' Punctuation +'\n' Text + +'protected' Keyword +'[' Punctuation +'com' Name +'.' Punctuation +'example' Name +']' Punctuation +' ' Text +'object' Keyword +' ' Text +'f' Name.Class +' ' Text +'{' Punctuation +'}' Punctuation +'\n' Text + +'synchronized' Keyword +' ' Text +'{' Punctuation +'}' Punctuation +'\n' Text + +'abstract' Keyword +' ' Text +'class' Keyword +' ' Text +'g' Name.Class +' ' Text +'{' Punctuation +'}' Punctuation +'\n' Text + +'final' Keyword +' ' Text +'val' Keyword.Declaration +' ' Text +'h' Name +' ' Text +'=' Operator +' ' Text +'???' Operator +'\n' Text + +'lazy' Keyword +' ' Text +'val' Keyword.Declaration +' ' Text +'i' Name +' ' Text +'=' Operator +' ' Text +'???' Operator +'\n' Text + +'sealed' Keyword +' ' Text +'trait' Keyword +' ' Text +'j' Name.Class +'\n' Text + +'implicit' Keyword +' ' Text +'val' Keyword.Declaration +' ' Text +'k' Name +' ' Text +'=' Operator +' ' Text +'???' Operator +'\n' Text + +'enum' Keyword +' ' Text +'m' Name.Class +' ' Text +'{' Punctuation +'}' Punctuation +'\n' Text + +'inline' Keyword +' ' Text +'val' Keyword.Declaration +' ' Text +'n' Name +' ' Text +'=' Operator +' ' Text +'???' Operator +'\n' Text + +'opaque' Keyword +' ' Text +'type' Keyword +' ' Text +'o' Name.Class +' ' Text +'=' Operator +' ' Text +'Unit' Name.Class +'\n' Text + +'@volatile' Name.Decorator +' ' Text +'@transient' Name.Decorator +' ' Text +'@native' Name.Decorator +'\n' Text + +'override' Keyword +' ' Text +'def' Keyword +' ' Text +'p' Name.Function +' ' Text +'=' Operator +' ' Text +'???' Operator +'\n' Text diff --git a/tests/examplefiles/scala/symbols.scala b/tests/examplefiles/scala/symbols.scala new file mode 100644 index 00000000..950a972f --- /dev/null +++ b/tests/examplefiles/scala/symbols.scala @@ -0,0 +1,14 @@ +// Symbols: +'* //test +'* +'symbol_* +'symbol1 //' +'ξφδ +'φδφ0 +'δφξφξ_+- +'*** + +// Not (just) symbols: +'symbol* +'**_x //' +'x'
\ No newline at end of file diff --git a/tests/examplefiles/scala/symbols.scala.output b/tests/examplefiles/scala/symbols.scala.output new file mode 100644 index 00000000..2a27f6fa --- /dev/null +++ b/tests/examplefiles/scala/symbols.scala.output @@ -0,0 +1,41 @@ +'// Symbols:\n' Comment.Single + +"'*" Literal.String.Symbol +' ' Text +'//test\n' Comment.Single + +"'*" Literal.String.Symbol +'\n' Text + +"'symbol_*" Literal.String.Symbol +'\n' Text + +"'symbol1" Literal.String.Symbol +' ' Text +"//'\n" Comment.Single + +"'ξφδ" Literal.String.Symbol +'\n' Text + +"'φδφ0" Literal.String.Symbol +'\n' Text + +"'δφξφξ_+-" Literal.String.Symbol +'\n' Text + +"'***" Literal.String.Symbol +'\n\n' Text + +'// Not (just) symbols:\n' Comment.Single + +"'symbol" Literal.String.Symbol +'*' Operator +'\n' Text + +"'**" Literal.String.Symbol +'_x' Name +' ' Text +"//'\n" Comment.Single + +"'x'" Literal.String.Char +'\n' Text diff --git a/tests/examplefiles/scala/type-operators.scala b/tests/examplefiles/scala/type-operators.scala new file mode 100644 index 00000000..d9337fae --- /dev/null +++ b/tests/examplefiles/scala/type-operators.scala @@ -0,0 +1,6 @@ +Type[A with "user provided string" with B] +def help(id: UserName | Password) = ??? +val either: Password | UserName = ??? +val both: Object & Product = ??? +<% =:= <:< <%< >: <: +[X, Y] =>> Map[Y, X]
\ No newline at end of file diff --git a/tests/examplefiles/scala/type-operators.scala.output b/tests/examplefiles/scala/type-operators.scala.output new file mode 100644 index 00000000..ff17f80b --- /dev/null +++ b/tests/examplefiles/scala/type-operators.scala.output @@ -0,0 +1,95 @@ +'Type' Name.Class +'[' Punctuation +'A' Name.Class +' ' Text +'with' Keyword +' ' Text +'"user provided string"' Literal.String +' ' Text +'with' Keyword +' ' Text +'B' Name.Class +']' Punctuation +'\n' Text + +'def' Keyword +' ' Text +'help' Name.Function +'(' Punctuation +'id' Name +':' Punctuation +' ' Text +'UserName' Name.Class +' ' Text +'|' Operator +' ' Text +'Password' Name.Class +')' Punctuation +' ' Text +'=' Operator +' ' Text +'???' Operator +'\n' Text + +'val' Keyword.Declaration +' ' Text +'either' Name +':' Punctuation +' ' Text +'Password' Name.Class +' ' Text +'|' Operator +' ' Text +'UserName' Name.Class +' ' Text +'=' Operator +' ' Text +'???' Operator +'\n' Text + +'val' Keyword.Declaration +' ' Text +'both' Name +':' Punctuation +' ' Text +'Object' Name.Class +' ' Text +'&' Name +' ' Text +'Product' Name.Class +' ' Text +'=' Operator +' ' Text +'???' Operator +'\n' Text + +'<%' Operator +' ' Text +'=:=' Operator +' ' Text +'<:<' Operator +' ' Text +'<%<' Operator +' ' Text +'>:' Operator +' ' Text +'<:' Operator +'\n' Text + +'[' Punctuation +'X' Name.Class +',' Punctuation +' ' Text +'Y' Name.Class +']' Punctuation +' ' Text +'=>>' Operator +' ' Text +'Map' Name.Class +'[' Punctuation +'Y' Name.Class +',' Punctuation +' ' Text +'X' Name.Class +']' Punctuation +'\n' Text diff --git a/tests/examplefiles/scala/using.scala b/tests/examplefiles/scala/using.scala new file mode 100644 index 00000000..e40d49f3 --- /dev/null +++ b/tests/examplefiles/scala/using.scala @@ -0,0 +1,9 @@ +def f(using x: Int): Unit = () +f(using 2) +f(using .2) +class A(using x: Int) +new A(using 3) +f(using ()) +f(using {}) +f(using ' ') +f(using "") diff --git a/tests/examplefiles/scala/using.scala.output b/tests/examplefiles/scala/using.scala.output new file mode 100644 index 00000000..7e87d777 --- /dev/null +++ b/tests/examplefiles/scala/using.scala.output @@ -0,0 +1,93 @@ +'def' Keyword +' ' Text +'f' Name.Function +'(' Punctuation +'using' Keyword +' ' Text +'x' Name +':' Punctuation +' ' Text +'Int' Name.Class +')' Punctuation +':' Punctuation +' ' Text +'Unit' Name.Class +' ' Text +'=' Operator +' ' Text +'(' Punctuation +')' Punctuation +'\n' Text + +'f' Name +'(' Punctuation +'using' Keyword +' ' Text +'2' Literal.Number.Integer +')' Punctuation +'\n' Text + +'f' Name +'(' Punctuation +'using' Keyword +' ' Text +'.2' Literal.Number.Float +')' Punctuation +'\n' Text + +'class' Keyword +' ' Text +'A' Name.Class +'(' Punctuation +'using' Keyword +' ' Text +'x' Name +':' Punctuation +' ' Text +'Int' Name.Class +')' Punctuation +'\n' Text + +'new' Keyword +' ' Text +'A' Name.Class +'(' Punctuation +'using' Keyword +' ' Text +'3' Literal.Number.Integer +')' Punctuation +'\n' Text + +'f' Name +'(' Punctuation +'using' Keyword +' ' Text +'(' Punctuation +')' Punctuation +')' Punctuation +'\n' Text + +'f' Name +'(' Punctuation +'using' Keyword +' ' Text +'{' Punctuation +'}' Punctuation +')' Punctuation +'\n' Text + +'f' Name +'(' Punctuation +'using' Keyword +' ' Text +"' '" Literal.String.Char +')' Punctuation +'\n' Text + +'f' Name +'(' Punctuation +'using' Keyword +' ' Text +'""' Literal.String +')' Punctuation +'\n' Text diff --git a/tests/examplefiles/scaml/test.scaml.output b/tests/examplefiles/scaml/test.scaml.output index 52b83c57..e30a34d9 100644 --- a/tests/examplefiles/scaml/test.scaml.output +++ b/tests/examplefiles/scaml/test.scaml.output @@ -2,11 +2,11 @@ '-@ ' Punctuation 'import' Keyword ' ' Text -'val' Keyword +'val' Keyword.Declaration ' ' Text 'city' Name -':' Keyword -'String' Keyword.Type +':' Punctuation +'String' Name.Class ' ' Text '=' Operator ' ' Text @@ -16,11 +16,11 @@ '' Text '-' Punctuation ' ' Text -'val' Keyword +'val' Keyword.Declaration ' ' Text 'name' Name -':' Keyword -'String' Keyword.Type +':' Punctuation +'String' Name.Class ' ' Text '=' Operator ' ' Text @@ -56,7 +56,7 @@ ' ' Text 'for' Keyword ' ' Text -'(' Operator +'(' Punctuation ' ' Text 'i' Name ' ' Text @@ -68,7 +68,7 @@ ' ' Text '10' Literal.Number.Integer ' ' Text -')' Operator +')' Punctuation '\n' Text ' ' Text diff --git a/tests/snippets/scala/test_colon_colon_function_name.txt b/tests/snippets/scala/test_colon_colon_function_name.txt new file mode 100644 index 00000000..eeebed2e --- /dev/null +++ b/tests/snippets/scala/test_colon_colon_function_name.txt @@ -0,0 +1,33 @@ +---input--- +def ::(xs: List[T]): List[T] = ::(x, xs) + +---tokens--- +'def' Keyword +' ' Text +'::' Name.Function +'(' Punctuation +'xs' Name +':' Punctuation +' ' Text +'List' Name.Class +'[' Punctuation +'T' Name.Class +']' Punctuation +')' Punctuation +':' Punctuation +' ' Text +'List' Name.Class +'[' Punctuation +'T' Name.Class +']' Punctuation +' ' Text +'=' Operator +' ' Text +'::' Name +'(' Punctuation +'x' Name +',' Punctuation +' ' Text +'xs' Name +')' Punctuation +'\n' Text diff --git a/tests/snippets/scala/test_default_parameter.txt b/tests/snippets/scala/test_default_parameter.txt new file mode 100644 index 00000000..a82e5a06 --- /dev/null +++ b/tests/snippets/scala/test_default_parameter.txt @@ -0,0 +1,37 @@ +---input--- +def f(using y: Char = if true then 'a' else 2): Int = ??? + +---tokens--- +'def' Keyword +' ' Text +'f' Name.Function +'(' Punctuation +'using' Keyword +' ' Text +'y' Name +':' Punctuation +' ' Text +'Char' Name.Class +' ' Text +'=' Operator +' ' Text +'if' Keyword +' ' Text +'true' Keyword.Constant +' ' Text +'then' Keyword +' ' Text +"'a'" Literal.String.Char +' ' Text +'else' Keyword +' ' Text +'2' Literal.Number.Integer +')' Punctuation +':' Punctuation +' ' Text +'Int' Name.Class +' ' Text +'=' Operator +' ' Text +'???' Operator +'\n' Text diff --git a/tests/snippets/scala/test_end_val.txt b/tests/snippets/scala/test_end_val.txt new file mode 100644 index 00000000..112cfafa --- /dev/null +++ b/tests/snippets/scala/test_end_val.txt @@ -0,0 +1,8 @@ +---input--- +end val + +---tokens--- +'end' Keyword +' ' Text +'val' Keyword +'\n' Text diff --git a/tests/snippets/scala/test_end_valx.txt b/tests/snippets/scala/test_end_valx.txt new file mode 100644 index 00000000..e72c4041 --- /dev/null +++ b/tests/snippets/scala/test_end_valx.txt @@ -0,0 +1,8 @@ +---input--- +end valx + +---tokens--- +'end' Keyword +' ' Text +'valx' Name.Namespace +'\n' Text diff --git a/tests/snippets/scala/test_float_with_exponents.txt b/tests/snippets/scala/test_float_with_exponents.txt new file mode 100644 index 00000000..9a702431 --- /dev/null +++ b/tests/snippets/scala/test_float_with_exponents.txt @@ -0,0 +1,12 @@ +---input--- +.1e12 .1e+34 .1e-56 .1e12f + +---tokens--- +'.1e12' Literal.Number.Float +' ' Text +'.1e+34' Literal.Number.Float +' ' Text +'.1e-56' Literal.Number.Float +' ' Text +'.1e12f' Literal.Number.Float +'\n' Text diff --git a/tests/snippets/scala/test_function_operator_name.txt b/tests/snippets/scala/test_function_operator_name.txt new file mode 100644 index 00000000..a1823f03 --- /dev/null +++ b/tests/snippets/scala/test_function_operator_name.txt @@ -0,0 +1,18 @@ +---input--- +def < (y: String): Boolean + +---tokens--- +'def' Keyword +' ' Text +'<' Name.Function +' ' Text +'(' Punctuation +'y' Name +':' Punctuation +' ' Text +'String' Name.Class +')' Punctuation +':' Punctuation +' ' Text +'Boolean' Name.Class +'\n' Text diff --git a/tests/snippets/scala/test_import_path.txt b/tests/snippets/scala/test_import_path.txt new file mode 100644 index 00000000..fc8e5a2c --- /dev/null +++ b/tests/snippets/scala/test_import_path.txt @@ -0,0 +1,12 @@ +---input--- +import a.b.c + +---tokens--- +'import' Keyword +' ' Text +'a' Name.Namespace +'.' Punctuation +'b' Name.Namespace +'.' Punctuation +'c' Name +'\n' Text diff --git a/tests/snippets/scala/test_invalid_symbol_and_invalid_char.txt b/tests/snippets/scala/test_invalid_symbol_and_invalid_char.txt new file mode 100644 index 00000000..9af24e53 --- /dev/null +++ b/tests/snippets/scala/test_invalid_symbol_and_invalid_char.txt @@ -0,0 +1,8 @@ +---input--- +'1 //' + +---tokens--- +"'" Error +'1' Literal.Number.Integer +' ' Text +"//'\n" Comment.Single diff --git a/tests/snippets/scala/test_open_soft_keyword.txt b/tests/snippets/scala/test_open_soft_keyword.txt new file mode 100644 index 00000000..800880ee --- /dev/null +++ b/tests/snippets/scala/test_open_soft_keyword.txt @@ -0,0 +1,12 @@ +---input--- +val open = true + +---tokens--- +'val' Keyword.Declaration +' ' Text +'open' Name +' ' Text +'=' Operator +' ' Text +'true' Keyword.Constant +'\n' Text diff --git a/tests/snippets/scala/test_package_name.txt b/tests/snippets/scala/test_package_name.txt new file mode 100644 index 00000000..6b1f3482 --- /dev/null +++ b/tests/snippets/scala/test_package_name.txt @@ -0,0 +1,11 @@ +---input--- +package p1.p2: + +---tokens--- +'package' Keyword +' ' Text +'p1' Name.Namespace +'.' Punctuation +'p2' Name +':' Punctuation +'\n' Text diff --git a/tests/snippets/scala/test_prepend_operator.txt b/tests/snippets/scala/test_prepend_operator.txt new file mode 100644 index 00000000..db850479 --- /dev/null +++ b/tests/snippets/scala/test_prepend_operator.txt @@ -0,0 +1,10 @@ +---input--- +a +: b + +---tokens--- +'a' Name +' ' Text +'+:' Operator +' ' Text +'b' Name +'\n' Text diff --git a/tests/snippets/scala/test_qualified_name.txt b/tests/snippets/scala/test_qualified_name.txt new file mode 100644 index 00000000..8a1f06ff --- /dev/null +++ b/tests/snippets/scala/test_qualified_name.txt @@ -0,0 +1,10 @@ +---input--- +a.b.c + +---tokens--- +'a' Name +'.' Punctuation +'b' Name +'.' Punctuation +'c' Name +'\n' Text diff --git a/tests/snippets/scala/test_qualified_name_class.txt b/tests/snippets/scala/test_qualified_name_class.txt new file mode 100644 index 00000000..b9d47c94 --- /dev/null +++ b/tests/snippets/scala/test_qualified_name_class.txt @@ -0,0 +1,10 @@ +---input--- +a.b.C + +---tokens--- +'a' Name +'.' Punctuation +'b' Name +'.' Punctuation +'C' Name.Class +'\n' Text diff --git a/tests/snippets/scala/test_script_header.txt b/tests/snippets/scala/test_script_header.txt new file mode 100644 index 00000000..f15ded80 --- /dev/null +++ b/tests/snippets/scala/test_script_header.txt @@ -0,0 +1,6 @@ +---input--- +#!/usr/bin/scala + +---tokens--- +'#!/usr/bin/scala' Comment.Hashbang +'\n' Text diff --git a/tests/snippets/scala/test_symbol_followed_by_op.txt b/tests/snippets/scala/test_symbol_followed_by_op.txt new file mode 100644 index 00000000..5d8a14f5 --- /dev/null +++ b/tests/snippets/scala/test_symbol_followed_by_op.txt @@ -0,0 +1,7 @@ +---input--- +symbol* + +---tokens--- +'symbol' Name +'*' Operator +'\n' Text diff --git a/tests/snippets/scala/test_symbol_name_ending_with_star.txt b/tests/snippets/scala/test_symbol_name_ending_with_star.txt new file mode 100644 index 00000000..bb1d987f --- /dev/null +++ b/tests/snippets/scala/test_symbol_name_ending_with_star.txt @@ -0,0 +1,6 @@ +---input--- +symbol_* + +---tokens--- +'symbol_*' Name +'\n' Text diff --git a/tests/snippets/scala/test_underscore_name.txt b/tests/snippets/scala/test_underscore_name.txt new file mode 100644 index 00000000..f27754fd --- /dev/null +++ b/tests/snippets/scala/test_underscore_name.txt @@ -0,0 +1,12 @@ +---input--- +val head = _head + +---tokens--- +'val' Keyword.Declaration +' ' Text +'head' Name +' ' Text +'=' Operator +' ' Text +'_head' Name +'\n' Text |