Hydra-Go
A partial or even full Go implementation of Hydra is likely to be required for some of our work at LinkedIn. Start by creating a Go model and Go language constraints, then proceed to a type-level Go coder. Extend this to a bicoder if practical, and implement as much of the Hydra kernel as is required for that particular use case. The recent work on migrating the kernel to Java will likely make a Go migration simpler.
Started working on this, on the branch feature-65-go.
TODO: figure out how to represent the following productions:
newline = /* the Unicode code point U+000A */ .
unicode_char = /* an arbitrary Unicode code point except newline */ .
unicode_letter = /* a Unicode code point categorized as "Letter" */ .
unicode_digit = /* a Unicode code point categorized as "Number, decimal digit" */ .
TODO: figure out how to represent keywords:
break default func interface select
case defer go map struct
chan else goto package switch
const fallthrough if range type
continue for import return var
TODO: figure out how to represent the following productions:
newline = /* the Unicode code point U+000A */ . unicode_char = /* an arbitrary Unicode code point except newline */ . unicode_letter = /* a Unicode code point categorized as "Letter" */ . unicode_digit = /* a Unicode code point categorized as "Number, decimal digit" */ .
These lexer details are really only important if you intend to use the grammar to generate a parser and/or a serializer for Go. That is the intention of preserving all of the information in the BNF grammar, but so far we haven't tried to generate serializers (e.g. see GraphQL). That would definitely be a worthwhile thing to do for the first time (and would probably require some extension of the hydra/grammar module).
TODO: figure out how to represent keywords:
break default func interface select case defer go map struct chan else goto package switch const fallthrough if range type continue for import return var
See Hydra.Langs.Java.Language and Hydra.Langs.Java.Utils (sanitizeJavaName) for an example of how to escape names so as to avoid conflicts with keywords.
Leaving this comment as a reminder to myself: I need to set up the simplest possible test case to quickly validate that I'm doing things correctly. I think a good simple case would be to generate a simple integer variable declaration in Go, from a Hydra DSL.