-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathalan.js
102 lines (101 loc) · 4.02 KB
/
alan.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
Language: Alan
Author: Tristano Ajmone <[email protected]>
Description: Alan Interactive Fiction (www.alanif.se)
Category: misc
License: MIT License
*/
// ====================================
// v1.0.2 (2021/04/10) | Alan v3.0beta7
// ====================================
// https://github.com/highlightjs/highlightjs-alan-if
// -----------------------------------------------------------------------------
// NOTE: This syntax required some tweaking in relevance of keywords and modes,
// and defining some illegals to prevent autodetection errors in Mocha
// tests. The syntaxes it tended to prevail where: axapta, inform7 and diff.
// Inform7 (which is also an Interactive Fiction language) was the syntax
// that tended to create more autodetection conflicts, as it's similar and
// it doesn't define any explicit relevance values.
// -----------------------------------------------------------------------------
function(hljs) {
var STRINGS = {
className: 'string',
begin: '"', end: '"',
contains: [{begin: '""'}], // Escaped double quotes
relevance: 0
};
var QUOTED_IDS = {
/*
We need this just to prevent false-positive keywords matches inside
quoted identifiers...
*/
begin: "'.*?'(?!'')",
relevance: 0
};
var ALAN_KEYWORDS = {
// Relevance added to selected keywords which are Alan specific.
keyword:
'add after an and are article|10 at attributes before between by can ' +
'cancel character characters check container|10 contains count current ' +
'decrease definite depend depending describe description directly do does ' +
'each else elsif empty end entered event every exclude exit extract first ' +
'for form from has header here if import in include increase indefinite ' +
'indirectly initialize into is isa|10 it last limits list locate look make ' +
'max mentioned|10 message meta min name near nearby negative no not of off ' +
'on only opaque option options or play prompt pronoun|10 quit random ' +
'restart restore save say schedule score script set show start step stop ' +
'strip style sum synonyms|10 syntax system taking the then this to ' +
'transcript transitively until use verb|10 visits wait when where with ' +
'word words',
built_in:
'actor entity integer literal location|10 object string thing'
};
var ALAN_KEYWORDS_ALT = {
/*
We'll also capture as keywords the following symbols (which in Alan are
never used as operators):
=> (shorthand for 'THEN' in rules)
. (dot terminator)
: (alterantive for 'OF' in attributes chains)
*/
className: 'keyword',
begin: '(\\=>|\\.|:)',
relevance: 0
};
var INTEGERS = {
// There only integer numerals in Alan.
className: 'number',
begin: '(\\d+)\\b',
relevance: 0
};
return {
aliases: ['i'],
case_insensitive: true,
keywords: ALAN_KEYWORDS,
illegal:
// Needed to prevent autodetection errors in Mocha tests:
'\\/[\\/|\\*]' + // C style comments: // /*
'|\\[' + // Inform7 comments: [
'|\\#', // hash comments: #
contains: [
hljs.COMMENT('--', '$', {relevance: 10}),
ALAN_KEYWORDS_ALT,
INTEGERS,
QUOTED_IDS,
STRINGS
]
};
}
/*==============================================================================
CHANGELOG
================================================================================
v1.0.2 (2021/04/10) | Alan v3.0beta7 | HLJS 10.7.2
* Renamed repository due to name clash with other language:
https://github.com/highlightjs/highlightjs-alan-if
v1.0.1 (2018/10/20) | Alan v3.0beta6 | HLJS 9.13.1
* First release on Highlight.js project:
https://github.com/highlightjs/highlightjs-alan
v1.0.0 (2018/09/30) | Alan v3.0beta6 | HLJS 9.12.0
* First public release on the Alan-Docs project:
https://github.com/alan-if/alan-docs
------------------------------------------------------------------------------*/