epoxylang 0.1.8 → 0.1.9

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.
@@ -1,6 +1,6 @@
1
1
  assign name = "satya";
2
- @js ~
2
+ @js :~
3
3
  let age = 18;
4
- ~
4
+ ~:
5
5
  store msg = `my name is [name] and i'm [age] years old.`;
6
6
  show msg;
package/examples/test.epx CHANGED
@@ -1,9 +1,10 @@
1
1
  assign numbers as array = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
2
2
  repeat[i in numbers]{
3
3
  assign n as int = numbers{i};
4
- @js ~
4
+ @js :~
5
5
  if(n % 2 == 0){
6
6
  console.log(n);
7
7
  }
8
- ~
8
+ ~:
9
+ show "diikhaa..";
9
10
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "epoxylang",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "epoxy": "./bin/epoxy.js"
@@ -104,6 +104,10 @@ class Lexer {
104
104
 
105
105
  // Skip any whitespace before ~
106
106
  this.skipWhitespace();
107
+ if (this.current !== ':') {
108
+ throw new Error("Expected ':' after '@js'");
109
+ }
110
+ this.advance();
107
111
 
108
112
  if (this.current !== '~') {
109
113
  throw new Error("Expected '~' after '@js'");
@@ -113,16 +117,17 @@ class Lexer {
113
117
  // Capture everything until closing '~'
114
118
  let code = "";
115
119
 
116
- while (this.current && this.current !== '~') {
120
+ while (this.current && this.current !== '~' && this.peek !== ':') {
117
121
  code += this.current;
118
122
  this.advance();
119
123
  }
120
124
 
121
- if (this.current !== '~') {
122
- throw new Error("Unterminated @js block - missing closing '~'");
125
+ if (this.current !== '~' && this.peek !== ':') {
126
+ throw new Error("Unterminated @js block - missing closing '~:'");
123
127
  }
124
128
 
125
129
  this.advance(); // skip closing '~'
130
+ this.advance(); // skip closing ':'
126
131
 
127
132
  return new Token(TokenType.JSBLOCK, code);
128
133
  }