|
| 1 | +/** |
| 2 | + * Prism language definition for Aiken |
| 3 | + * Converted from aiken.tmLanguage.json (https://github.com/aiken-lang/site/blob/main/aiken.tmLanguage.json) |
| 4 | + */ |
| 5 | + |
1 | 6 | Prism.languages.aiken = { |
2 | | - 'string': /".*"/, |
3 | | - 'comment': /\/\/.*/, |
4 | | - 'number': /(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:E[+-]?\d+)?/i, |
5 | | - 'boolean': /\btrue|false\b/, |
6 | | - 'class-name': /\b[A-Z]\w*\b/, |
7 | | - 'punctuation': /\./, |
8 | | - 'function-definition': { |
9 | | - pattern: /\b(fn|test\s)[^(]*/, |
10 | | - alias: 'function', |
11 | | - lookbehind: true |
12 | | - }, |
13 | | - 'variable': { |
14 | | - pattern: /\b(let\s)[^=]*/, |
15 | | - lookbehind: true |
16 | | - }, |
17 | | - 'keyword': /\b(if|else|fn|let|when|is|use|pub|type|opaque|const|todo|assert|check|test)\b/, |
18 | | - 'operator': [ |
19 | | - /&&|\\|\|/, |
20 | | - /\+|\-|\/|\*|%/, |
21 | | - /<=|>=|==|!=|<|>/, |
22 | | - /\.\./, |
23 | | - /\|>/, |
24 | | - /->/ |
25 | | - ] |
| 7 | + // Comments (single-line only) |
| 8 | + 'comment': { |
| 9 | + pattern: /\/\/.*/, |
| 10 | + greedy: true |
| 11 | + }, |
| 12 | + |
| 13 | + // Strings (double-quoted with escape sequences) |
| 14 | + 'string': { |
| 15 | + pattern: /"(?:\\.|[^"\\])*"/, |
| 16 | + greedy: true |
| 17 | + }, |
| 18 | + |
| 19 | + // Booleans (must come before class-name to take precedence) |
| 20 | + 'boolean': /\b(?:True|False)\b/, |
| 21 | + |
| 22 | + // Numbers |
| 23 | + 'number': [ |
| 24 | + // Binary |
| 25 | + /\b0b[01]+\b/, |
| 26 | + // Octal |
| 27 | + /\b0o[0-7]+\b/, |
| 28 | + // Hexadecimal |
| 29 | + /\b0x[\da-fA-F]+\b/, |
| 30 | + // Decimal (with optional decimal point) |
| 31 | + /\b\d[\d_]*(?:\.\d*)?\b/ |
| 32 | + ], |
| 33 | + |
| 34 | + // Keywords |
| 35 | + 'keyword': /\b(?:if|else|when|is|fn|use|let|pub|type|opaque|const|todo|expect|test|bench|trace|fail|validator|and|or|as|via)\b/, |
| 36 | + |
| 37 | + // Type names (PascalCase identifiers) |
| 38 | + 'class-name': /\b[A-Z][a-zA-Z0-9_]*\b/, |
| 39 | + |
| 40 | + // Function calls |
| 41 | + 'function': /\b[a-z][a-zA-Z0-9_]*(?=\s*\()/, |
| 42 | + |
| 43 | + // Namespace/module prefix (e.g., `module:`) |
| 44 | + 'namespace': /\b[a-z][a-zA-Z0-9_]*(?=:)/, |
| 45 | + |
| 46 | + // Operators |
| 47 | + 'operator': [ |
| 48 | + // Arrow operators |
| 49 | + /->|<-/, |
| 50 | + // Pipe operator |
| 51 | + /\|>/, |
| 52 | + // Spread/splat |
| 53 | + /\.\./, |
| 54 | + // Comparison |
| 55 | + /<=|>=|==|!=|<|>/, |
| 56 | + // Logical |
| 57 | + /&&|\|\|/, |
| 58 | + // Arithmetic |
| 59 | + /[+\-*/%]/, |
| 60 | + // Assignment |
| 61 | + /=/, |
| 62 | + // Pipe/union |
| 63 | + /\|/ |
| 64 | + ], |
| 65 | + |
| 66 | + // Punctuation |
| 67 | + 'punctuation': /[{}[\](),.:]/ |
26 | 68 | }; |
| 69 | + |
| 70 | +// Aliases |
| 71 | +Prism.languages.ak = Prism.languages.aiken; |
0 commit comments