Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

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

Closed
myitcv opened this issue Jun 2, 2021 · 3 comments
Closed

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

myitcv opened this issue Jun 2, 2021 · 3 comments
Labels
FeatureRequest New feature or request Triage Requires triage/attention

Comments

@myitcv
Copy link
Contributor

myitcv commented Jun 2, 2021

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.

@myitcv myitcv added FeatureRequest New feature or request Triage Requires triage/attention labels Jun 2, 2021
@verdverm
Copy link
Contributor

verdverm commented Jun 4, 2021

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.

@myitcv
Copy link
Contributor Author

myitcv commented Jun 4, 2021

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

@cueckoo
Copy link

cueckoo commented Jul 3, 2021

This issue has been migrated to cue-lang/cue#1036.

For more details about CUE's migration to a new home, please see cue-lang/cue#1078.

@cueckoo cueckoo closed this as completed Jul 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FeatureRequest New feature or request Triage Requires triage/attention
Projects
None yet
Development

No branches or pull requests

3 participants