Skip to content

Extend parse tree with range and position indices in input query string #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

Querela
Copy link

@Querela Querela commented Aug 10, 2022

Only cosmetic changes:

  • (a516856) Reformatted cql.js code (Visual Studio Code default Javascript settings)
  • (b22a83f) added a comment for how to use cql.js in a module manner, e.g. react etc.
  • (9b8ab81) Formatted some spaces
  • (c2037d8) Added comments to explain object fields/properties
  • (95764ea) Update demo page (add labels for output fields)

Adding position/range computation:

  • f121b10 Added custom error class CQLError to track more state (currently only actual input query, position in string and some parsing context) to help with interpreting queries. Still needs some more manual work e.g. providing hints for fixing the query or some positioning in the query string.
    Note: forgot let _qi = this.qi; which was added in 5d05ecf around line 360
  • 5d05ecf ... 1219482 Added more context to parsed query classes, e.g. position (@pos) / range (@range) of terms and operators in original query. May be used for highlighting etc. Added fifth output box in demo HTML page to demonstrate the extra range properties.
  • 908005a + eb05749 + ea00edd Add relation start position (for annotating, see demo)
    Note: only serialized in the FQ methods (ignored when loading with cql.js but might introduce incompatibilities with other tools or libraries that just take any JSON key as some modifier.)

NOTE: Indizes in @pos or @range are inclusive and start with 1.

I tried to test as many possible variants I could think of. There might be some issues but I hope I found and fixed most.
The original parsing code was left untouched, so nothing should be broken there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant