Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ransome
sleek
Commits
f9a78db7
Commit
f9a78db7
authored
Jun 23, 2021
by
ransome1
Browse files
Merge branch 'develop' of github.com:ransome1/sleek into develop
parents
a38c0249
1d8c639b
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/js/filterlang.pegjs
View file @
f9a78db7
...
...
@@ -4,6 +4,7 @@
filterQuery
= _ left:orExpr _ { return left; }
/ _ { return []; }
orExpr
= left:andExpr _ OrOp _ right:orExpr { return left.concat(right, ["||"]); }
...
...
@@ -28,11 +29,11 @@ boolExpr
project
= "+" left:name { return ["++", left]; }
/ "+
*
" { return ["++", "*"]; }
/ "+" { return ["++", "*"]; }
context
= "@" left:name { return ["@@", left]; }
/ "@
*
" { return ["@@", "*"]; }
/ "@" { return ["@@", "*"]; }
OrOp
= "||"
...
...
@@ -113,10 +114,10 @@ number
= [0-9]+ { return text(); }
StringLiteral "string"
= '"' chars:DoubleStringCharacter* '"' {
= '"' chars:DoubleStringCharacter* '"'
?
{
return chars.join("");
}
/ "'" chars:SingleStringCharacter* "'" {
/ "'" chars:SingleStringCharacter* "'"
?
{
return chars.join("");
}
...
...
@@ -132,7 +133,7 @@ RegexLiteral "regex"
= "/" chars:RegexCharacter* "/" "i" {
return new RegExp(chars.join(""), "i");
}
/ "/" chars:RegexCharacter* "/" {
/ "/" chars:RegexCharacter* "/"
?
{
return new RegExp(chars.join(""));
}
...
...
@@ -144,7 +145,9 @@ SourceCharacter
= .
name
= [a-zA-Z_][a-zA-Z_0-9]* { return text(); }
= '"' [a-zA-Z_][a-zA-Z_0-9]* '"' { return text(); }
/ [a-zA-Z_][a-zA-Z_0-9]* '"' { return '"' + text(); }
/ [a-zA-Z_][a-zA-Z_0-9]* { return text(); }
_ "whitespace"
= [ \t\n\r]*
\ No newline at end of file
= [ \t\n\r]*
src/js/filterquery.mjs
View file @
f9a78db7
...
...
@@ -4,6 +4,9 @@
// specifically for todo.txt searching and filtering.
function
runQuery
(
item
,
compiledQuery
)
{
if
(
!
compiledQuery
)
{
return
true
;
// a null query matches everything
}
let
stack
=
[];
let
operand1
=
false
;
let
operand2
=
false
;
...
...
@@ -69,16 +72,26 @@ function runQuery(item, compiledQuery) {
next
=
q
.
shift
();
if
(
next
==
"
*
"
)
{
stack
.
push
(
item
.
projects
?
true
:
false
);
}
else
if
(
next
.
startsWith
(
'
"
'
))
{
stack
.
push
(
item
.
projects
&&
item
.
projects
.
includes
(
next
.
slice
(
1
,
-
1
)));
}
else
{
stack
.
push
(
item
.
projects
&&
item
.
projects
.
includes
(
next
));
// match the prefix of the project name
stack
.
push
(
item
.
projects
&&
item
.
projects
.
findIndex
(
function
(
p
)
{
return
p
.
startsWith
(
next
);
})
>
-
1
);
}
break
;
case
"
@@
"
:
next
=
q
.
shift
();
if
(
next
==
"
*
"
)
{
stack
.
push
(
item
.
contexts
?
true
:
false
);
}
else
if
(
next
.
startsWith
(
'
"
'
))
{
stack
.
push
(
item
.
contexts
&&
item
.
contexts
.
includes
(
next
.
slice
(
1
,
-
1
)));
}
else
{
stack
.
push
(
item
.
contexts
&&
item
.
contexts
.
includes
(
next
));
// match the prefix of the context name
stack
.
push
(
item
.
contexts
&&
item
.
contexts
.
findIndex
(
function
(
c
)
{
return
c
.
startsWith
(
next
);
})
>
-
1
);
}
break
;
case
"
||
"
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment