Skip to content
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

Add lexer for JMESPath #2175

Merged
merged 7 commits into from
Jul 5, 2022
Merged

Add lexer for JMESPath #2175

merged 7 commits into from
Jul 5, 2022

Conversation

mondeja
Copy link
Contributor

@mondeja mondeja commented Jul 5, 2022

Closes #2174

@mondeja mondeja mentioned this pull request Jul 5, 2022
@mondeja mondeja marked this pull request as draft July 5, 2022 14:43
@mondeja mondeja marked this pull request as ready for review July 5, 2022 14:51
pygments/lexers/jmespath.py Outdated Show resolved Hide resolved
pygments/lexers/jmespath.py Show resolved Hide resolved
pygments/lexers/jmespath.py Show resolved Hide resolved
pygments/lexers/jmespath.py Show resolved Hide resolved
pygments/lexers/jmespath.py Outdated Show resolved Hide resolved
pygments/lexers/jmespath.py Outdated Show resolved Hide resolved
tests/examplefiles/jmespath/example.jp Outdated Show resolved Hide resolved
mondeja and others added 4 commits July 5, 2022 18:45
Co-authored-by: Jean Abou-Samra <jean@abou-samra.fr>
Co-authored-by: Jean Abou-Samra <jean@abou-samra.fr>
@jeanas jeanas merged commit 16921ee into pygments:master Jul 5, 2022
@jeanas
Copy link
Contributor

jeanas commented Jul 5, 2022

Thanks for the PR!

@innovate-invent
Copy link

This is a great start but fails for some syntax, like &expression-type.

Here is a sizeable example query:

[0].let({org: (annotations.organism || annotations.source)}, &(features[?type=='CDS' && qualifiers.translation].{id:
join('|', [
        (qualifiers.db_xref[?starts_with(@, 'GI')].['gi', split(':', @)[1]]),
        (qualifiers.protein_id[*].['ref', @]),
        (qualifiers.locus_tag[*].['locus', @]),
        join('', [':', [location][?strand==`-1`] && 'c' || '', to_string(sum([location.start, `1`])), '..', to_string(location.end)])
][][]),
seq: qualifiers.translation[0],
description: (org && join('', [qualifiers.product[0], ' [', org, ']']) || qualifiers.product[0])}))

@mondeja
Copy link
Contributor Author

mondeja commented Jul 8, 2022

Sure, do you've more examples of expression-type like before subexpression as in &(features)?

@innovate-invent
Copy link

https://github.com/jmespath-community/jmespath.spec/blob/main/functions/max_by.yml

@mondeja mondeja mentioned this pull request Jul 8, 2022
@mondeja
Copy link
Contributor Author

mondeja commented Jul 8, 2022

Great, opened #2179 to track it.

@Anteru Anteru added this to the 2.13.0 milestone Aug 14, 2022
@Anteru Anteru added the A-lexing area: changes to individual lexers label Aug 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lexing area: changes to individual lexers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add lexer for JMESPath
4 participants