dal-ast-js 0.0.5-dev → 0.0.6-dev

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.
package/dist/index.cjs CHANGED
@@ -86,7 +86,7 @@ class DalLexer {
86
86
  const token = this.getToken(character);
87
87
  if (token) {
88
88
  if (token === "HASH") {
89
- this.scanToNewLine();
89
+ this.ignoreComment();
90
90
  return;
91
91
  }
92
92
  this.addAccumulatedIdentifierToken();
@@ -103,13 +103,14 @@ class DalLexer {
103
103
  * Scan to new line to ignore comment.
104
104
  * @returns {null}
105
105
  */
106
- scanToNewLine () {
107
- do {
106
+ ignoreComment () {
107
+ while (++this.currPos < this.source.length) {
108
108
  const character = this.source[this.currPos];
109
- if (character == "\n") {
109
+ const token = this.getToken(character);
110
+ if (token == "HASH") {
110
111
  return;
111
112
  }
112
- } while (++this.currPos < this.source.length);
113
+ }
113
114
  }
114
115
 
115
116
  /**
package/dist/index.esm.js CHANGED
@@ -84,7 +84,7 @@ class DalLexer {
84
84
  const token = this.getToken(character);
85
85
  if (token) {
86
86
  if (token === "HASH") {
87
- this.scanToNewLine();
87
+ this.ignoreComment();
88
88
  return;
89
89
  }
90
90
  this.addAccumulatedIdentifierToken();
@@ -101,13 +101,14 @@ class DalLexer {
101
101
  * Scan to new line to ignore comment.
102
102
  * @returns {null}
103
103
  */
104
- scanToNewLine () {
105
- do {
104
+ ignoreComment () {
105
+ while (++this.currPos < this.source.length) {
106
106
  const character = this.source[this.currPos];
107
- if (character == "\n") {
107
+ const token = this.getToken(character);
108
+ if (token == "HASH") {
108
109
  return;
109
110
  }
110
- } while (++this.currPos < this.source.length);
111
+ }
111
112
  }
112
113
 
113
114
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dal-ast-js",
3
- "version": "0.0.5-dev",
3
+ "version": "0.0.6-dev",
4
4
  "main": "dist/index.cjs",
5
5
  "module": "dist/index.esm.js",
6
6
  "type": "module",
package/src/Lexer.js CHANGED
@@ -71,7 +71,7 @@ export class DalLexer {
71
71
  const token = this.getToken(character);
72
72
  if (token) {
73
73
  if (token === "HASH") {
74
- this.scanToNewLine();
74
+ this.ignoreComment();
75
75
  return;
76
76
  }
77
77
  this.addAccumulatedIdentifierToken();
@@ -88,13 +88,20 @@ export class DalLexer {
88
88
  * Scan to new line to ignore comment.
89
89
  * @returns {null}
90
90
  */
91
- scanToNewLine () {
92
- do {
91
+ ignoreComment () {
92
+ /**
93
+ * Comments are:
94
+ * # This is a comment #
95
+ */
96
+ let comment = "";
97
+ while (++this.currPos < this.source.length) {
93
98
  const character = this.source[this.currPos];
94
- if (character == "\n") {
99
+ const token = this.getToken(character);
100
+ if (token == "HASH") {
95
101
  return;
96
102
  }
97
- } while (++this.currPos < this.source.length);
103
+ comment += character;
104
+ }
98
105
  }
99
106
 
100
107
  /**
@@ -1,7 +1,7 @@
1
1
  design ("reverse_name_persist")
2
2
 
3
- # Example comment that is ignored.
4
- behavior b_createDatabaseConnection {
3
+ #Example comment that is ignored.#
4
+ behavior b_createDatabaseConnection
5
5
  create(name=connection, type="object", role="connection")
6
6
  _connectToDatabase(connection)
7
7
  set(worldState, ["connection"], connection)