Giter Site home page Giter Site logo

Comments (7)

mstijak avatar mstijak commented on September 26, 2024 1

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.

e5b47f9

from tdo.

mstijak avatar mstijak commented on September 26, 2024

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.

RobertTalbert avatar RobertTalbert commented on September 26, 2024

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.

mstijak avatar mstijak commented on September 26, 2024

What would be the best way to write a parser that is simple and forgiving for bad inputs, e.g. unmatched brackets?

from tdo.

RobertTalbert avatar RobertTalbert commented on September 26, 2024

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.

RobertTalbert avatar RobertTalbert commented on September 26, 2024

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

tree_2

(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.

RobertTalbert avatar RobertTalbert commented on September 26, 2024

Nice! That seems to work well. Thanks a lot.

from tdo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.