Comments (7)
I hacked something. Since this is JavaScript we can use builtin functionality to do the parsing. Please report any issues you find. &&
and ||
also work.
from tdo.
I like the idea. The app already allows searching for multiple words, so we just need to support OR and maybe we can simply ignore AND if we find it.
Should we simply evaluate left to right?
For example, @work
would be mandatory in @computer OR !important AND @work
.
from tdo.
It would be more consistent with order of operations in programming languages (I'm thinking Python mostly) to have AND take precedence over OR. So @computer OR !important AND @work
would be evaluated like @computer OR (!important AND @work)
. I'd need to whip up a truth table to see if those two expressions are equivalent but I think they aren't always going to be.
If I wanted tasks that had either @computer
or !important
but they all must have @work
, I'd enter (@computer OR !important) AND @work
(or write it out without parentheses using DeMorgan's Laws). I'm not saying that would be the easiest approach! But that would make the most sense from a user perspective.
Oh, I forgot NOT -- a search for NOT @work
would give me all tasks that don't have @work
attached. NOT would take precedence over both AND and OR.
from tdo.
What would be the best way to write a parser that is simple and forgiving for bad inputs, e.g. unmatched brackets?
from tdo.
Update: Now that I've had my coffee -- If you evaluate left to right, then x or y and z
would be interpreted (x or y) and z
which is definitely not equivalent to x or (y and z)
. The latter is what would be evaluated if x or y and z
were done using regular order of operations.
from tdo.
What would be the best way to write a parser that is simple and forgiving for bad inputs, e.g. unmatched brackets?
I am not actually a programmer, but IIRC these parsers are often done by representing the input as a tree structure and then doing a traversal (the exact type of traversal being dependent on whether you want to use a queue or a stack). Example: x or (y and z)
would be the tree
(Sorry for the huge size) Then the parser traverses the tree -- a postorder traversal would give x y z AND OR
which could then be evaluated with a stack (I think).
Actually getting the input expression from a parenthesized form into a tree is just a matter of parsing out the parentheses as tokens, but again IANA programmer.
from tdo.
Nice! That seems to work well. Thanks a lot.
from tdo.
Related Issues (20)
- Display an undo toast after deleting a task, board or a list
- Deleting tasks on touch devices
- Subtasks [feature request] HOT 4
- Controller - url pasting - app not response even for settings HOT 2
- Moving task - Cannot read property 'contains' of null
- Insert at coursor position not work HOT 2
- Option to change key binding without modify app code [feature request]
- Adding new task by keyboard - firebase error (unlogged to firebase) HOT 1
- Option to add tasks/subtask on begining or end task list [feature request]
- PWA & Offline
- Sign in with GitHub/Facebook/Twitter HOT 1
- New visual themes
- Put Sign In/Account info in the menu HOT 1
- Improve README
- Enable tdo for anonymous users HOT 1
- Optimize board selection for small screens
- Sign in with Microsoft HOT 1
- Account linking
- Question/Feature Request - Possible to Auto-Place Completed Items @ End of List? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tdo.