Skip to content

Commit

Permalink
Add support for sqlite.query/sqlite.row as let decorator.
Browse files Browse the repository at this point in the history
  • Loading branch information
toots committed Dec 4, 2023
1 parent 0f71c30 commit 7235a81
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/liquidsoap.grammar
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ parseDecorationArgs {
}

parseDecoration /* precedence: right 1 */ {
(kw<"json"> | kw<"yaml">) "." kw<"parse"> (!no_app "[" parseDecorationArgs? "]")?
(kw<"json"> | kw<"yaml">) "." kw<"parse"> (!no_app "[" parseDecorationArgs? "]")? |
kw<"sqlite"> "." (kw<"row"> | kw<"query">)
}

defDecoration {
Expand Down
7 changes: 4 additions & 3 deletions src/tokens.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { _var, varLpar, varLbra, uminus, Float } from "./parser.terms.js";

const whiteSpace = /[ \t]/;

const letKeywords = ["eval", "replaces", "json", "yaml"];
const letKeywords = ["eval", "replaces", "json", "yaml", "sqlite"];

const defKeywords = ["rec", "replaces"];

Expand Down Expand Up @@ -87,7 +87,7 @@ export const varTok = new ExternalTokenizer((input, stack) => {

if (prevKeyword === "def" && defKeywords.includes(str)) return;
if (prevKeyword === "let" && letKeywords.includes(str)) {
if (!["json", "yaml"].includes(str)) return;
if (!["json", "yaml", "sqlite"].includes(str)) return;

let parseStr = "";
let parsePos = 0;
Expand All @@ -96,7 +96,8 @@ export const varTok = new ExternalTokenizer((input, stack) => {
parsePos++;
}

if (parseStr === ".parse") return;
if (["json", "yaml"].includes(str) && parseStr === ".parse") return;
if (str === "sqlite" && [".row", ".query"].includes(parseStr)) return;
}

if (
Expand Down

0 comments on commit 7235a81

Please sign in to comment.