Commits

Rob Hoelz committed aa20db8 Merge

Merged birkenfeld/pygments-main into default

  • Participants
  • Parent commits 3c24ba9, 1df5916

Comments (0)

Files changed (2)

pygments/lexers/jvm.py

             (r'[^\S\n]+', Text),
             (r'//.*?\n', Comment.Single),
             (r'/\*.*?\*/', Comment.Multiline),
-            (r'(variable|shared|abstract|doc|by|formal|actual)',
+            (r'(variable|shared|abstract|doc|by|formal|actual|late|native)',
              Name.Decorator),
             (r'(break|case|catch|continue|default|else|finally|for|in|'
-             r'variable|if|return|switch|this|throw|try|while|is|exists|'
-             r'nonempty|then|outer)\b', Keyword),
+             r'variable|if|return|switch|this|throw|try|while|is|exists|dynamic|'
+             r'nonempty|then|outer|assert)\b', Keyword),
             (r'(abstracts|extends|satisfies|adapts|'
              r'super|given|of|out|assign|'
              r'transient|volatile)\b', Keyword.Declaration),
              Keyword.Type),
             (r'(package)(\s+)', bygroups(Keyword.Namespace, Text)),
             (r'(true|false|null)\b', Keyword.Constant),
-            (r'(class|interface|object)(\s+)',
+            (r'(class|interface|object|alias)(\s+)',
              bygroups(Keyword.Declaration, Text), 'class'),
             (r'(import)(\s+)', bygroups(Keyword.Namespace, Text), 'import'),
             (r'"(\\\\|\\"|[^"])*"', String),
-            (r"'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'", String.Quoted),
-            (r"`\\.`|`[^\\]`|`\\u[0-9a-fA-F]{4}`", String.Char),
-            (r'(\.)([a-zA-Z_][a-zA-Z0-9_]*)',
+            (r"'\\.'|'[^\\]'|'\\\{#[0-9a-fA-F]{4}\}'", String.Char),
+            (r'".*``.*``.*"', String.Interpol),
+            (r'(\.)([a-z_][a-zA-Z0-9_]*)',
              bygroups(Operator, Name.Attribute)),
             (r'[a-zA-Z_][a-zA-Z0-9_]*:', Name.Label),
-            (r'[a-zA-Z_\$][a-zA-Z0-9_]*', Name),
+            (r'[a-zA-Z_][a-zA-Z0-9_]*', Name),
             (r'[~\^\*!%&\[\]\(\)\{\}<>\|+=:;,./?-]', Operator),
             (r'\d{1,3}(_\d{3})+\.\d{1,3}(_\d{3})+[kMGTPmunpf]?', Number.Float),
             (r'\d{1,3}(_\d{3})+\.[0-9]+([eE][+-]?[0-9]+)?[kMGTPmunpf]?',
             (r'[0-9][0-9]*\.\d{1,3}(_\d{3})+[kMGTPmunpf]?', Number.Float),
             (r'[0-9][0-9]*\.[0-9]+([eE][+-]?[0-9]+)?[kMGTPmunpf]?',
              Number.Float),
-            (r'0x[0-9a-fA-F]+', Number.Hex),
+            (r'#([0-9a-fA-F]{4})(_[0-9a-fA-F]{4})+', Number.Hex),
+            (r'#[0-9a-fA-F]+', Number.Hex),
+            (r'\$([01]{4})(_[01]{4})+', Number.Integer),
+            (r'\$[01]+', Number.Integer),
             (r'\d{1,3}(_\d{3})+[kMGTP]?', Number.Integer),
             (r'[0-9]+[kMGTP]?', Number.Integer),
             (r'\n', Text)
         ],
         'class': [
-            (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop')
+            (r'[A-Za-z_][a-zA-Z0-9_]*', Name.Class, '#pop')
         ],
         'import': [
-            (r'[a-zA-Z0-9_.]+\w+ \{([a-zA-Z,]+|\.\.\.)\}',
+            (r'[a-z][a-zA-Z0-9_.]*',
              Name.Namespace, '#pop')
         ],
     }

tests/examplefiles/example.ceylon

+import ceylon.language { parseInteger }
+
 doc "A top-level function,
      with multi-line documentation."
-void topLevel(String? a, Integer b=5, String... seqs) {
+void topLevel(String? a, Integer b=5, String* seqs) {
     function nested(String s) {
         print(s[1..2]);
         return true;
     }
-    for (s in seqs.filter((String x) x.size > 2)) {
+    for (s in seqs.filter((String x) => x.size > 2)) {
         nested(s);
     }
-    value uppers = seqs.sequence[].uppercased;
-    String|Nothing z = a;
-    Sequence<Integer> ints = { 1, 2, 3, 4, 5 };
+    value uppers = seqs.map((String x) {
+        return x.uppercased;
+    });
+    String|Null z = a;
+    {Integer+} ints = { 1, 2, 3, 4, 5 };
+    value numbers = [ 1, #ffff, #ffff_ffff, $10101010, $1010_1010_1010_1010,
+        123_456_789 ];
+    value chars = ['a', '\{#ffff}' ];
 }
 
-shared class Example<Element>(name, element) satisfies Comparable<Example<Element>>
+shared class Example_1<Element>(name, element) satisfies Comparable<Example_1<Element>>
         given Element satisfies Comparable<Element> {
     shared String name;
     shared Element element;
+    shared [Integer,String] tuple = [1, "2"];
+    shared late String lastName;
+    variable Integer cnt = 0;
 
-    shared actual Comparison compare(Example<Element> other) {
+    shared Integer count => cnt;
+    assign count {
+        assert(count >= cnt);
+        cnt = count;
+    }
+
+    shared actual Comparison compare(Example_1<Element> other) {
         return element <=> other.element;
     }
 
     shared actual String string {
-        return "Example with " + element.string;
+        return "Example with ``element.string``";
     }
 }
 
-Example<Integer> instance = Example {
-    name = "Named args call";
+Example_1<Integer> instance = Example_1 {
     element = 5;
+    name = "Named args call \{#0060}";
 };
+
+object example1 extends Example_1<Integer>("object", 5) {
+}