Skip to content
New issue

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

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

Already on GitHub? # to your account

CUE #857

Closed
1 task done
myitcv opened this issue Sep 22, 2023 · 3 comments · Fixed by #858
Closed
1 task done

CUE #857

myitcv opened this issue Sep 22, 2023 · 3 comments · Fixed by #858
Labels
help wanted lexer missing Missing a lexer, please contribute

Comments

@myitcv
Copy link
Contributor

myitcv commented Sep 22, 2023

Is there an existing issue for this?

  • I have searched the existing issues

What is the missing lexer?

CUE (https://cuelang.org/) is an open source configuration, policy, validation, data and schema language. It has a rich set of APIs and tooling, for defining, generating, and validating all kinds of data: configuration, APIs, database schemas, code, etc.

Links to existing syntax definitions

We are working on various syntax definitions based on the language spec:

https://cuelang.org/docs/references/

The most complete representations to date are:

TextMate grammars will follow.

@myitcv myitcv added help wanted lexer missing Missing a lexer, please contribute labels Sep 22, 2023
@myitcv
Copy link
Contributor Author

myitcv commented Sep 22, 2023

I would like to suggest that for now we iterate on the initial CUE lexer via pull requests into https://github.com/myitcvforks/chroma. That will allow for testing, iteration etc without creating too much noise here.

As you can see from the tip of master in that repo, I have made a start.

@alecthomas how does that sound?

If that works, please feel free to assign this issue to me in case that helps with your workflow/project management. I'm a full time contributor to the CUE project and will help to coordinate here in whatever way helps make things easy for you and the chroma project.

I also wonder whether you could help advise how best to work with a lexer that is not yet complete. Is there a way of writing an XML-based lexer such that it relaxes in case it encounters a syntactic element it doesn't know about, rather than emitting errors?

@alecthomas
Copy link
Owner

alecthomas commented Sep 22, 2023

That's sounds fine to me.

I also wonder whether you could help advise how best to work with a lexer that is not yet complete. Is there a way of writing an XML-based lexer such that it relaxes in case it encounters a syntactic element it doesn't know about, rather than emitting errors?

I think just having a fallback pattern like this should do it:

      <rule pattern=".">
        <token type="Text"/>
      </rule>

myitcv added a commit to myitcvforks/chroma that referenced this issue Sep 23, 2023
This commit adds a decent first-cut of a lexer for CUE
(https://cuelang.org).

The main aspects of the language are implemented, but there are likely a
number of edge cases not covered, especially when it comes to string
interpolation, but this is a sufficiently decent first cut so as to
warrant merging into the chroma project rather than first working in a
fork.

Closes alecthomas#857
myitcv added a commit to myitcvforks/chroma that referenced this issue Sep 23, 2023
This commit adds a decent first-cut of a lexer for CUE
(https://cuelang.org).

The main aspects of the language are implemented, but there are likely a
number of edge cases not covered, especially when it comes to string
interpolation, but this is a sufficiently decent first cut so as to
warrant merging into the chroma project rather than first working in a
fork.

Closes alecthomas#857
myitcv added a commit to myitcvforks/chroma that referenced this issue Sep 23, 2023
This commit adds a decent first-cut of a lexer for CUE
(https://cuelang.org).

The main aspects of the language are implemented, but there are likely a
number of edge cases not covered, especially when it comes to string
interpolation, but this is a sufficiently decent first cut so as to
warrant merging into the chroma project rather than first working in a
fork.

This was tested locally for visual correctness using

    mkdir -p _examples
    (command cd ./cmd/chroma; go run . --lexer=cue --html --html-inline-styles) < lexers/testdata/cue.actual > _examples/cue.html

and then loading _examples/cue.html in a browser.

Closes alecthomas#857
@myitcv
Copy link
Contributor Author

myitcv commented Sep 23, 2023

That's sounds fine to me.

Great. I actually bit the bullet and tried to sketch out a pretty decent first cut, which is now pushed up in #858.

I also wonder whether you could help advise how best to work with a lexer that is not yet complete. Is there a way of writing an XML-based lexer such that it relaxes in case it encounters a syntactic element it doesn't know about, rather than emitting errors?

I think just having a fallback pattern like this should do it:

      <rule pattern=".">
        <token type="Text"/>
      </rule>

Thanks, appreciate the pointer. I also learned a great deal from looking at the other lexers.

alecthomas pushed a commit that referenced this issue Sep 23, 2023
This commit adds a decent first-cut of a lexer for CUE
(https://cuelang.org).

The main aspects of the language are implemented, but there are likely a
number of edge cases not covered, especially when it comes to string
interpolation, but this is a sufficiently decent first cut so as to
warrant merging into the chroma project rather than first working in a
fork.

This was tested locally for visual correctness using

    mkdir -p _examples
    (command cd ./cmd/chroma; go run . --lexer=cue --html --html-inline-styles) < lexers/testdata/cue.actual > _examples/cue.html

and then loading _examples/cue.html in a browser.

Closes #857
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
help wanted lexer missing Missing a lexer, please contribute
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants