@rip-lang/print 1.1.49 → 1.1.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/hljs-rip.js +61 -11
  2. package/package.json +2 -2
package/hljs-rip.js CHANGED
@@ -1,27 +1,51 @@
1
1
  // highlight.js language definition for Rip
2
- // Derived from the Monarch grammar in docs/index.html
3
2
 
4
3
  export default function(hljs) {
5
4
  const KEYWORDS = [
6
- 'if', 'else', 'unless', 'then', 'switch', 'when', 'for', 'while', 'until',
7
- 'loop', 'do', 'return', 'break', 'continue', 'throw', 'try', 'catch', 'finally',
8
- 'yield', 'await', 'import', 'export', 'from', 'default', 'delete', 'typeof',
9
- 'instanceof', 'new', 'super', 'debugger', 'use', 'own', 'extends', 'in', 'of',
10
- 'by', 'as', 'class', 'def', 'enum', 'interface', 'component', 'render',
5
+ // Control flow
6
+ 'if', 'else', 'unless', 'then', 'switch', 'when',
7
+ 'for', 'while', 'until', 'loop', 'do',
8
+ 'return', 'break', 'continue', 'throw',
9
+ 'try', 'catch', 'finally',
10
+ 'yield', 'await',
11
+ // Modules
12
+ 'import', 'export', 'from', 'default',
13
+ // Operators as keywords
14
+ 'delete', 'typeof', 'instanceof', 'new', 'super',
11
15
  'and', 'or', 'not', 'is', 'isnt',
16
+ // Declarations
17
+ 'class', 'def', 'enum', 'interface', 'extends', 'own',
18
+ // Iteration
19
+ 'in', 'of', 'by', 'as',
20
+ // Component system
21
+ 'component', 'render', 'slot', 'offer', 'accept',
22
+ // Other
23
+ 'use', 'debugger', 'it',
12
24
  ];
13
25
 
14
26
  const LITERALS = [
15
27
  'true', 'false', 'yes', 'no', 'on', 'off',
16
- 'null', 'undefined', 'NaN', 'Infinity',
28
+ 'null', 'undefined', 'NaN', 'Infinity', 'this',
17
29
  ];
18
30
 
19
31
  const BUILT_INS = [
20
32
  'console', 'process', 'require', 'module', 'exports',
21
33
  'setTimeout', 'setInterval', 'clearTimeout', 'clearInterval',
34
+ 'requestAnimationFrame', 'cancelAnimationFrame',
22
35
  'Promise', 'Array', 'Object', 'String', 'Number', 'Boolean',
23
- 'Math', 'Date', 'RegExp', 'Error', 'JSON', 'Map', 'Set',
24
- 'Symbol', 'Buffer', 'Bun',
36
+ 'Math', 'Date', 'RegExp', 'Error', 'TypeError', 'RangeError',
37
+ 'JSON', 'Map', 'Set', 'WeakMap', 'WeakSet',
38
+ 'Symbol', 'Proxy', 'Reflect',
39
+ 'Buffer', 'Bun',
40
+ 'document', 'window', 'globalThis', 'navigator',
41
+ 'fetch', 'URL', 'URLSearchParams', 'FormData',
42
+ 'Event', 'CustomEvent', 'EventSource',
43
+ 'HTMLElement', 'Node', 'NodeList', 'Element',
44
+ 'DocumentFragment', 'MutationObserver', 'ResizeObserver',
45
+ 'IntersectionObserver',
46
+ // Rip stdlib
47
+ 'p', 'pp', 'abort', 'assert', 'exit', 'kind', 'noop',
48
+ 'raise', 'rand', 'sleep', 'todo', 'warn', 'zip',
25
49
  ];
26
50
 
27
51
  const INTERPOLATION = {
@@ -90,6 +114,11 @@ export default function(hljs) {
90
114
  begin: /@[a-zA-Z_$][\w$]*/,
91
115
  };
92
116
 
117
+ const SIGIL_ATTR = {
118
+ className: 'attribute',
119
+ begin: /\$[a-zA-Z_][\w]*/,
120
+ };
121
+
93
122
  const CLASS_NAME = {
94
123
  className: 'title.class',
95
124
  begin: /[A-Z][\w]*/,
@@ -106,6 +135,24 @@ export default function(hljs) {
106
135
  ],
107
136
  };
108
137
 
138
+ const METHOD_DEF = {
139
+ className: 'function',
140
+ match: /[a-zA-Z_$][\w$]*[!?]?(?=\s*:\s*(?:\([^)]*\)\s*)?[-=]>)/,
141
+ contains: [
142
+ { className: 'title.function', begin: /[a-zA-Z_$][\w$]*[!?]?/ },
143
+ ],
144
+ };
145
+
146
+ const COMPONENT_DEF = {
147
+ className: 'class',
148
+ begin: /\b(?:export\s+)?[A-Z][\w]*\s*=\s*component\b/,
149
+ returnBegin: true,
150
+ keywords: { keyword: ['export', 'component'] },
151
+ contains: [
152
+ { className: 'title.class', begin: /[A-Z][\w]*/ },
153
+ ],
154
+ };
155
+
109
156
  const CLASS_DEF = {
110
157
  className: 'class',
111
158
  beginKeywords: 'class',
@@ -118,7 +165,7 @@ export default function(hljs) {
118
165
 
119
166
  const OPERATORS = {
120
167
  className: 'operator',
121
- begin: /\|>|::=|::|:=|~=|~>|<=>|=!|!\?|=~|\?\?|\?\.|\.\.\.|\.\.|=>|->|\*\*|\/\/|%%|===|!==|==|!=|<=|>=|&&|\|\||[+\-*\/%&|^~<>=!?]/,
168
+ begin: /\|>|::=|::|:=|~=|~>|<=>|\.=|=!|!\?|\?!|=~|\?\?=|\?\?|\?\.|\.\.\.|\.\.|=>|->|\*\*|\/\/|%%|===|!==|==|!=|<=|>=|&&|\|\||[+\-*\/%&|^~<>=!?]/,
122
169
  relevance: 0,
123
170
  };
124
171
 
@@ -144,13 +191,16 @@ export default function(hljs) {
144
191
  STRING_SINGLE,
145
192
  HEREGEX,
146
193
  REGEX,
194
+ COMPONENT_DEF,
147
195
  FUNCTION_DEF,
196
+ METHOD_DEF,
148
197
  CLASS_DEF,
149
198
  NUMBER,
150
199
  INSTANCE_VAR,
200
+ SIGIL_ATTR,
151
201
  TYPE_KEYWORDS,
152
202
  OPERATORS,
153
- { // inline JS
203
+ { // inline JS (backtick)
154
204
  className: 'string',
155
205
  begin: /`[^`]*`/,
156
206
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rip-lang/print",
3
- "version": "1.1.49",
3
+ "version": "1.1.51",
4
4
  "description": "Syntax-highlighted source code printer - highlight.js-powered, serves once, auto-opens browser",
5
5
  "type": "module",
6
6
  "main": "print.rip",
@@ -29,7 +29,7 @@
29
29
  "author": "Steve Shreeve <steve.shreeve@gmail.com>",
30
30
  "license": "MIT",
31
31
  "dependencies": {
32
- "rip-lang": ">=3.13.69",
32
+ "rip-lang": ">=3.13.70",
33
33
  "highlight.js": "^11.11.1"
34
34
  },
35
35
  "files": [