hydra icon indicating copy to clipboard operation
hydra copied to clipboard

Hydra-Go

Open joshsh opened this issue 2 years ago • 6 comments

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.

joshsh avatar Mar 16 '23 22:03 joshsh

Started working on this, on the branch feature-65-go.

aman-dureja avatar Apr 20 '23 07:04 aman-dureja

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" */ .

aman-dureja avatar Apr 21 '23 07:04 aman-dureja

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

aman-dureja avatar Apr 21 '23 07:04 aman-dureja

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

joshsh avatar Apr 21 '23 14:04 joshsh

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.

joshsh avatar Apr 21 '23 14:04 joshsh

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.

aman-dureja avatar Apr 22 '23 08:04 aman-dureja