rip-lang 3.13.53 → 3.13.55

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.
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rip-lang",
3
- "version": "3.13.53",
3
+ "version": "3.13.55",
4
4
  "description": "A modern language that compiles to JavaScript",
5
5
  "type": "module",
6
6
  "main": "src/compiler.js",
package/src/components.js CHANGED
@@ -112,6 +112,25 @@ function isPublicProp(target) {
112
112
 
113
113
  export function installComponentSupport(CodeGenerator, Lexer) {
114
114
 
115
+ // ==========================================================================
116
+ // Lexer: Context-sensitive 'offer'/'accept' (only inside component bodies)
117
+ // ==========================================================================
118
+
119
+ const origClassify = Lexer.prototype.classifyKeyword;
120
+ Lexer.prototype.classifyKeyword = function(id, fallback, data) {
121
+ if (id === 'offer' || id === 'accept') {
122
+ let depth = 0;
123
+ for (let i = this.tokens.length - 1; i >= 0; i--) {
124
+ const tag = this.tokens[i][0];
125
+ if (tag === 'OUTDENT') depth++;
126
+ else if (tag === 'INDENT') depth--;
127
+ if (depth < 0 && this.tokens[i - 1]?.[0] === 'COMPONENT') return id.toUpperCase();
128
+ }
129
+ return fallback;
130
+ }
131
+ return origClassify.call(this, id, fallback, data);
132
+ };
133
+
115
134
  // ==========================================================================
116
135
  // Lexer: Render block rewriter
117
136
  // ==========================================================================
package/src/lexer.js CHANGED
@@ -61,7 +61,7 @@ let JS_KEYWORDS = new Set([
61
61
  let RIP_KEYWORDS = new Set([
62
62
  'undefined', 'Infinity', 'NaN',
63
63
  'then', 'unless', 'until', 'loop', 'of', 'by', 'when', 'def',
64
- 'component', 'render', 'offer', 'accept',
64
+ 'component', 'render',
65
65
  'enum', 'interface',
66
66
  ]);
67
67