Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ module.exports = {

// Additional Language Syntax Highlighting
prism: {
//theme: prismThemes.github, // uncomment for light mode in code boxes
theme: prismThemes.github,
darkTheme: prismThemes.dracula,
additionalLanguages: ['csharp', 'php', 'bash', 'json', 'typescript', 'yaml', 'diff'],
},
Expand Down
93 changes: 69 additions & 24 deletions src/aiken.prism.lang.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,71 @@
/**
* Prism language definition for Aiken
* Converted from aiken.tmLanguage.json (https://github.com/aiken-lang/site/blob/main/aiken.tmLanguage.json)
*/

Prism.languages.aiken = {
'string': /".*"/,
'comment': /\/\/.*/,
'number': /(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:E[+-]?\d+)?/i,
'boolean': /\btrue|false\b/,
'class-name': /\b[A-Z]\w*\b/,
'punctuation': /\./,
'function-definition': {
pattern: /\b(fn|test\s)[^(]*/,
alias: 'function',
lookbehind: true
},
'variable': {
pattern: /\b(let\s)[^=]*/,
lookbehind: true
},
'keyword': /\b(if|else|fn|let|when|is|use|pub|type|opaque|const|todo|assert|check|test)\b/,
'operator': [
/&&|\\|\|/,
/\+|\-|\/|\*|%/,
/<=|>=|==|!=|<|>/,
/\.\./,
/\|>/,
/->/
]
// Comments (single-line only)
'comment': {
pattern: /\/\/.*/,
greedy: true
},

// Strings (double-quoted with escape sequences)
'string': {
pattern: /"(?:\\.|[^"\\])*"/,
greedy: true
},

// Booleans (must come before class-name to take precedence)
'boolean': /\b(?:True|False)\b/,

// Numbers
'number': [
// Binary
/\b0b[01]+\b/,
// Octal
/\b0o[0-7]+\b/,
// Hexadecimal
/\b0x[\da-fA-F]+\b/,
// Decimal (with optional decimal point)
/\b\d[\d_]*(?:\.\d*)?\b/
Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The decimal number pattern allows trailing decimal points without digits (e.g., '123.'), which may not be valid Aiken syntax. Consider changing the pattern to /\b\d[\d_]*(?:\.\d+)?\b/ to require at least one digit after the decimal point.

Suggested change
/\b\d[\d_]*(?:\.\d*)?\b/
/\b\d[\d_]*(?:\.\d+)?\b/

Copilot uses AI. Check for mistakes.
],

// Keywords
'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/,

// Type names (PascalCase identifiers)
'class-name': /\b[A-Z][a-zA-Z0-9_]*\b/,

// Function calls
'function': /\b[a-z][a-zA-Z0-9_]*(?=\s*\()/,
Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The positive lookahead (?=\s*\() may not match function calls without whitespace before the parenthesis. Consider using (?=\() instead to match function() as well as function ().

Suggested change
'function': /\b[a-z][a-zA-Z0-9_]*(?=\s*\()/,
'function': /\b[a-z][a-zA-Z0-9_]*(?=\()/,

Copilot uses AI. Check for mistakes.

// Namespace/module prefix (e.g., `module:`)
'namespace': /\b[a-z][a-zA-Z0-9_]*(?=:)/,

// Operators
'operator': [
// Arrow operators
/->|<-/,
// Pipe operator
/\|>/,
// Spread/splat
/\.\./,
// Comparison
/<=|>=|==|!=|<|>/,
// Logical
/&&|\|\|/,
// Arithmetic
/[+\-*/%]/,
// Assignment
/=/,
// Pipe/union
/\|/
],

// Punctuation
'punctuation': /[{}[\](),.:]/
};

// Aliases
Prism.languages.ak = Prism.languages.aiken;
Loading