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

cmd/cue: import/export (go|rust|...) #1036

Open
cueckoo opened this issue Jul 3, 2021 · 2 comments
Open

cmd/cue: import/export (go|rust|...) #1036

cueckoo opened this issue Jul 3, 2021 · 2 comments
Labels
FeatureRequest New feature or request

Comments

@cueckoo
Copy link
Collaborator

cueckoo commented Jul 3, 2021

Originally opened by @myitcv in cuelang/cue#1036

In #646 we discuss renaming cue get go to be cue import go. In the future we also intend to more clearly support exporting from CUE to some other language representation (this is currently made possible via the cuelang.org/go/encoding/gocode package) from the command line.

Which begs the question: what about languages other than Go?

For example, @nyarly has previous enquired about Rust being added to that list.

This is a general placeholder for import/export support for "insert your language here".

Building on the motivation in #646, this would purely be the support for importing/exporting from/to "a another language", e.g. Rust. The method for resolving packages (or the equivalent in any given language) would be delegated to language specific tooling/loader/something. e.g. for Go, package resolution is handled by go/packages, which requires that (as of Go 1.16) a go.mod is present through which a package can be resolved.

@cueckoo cueckoo added FeatureRequest New feature or request Triage Requires triage/attention labels Jul 3, 2021
@cueckoo
Copy link
Collaborator Author

cueckoo commented Jul 3, 2021

Original reply by @verdverm in cuelang/cue#1036 (comment)

I wonder if there is a way to use tree-sitter , given all the language grammars that have accumulated there.

There looks to be an unofficial Go binding here: https://github.com/smacker/go-tree-sitter


I'm going to guess that "tree-standing" (for export) won't work out well after exploring some of the grammars. We'd probably need to define a language format (in CUE of course :) for generation. Maybe that format maps onto the tree-sitter grammar, but it looks to be quite complicated due to the widely varied syntax across languages.

@cueckoo
Copy link
Collaborator Author

cueckoo commented Jul 3, 2021

Original reply by @myitcv in cuelang/cue#1036 (comment)

For import (currently cue get go) we need type information for Go, and suspect we would for every other language: syntax by itself would not be enough (unless I misunderstood what you were suggesting, or am missing a piece in the puzzle here with respect to tree sitter?). For export I'm not sure of the need for a common format - we simply need to take convert from CUE API values (already well defined) to a target language (could be as simple as fmt.Printf calls, could use text/template, could use an AST for the language...)

@myitcv myitcv removed the Triage Requires triage/attention label Jul 29, 2021
@myitcv myitcv added the zGarden label Jun 15, 2023
@mvdan mvdan removed the zGarden label Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FeatureRequest New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants