diff --git a/lib/dsl/__test__/dsl-interpreter.test.ts b/lib/dsl/__test__/dsl-interpreter.test.ts index b78b49f..63d5f84 100644 --- a/lib/dsl/__test__/dsl-interpreter.test.ts +++ b/lib/dsl/__test__/dsl-interpreter.test.ts @@ -235,6 +235,16 @@ test("Multiple actions", async () => { expect(funcCallResult["objectType"]).toEqual("string"); }); +test("Single actions with semicolon", async () => { + Restaurant.all(); + const interpreter = new DslInterpreter(allDescriptors); + const funcCallResult = await interpreter.interpret( + 'Order.all().dateTime[0].dayOfWeek;' + ); + expect(funcCallResult["objectType"]).toEqual("string"); +}); + + test("[dry run] Order containing burger", async () => { Restaurant.all(); diff --git a/lib/dsl/parser.pegjs b/lib/dsl/parser.pegjs index 712319f..82afffa 100644 --- a/lib/dsl/parser.pegjs +++ b/lib/dsl/parser.pegjs @@ -7,11 +7,16 @@ } } -top = s: statement sl: (SP* ';' SP* statement)* { +top = s: statement sl: (SP* ';' SP* statement?)* { return [s].concat( sl.map((e) => { return e[3]; - }) + }).reduce((acc, cur) => { + if (cur !== null) { + acc.push(cur); + } + return acc; + }, []) ); } diff --git a/lib/nl/prompt-gen.ts b/lib/nl/prompt-gen.ts index 516cdc2..6994a85 100644 --- a/lib/nl/prompt-gen.ts +++ b/lib/nl/prompt-gen.ts @@ -43,7 +43,7 @@ export class BasicPromptGen { )}${post_section_separator}` + `${example_prequel}${pre_section_separator}` + `${example_parses(this.examples)}${post_section_separator}` + - `${parse_issues}${post_section_separator}` + + // `${parse_issues}${post_section_separator}` + `${user_interaction_prequel}${pre_section_separator}`; if (this.extraPrompt !== undefined) { prompt += `${this.extraPrompt}${pre_section_separator}`; diff --git a/package.json b/package.json index d6e69bd..63a3d9b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "reactgenie-dsl", - "version": "0.0.32", + "version": "0.0.33", "description": "A natural language parser based on a large language model", "scripts": { "prepare": "peggy lib/dsl/parser.pegjs -o lib/dsl/parser.gen.js && tsc",