Use backtick syntax to support identifiers in expression language, see examples
parent
6f897f6f6e
commit
7de987fd56
|
@ -10,7 +10,7 @@ export const parser = LRParser.deserialize({
|
||||||
maxTerm: 84,
|
maxTerm: 84,
|
||||||
skippedNodes: [0,1],
|
skippedNodes: [0,1],
|
||||||
repeatNodeCount: 5,
|
repeatNodeCount: 5,
|
||||||
tokenData: "=Z~R!RX^$[pq$[qr%Prs%fst&Tuv&lwx&qxy'Zyz'`z{'e{|'j|}'o}!O't!O!P'y!P!Q(O!Q![*g![!]*o!^!_*t!_!`+R!`!a+`!a!b+m!b!c+r!c!},a!}#O-c#P#Q.`#S#T.e#T#U.}#U#W,a#W#X0z#X#Y,a#Y#Z1k#Z#],a#]#^4u#^#b,a#b#c6R#c#d8O#d#h,a#h#i;o#i#o,a#o#p=P#q#r=U#y#z$[$f$g$[#BY#BZ$[$IS$I_$[$I|$JO$[$JT$JU$[$KV$KW$[&FU&FV$[~$aY!Y~X^$[pq$[#y#z$[$f$g$[#BY#BZ$[$IS$I_$[$I|$JO$[$JT$JU$[$KV$KW$[&FU&FV$[R%UP!fP!_!`%XQ%^P!kQ#r#s%aQ%fO!oQ~%iTOr%frs%xs;'S%f;'S;=`%}<%lO%f~%}OU~~&QP;=`<%l%f~&YSP~OY&TZ;'S&T;'S;=`&f<%lO&T~&iP;=`<%l&T~&qO!r~~&tTOw&qwx%xx;'S&q;'S;=`'T<%lO&q~'WP;=`<%l&q~'`O!`~~'eO!a~~'jO!p~~'oO!s~~'tO!]~~'yO!g~~(OO!_~R(TW!qQOY(mZ](m^!P(m!Q#O(m#O#P)b#P;'S(m;'S;=`*a<%lO(mP(pXOY(mZ](m^!P(m!P!Q)]!Q#O(m#O#P)b#P;'S(m;'S;=`*a<%lO(mP)bOXPP)eRO;'S(m;'S;=`)n;=`O(mP)qYOY(mZ](m^!P(m!P!Q)]!Q#O(m#O#P)b#P;'S(m;'S;=`*a;=`<%l(m<%lO(mP*dP;=`<%l(m~*lPT~!Q![*g~*tO!u~~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q,z!Q![,a!c!},a#R#S,a#T#X,a#X#Y4_#Y#o,aV4hUfSWPYR}!O,a!P!Q,z!Q![,a!c!},a#R#S,a#T#o,aV5RWfSYR}!O,a!P!Q,z!Q![,a!c!},a#R#S,a#T#b,a#b#c5k#c#o,aV5tUfS|QYR}!O,a!P!Q,z!Q![,a!c!},a#R#S,a#T#o,aV6_WfSYR}!O,a!P!Q,z!Q![,a!c!},a#R#S,a#T#c,a#c#d6w#d#o,aV7OWfSYR}!O,a!P!Q,z!Q![,a!c!},a#R#S,a#T#h,a#h#i7h#i#o,aV7qUfSzPYR}!O,a!P!Q,z!Q![,a!c!},a#R#S,a#T#o,aV8[WfSYR}!O,a!P!Q,z!Q![,a!c!},a#R#S,a#T#f,a#f#g8t#g#o,aV8{WfSYR}!O,a!P!Q,z!Q![,a!c!},a#R#S,a#T#W,a#W#X9e#X#o,aV9lWfSYR}!O,a!P!Q,z!Q![,a!c!},a#R#S,a#T#X,a#X#Y:U#Y#o,aV:]WfSYR}!O,a!P!Q,z!Q![,a!c!},a#R#S,a#T#f,a#f#g:u#g#o,aV:|VfSYRpq;c}!O,a!P!Q,z!Q![,a!c!},a#R#S,a#T#o,aR;fP#U#V;iR;lP#m#n;oR;tOlRV;{WfSYR}!O,a!P!Q,z!Q![,a!c!},a#R#S,a#T#f,a#f#g<e#g#o,aV<lWfSYR}!O,a!P!Q,z!Q![,a!c!},a#R#S,a#T#i,a#i#j3n#j#o,a~=ZO!b~~=`O!e~",
|
||||||
tokenizers: [0, 1, 2],
|
tokenizers: [0, 1, 2],
|
||||||
topRules: {"Program":[0,2]},
|
topRules: {"Program":[0,2]},
|
||||||
specialized: [{term: 10, get: (value) => spec_Identifier[value] || -1}],
|
specialized: [{term: 10, get: (value) => spec_Identifier[value] || -1}],
|
||||||
|
|
|
@ -10,7 +10,7 @@ export const parser = LRParser.deserialize({
|
||||||
maxTerm: 84,
|
maxTerm: 84,
|
||||||
skippedNodes: [0,1],
|
skippedNodes: [0,1],
|
||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o,aV5tUSPlSUU}!O,a!P!Q,z!Q![,a!c!},a#R#S,a#T#o,aV6_WSPUU}!O,a!P!Q,z!Q![,a!c!},a#R#S,a#T#c,a#c#d6w#d#o,aV7OWSPUU}!O,a!P!Q,z!Q![,a!c!},a#R#S,a#T#h,a#h#i7h#i#o,aV7qUSPjQUU}!O,a!P!Q,z!Q![,a!c!},a#R#S,a#T#o,aV8[WSPUU}!O,a!P!Q,z!Q![,a!c!},a#R#S,a#T#f,a#f#g8t#g#o,aV8{WSPUU}!O,a!P!Q,z!Q![,a!c!},a#R#S,a#T#W,a#W#X9e#X#o,aV9lWSPUU}!O,a!P!Q,z!Q![,a!c!},a#R#S,a#T#X,a#X#Y:U#Y#o,aV:]WSPUU}!O,a!P!Q,z!Q![,a!c!},a#R#S,a#T#f,a#f#g:u#g#o,aV:|VSPUUpq;c}!O,a!P!Q,z!Q![,a!c!},a#R#S,a#T#o,aU;fP#U#V;iU;lP#m#n;oU;tOuUV;{WSPUU}!O,a!P!Q,z!Q![,a!c!},a#R#S,a#T#f,a#f#g<e#g#o,aV<lWSPUU}!O,a!P!Q,z!Q![,a!c!},a#R#S,a#T#i,a#i#j3n#j#o,a~=ZO!b~~=`O!c~",
|
||||||
tokenizers: [0, 1, 2],
|
tokenizers: [0, 1, 2],
|
||||||
topRules: {"Program":[0,2]},
|
topRules: {"Program":[0,2]},
|
||||||
specialized: [{term: 6, get: (value) => spec_Identifier[value] || -1}],
|
specialized: [{term: 6, get: (value) => spec_Identifier[value] || -1}],
|
||||||
|
|
|
@ -125,14 +125,13 @@ Bool {
|
||||||
|
|
||||||
TagIdentifier { @asciiLetter (@asciiLetter | @digit | "-" | "_" | "/" )* }
|
TagIdentifier { @asciiLetter (@asciiLetter | @digit | "-" | "_" | "/" )* }
|
||||||
|
|
||||||
Identifier { @asciiLetter (@asciiLetter | @digit | "-" | "_")* }
|
Identifier { @asciiLetter (@asciiLetter | @digit | "-" | "_")* | "`" ![`]* "`" }
|
||||||
|
|
||||||
GlobalIdentifier { "@" @asciiLetter (@asciiLetter | @digit | "-" | "_")* }
|
GlobalIdentifier { "@" @asciiLetter (@asciiLetter | @digit | "-" | "_")* }
|
||||||
|
|
||||||
String {
|
String {
|
||||||
"\"" ![\"]* "\""
|
"\"" ![\"]* "\""
|
||||||
| "'" ![']* "'"
|
| "'" ![']* "'"
|
||||||
| "`" ![`]* "`"
|
|
||||||
}
|
}
|
||||||
PageRef {
|
PageRef {
|
||||||
"[[" ![\]]* "]]"
|
"[[" ![\]]* "]]"
|
||||||
|
|
|
@ -63,10 +63,12 @@ export function astToKvQuery(
|
||||||
query.select = [];
|
query.select = [];
|
||||||
}
|
}
|
||||||
if (select.length === 2) {
|
if (select.length === 2) {
|
||||||
query.select.push({ name: select[1][1] as string });
|
query.select.push({
|
||||||
|
name: cleanIdentifier(select[1][1] as string),
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
query.select.push({
|
query.select.push({
|
||||||
name: select[3][1] as string,
|
name: cleanIdentifier(select[3][1] as string),
|
||||||
expr: expressionToKvQueryExpression(select[1]),
|
expr: expressionToKvQueryExpression(select[1]),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -88,6 +90,13 @@ export function astToKvQuery(
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function cleanIdentifier(s: string): string {
|
||||||
|
if (s.startsWith("`") && s.endsWith("`")) {
|
||||||
|
return s.slice(1, -1);
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
export function expressionToKvQueryExpression(node: AST): QueryExpression {
|
export function expressionToKvQueryExpression(node: AST): QueryExpression {
|
||||||
if (["LVal", "Expression", "Value"].includes(node[0])) {
|
if (["LVal", "Expression", "Value"].includes(node[0])) {
|
||||||
return expressionToKvQueryExpression(node[1]);
|
return expressionToKvQueryExpression(node[1]);
|
||||||
|
@ -98,11 +107,11 @@ export function expressionToKvQueryExpression(node: AST): QueryExpression {
|
||||||
return [
|
return [
|
||||||
"attr",
|
"attr",
|
||||||
expressionToKvQueryExpression(node[1]),
|
expressionToKvQueryExpression(node[1]),
|
||||||
node[3][1] as string,
|
cleanIdentifier(node[3][1] as string),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
case "Identifier":
|
case "Identifier":
|
||||||
return ["attr", node[1] as string];
|
return ["attr", cleanIdentifier(node[1] as string)];
|
||||||
case "String":
|
case "String":
|
||||||
return ["string", (node[1] as string).slice(1, -1)];
|
return ["string", (node[1] as string).slice(1, -1)];
|
||||||
case "Number":
|
case "Number":
|
||||||
|
@ -155,7 +164,7 @@ export function expressionToKvQueryExpression(node: AST): QueryExpression {
|
||||||
}
|
}
|
||||||
case "Call": {
|
case "Call": {
|
||||||
// console.log("Call", node);
|
// console.log("Call", node);
|
||||||
const fn = node[1][1] as string;
|
const fn = cleanIdentifier(node[1][1] as string);
|
||||||
const args: AST[] = [];
|
const args: AST[] = [];
|
||||||
for (const expr of node.slice(2)) {
|
for (const expr of node.slice(2)) {
|
||||||
if (expr[0] === "Expression") {
|
if (expr[0] === "Expression") {
|
||||||
|
|
|
@ -43,6 +43,41 @@ Deno.test("Test query parser", () => {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
assertEquals(
|
||||||
|
astToKvQuery(wrapQueryParse(`page where name = "hello"`)!),
|
||||||
|
{
|
||||||
|
querySource: "page",
|
||||||
|
filter: ["=", ["attr", "name"], [
|
||||||
|
"string",
|
||||||
|
"hello",
|
||||||
|
]],
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEquals(
|
||||||
|
astToKvQuery(wrapQueryParse("page where `name`")!),
|
||||||
|
{
|
||||||
|
querySource: "page",
|
||||||
|
filter: ["attr", "name"],
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEquals(
|
||||||
|
astToKvQuery(wrapQueryParse("page where `something`.`name`")!),
|
||||||
|
{
|
||||||
|
querySource: "page",
|
||||||
|
filter: ["attr", ["attr", "something"], "name"],
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEquals(
|
||||||
|
astToKvQuery(wrapQueryParse("page select 10 as `something`, `name`")!),
|
||||||
|
{
|
||||||
|
querySource: "page",
|
||||||
|
select: [{ name: "something", expr: ["number", 10] }, { name: "name" }],
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
astToKvQuery(wrapQueryParse(`page where @page`)!),
|
astToKvQuery(wrapQueryParse(`page where @page`)!),
|
||||||
{
|
{
|
||||||
|
@ -375,7 +410,10 @@ Deno.test("Test query parser", () => {
|
||||||
),
|
),
|
||||||
{
|
{
|
||||||
querySource: "page",
|
querySource: "page",
|
||||||
filter: [">", ["call", "myCall", [["-", ["number", 3]]]], ["-", ["number", 4], ["number", 2]]],
|
filter: [">", ["call", "myCall", [["-", ["number", 3]]]], ["-", [
|
||||||
|
"number",
|
||||||
|
4,
|
||||||
|
], ["number", 2]]],
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -5,13 +5,14 @@ Examples in this page will be demonstrated by embedding expressions inside of a
|
||||||
While a custom language, it takes a lot of inspiration from JavaScript and SQL, but includes some features very specific to SilverBullet, including syntax for embedded queries and page references.
|
While a custom language, it takes a lot of inspiration from JavaScript and SQL, but includes some features very specific to SilverBullet, including syntax for embedded queries and page references.
|
||||||
|
|
||||||
# Primitive values
|
# Primitive values
|
||||||
* strings: `"a string"`, `'a string'` or `a string` (with backticks). Escaping is not currently supported, so use your quotes wisely.
|
* strings: `"a string"`, or `'a string'`. Escaping is not currently supported, so use your quotes wisely.
|
||||||
* numbers: `10`
|
* numbers: `10`
|
||||||
* booleans: `true` or `false`
|
* booleans: `true` or `false`
|
||||||
* regular expressions: `/[a-z]+/`
|
* regular expressions: `/[a-z]+/`
|
||||||
* null: `null`
|
* null: `null`
|
||||||
* lists: `["value 1", 10, false]`
|
* lists: `["value 1", 10, false]`
|
||||||
* objects: `{"name": "Jack", "age": 1232}`
|
* objects: `{"name": "Jack", "age": 1232}`
|
||||||
|
* identifiers: starting with a letter, followed by alphanumerics, `_` or `-`. Identifiers can also be surrounded with backticks: ` and in that case contain any non-backtick characters, including spaces.
|
||||||
* attributes:
|
* attributes:
|
||||||
* `.` for the current object
|
* `.` for the current object
|
||||||
* `attr` for the current object’s attribute with the name `attr`
|
* `attr` for the current object’s attribute with the name `attr`
|
||||||
|
@ -20,9 +21,9 @@ While a custom language, it takes a lot of inspiration from JavaScript and SQL,
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
```template
|
```template
|
||||||
String expression: {{"This is a string"}}
|
String expression: {{"This is a string"}}
|
||||||
List expression: {{[1, 2, 3]}}
|
List expression: {{[1, 2, 3]}}
|
||||||
Attribute of variable: {{@page.name}}
|
Attribute of variable: {{@page.name}}
|
||||||
```
|
```
|
||||||
|
|
||||||
# Function calls
|
# Function calls
|
||||||
|
|
|
@ -52,12 +52,12 @@ person where page = @page.name limit 1
|
||||||
```
|
```
|
||||||
|
|
||||||
## select
|
## select
|
||||||
You can use the `select` clause to select only specific attributes from the result set. You can use it either simply as `select attribute1, attribute2` but also select the value of certain expressions and give them a name via the `select age + 1 as nextYear` syntax:
|
You can use the `select` clause to select only specific attributes from the result set. You can use it either simply as `select attribute1, attribute2` but also select the value of certain expressions and give them a name, even one containing spaces using the backtick identifier syntax:
|
||||||
|
|
||||||
```query
|
```query
|
||||||
person
|
person
|
||||||
where page = @page.name
|
where page = @page.name
|
||||||
select name, age, age + 1 as nextYear
|
select name, age, age + 1 as `next year`
|
||||||
```
|
```
|
||||||
|
|
||||||
## render each <template> and render all <template>
|
## render each <template> and render all <template>
|
||||||
|
|
Loading…
Reference in New Issue