Skip to content

Commit

Permalink
Support single action with trailing semicolon
Browse files Browse the repository at this point in the history
  • Loading branch information
valkjsaaa committed Nov 5, 2023
1 parent 40356a2 commit 5b72cbe
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
10 changes: 10 additions & 0 deletions lib/dsl/__test__/dsl-interpreter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
9 changes: 7 additions & 2 deletions lib/dsl/parser.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}, [])
);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/nl/prompt-gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 5b72cbe

Please sign in to comment.