@malloydata/malloy 0.0.11 → 0.0.12-dev221204204332

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.
@@ -49,6 +49,18 @@ const document_highlight_walker_1 = require("./parse-tree-walkers/document-highl
49
49
  const document_completion_walker_1 = require("./parse-tree-walkers/document-completion-walker");
50
50
  const document_help_context_walker_1 = require("./parse-tree-walkers/document-help-context-walker");
51
51
  const reference_list_1 = require("./reference-list");
52
+ /**
53
+ * This ignores a -> popMode when the mode stack is empty, which is a hack,
54
+ * but it let's us parse }%
55
+ */
56
+ class HandlesOverpoppingLexer extends MalloyLexer_1.MalloyLexer {
57
+ popMode() {
58
+ if (this._modeStack.isEmpty) {
59
+ return this._mode;
60
+ }
61
+ return super.popMode();
62
+ }
63
+ }
52
64
  class MalloyParserErrorHandler {
53
65
  constructor(translator, messages) {
54
66
  this.translator = translator;
@@ -105,7 +117,16 @@ class ParseStep {
105
117
  }
106
118
  const source = srcEnt.value == "" ? "\n" : srcEnt.value;
107
119
  this.sourceInfo = this.getSourceInfo(source);
108
- const parse = this.runParser(source, that);
120
+ let parse;
121
+ try {
122
+ parse = this.runParser(source, that);
123
+ }
124
+ catch (parseException) {
125
+ that.root.logger.log({
126
+ message: `Malloy internal parser exception [${parseException.message}]`,
127
+ });
128
+ parse = undefined;
129
+ }
109
130
  if (that.root.logger.hasErrors()) {
110
131
  this.response = {
111
132
  parse,
@@ -154,7 +175,7 @@ class ParseStep {
154
175
  }
155
176
  runParser(source, that) {
156
177
  const inputStream = antlr4ts_1.CharStreams.fromString(source);
157
- const lexer = new MalloyLexer_1.MalloyLexer(inputStream);
178
+ const lexer = new HandlesOverpoppingLexer(inputStream);
158
179
  const tokenStream = new antlr4ts_1.CommonTokenStream(lexer);
159
180
  const malloyParser = new MalloyParser_1.MalloyParser(tokenStream);
160
181
  malloyParser.removeErrorListeners();
@@ -1260,6 +1260,9 @@ describe("error handling", () => {
1260
1260
  }
1261
1261
  }
1262
1262
  `));
1263
+ test("popping out of embedding when not embedded", () => {
1264
+ expect("}%").compileToFailWith("extraneous input '}%' expecting {<EOF>, EXPLORE, QUERY, SOURCE, SQL, IMPORT, ';'}");
1265
+ });
1263
1266
  });
1264
1267
  function getSelectOneStruct(sqlBlock) {
1265
1268
  const selectThis = sqlBlock.select[0];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malloydata/malloy",
3
- "version": "0.0.11",
3
+ "version": "0.0.12-dev221204204332",
4
4
  "license": "GPL-2.0",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",