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

scala: option to use back ticks #30

Closed
carueda opened this issue Feb 12, 2018 · 1 comment
Closed

scala: option to use back ticks #30

carueda opened this issue Feb 12, 2018 · 1 comment

Comments

@carueda
Copy link
Owner

carueda commented Feb 12, 2018

Currently (0.8.4):

From:

foo-object {
  bar-baz: string
}
other-stuff: int

the generated Scala is:

case class ScalaIssue30Cfg(
  foo_object  : ScalaIssue30Cfg.FooObject,
  other_stuff : scala.Int
)
object ScalaIssue30Cfg {
  case class FooObject(
    bar_baz : java.lang.String
  )
  ...

That is, regarding the characters that would make the identifiers invalid in Scala, tscfg either removes them (foo-object becomes FooObject) or replace them with underscores (other-stuff -> other_stuff; bar-baz -> bar_baz).

So, the suggested idea here is to add an option to instead use back ticks for such translations (which should probably have been the default behavior since this was implemented):

case class ScalaIssue30Cfg(
  `foo-object`  : ScalaIssue30Cfg.`Foo-Object`,
  `other-stuff` : scala.Int
)
object ScalaIssue30Cfg {
  case class `Foo-Object`(
    `bar-baz` : java.lang.String
  )
...

Note that back sticks have already been used but only for Scala reserved words.

@carueda
Copy link
Owner Author

carueda commented Feb 12, 2018

Now, with 0.9.0:

From:

foo-object {
  bar-baz: string
  0: string
}
"other#stuff": int

and using the new --scala:bt option one gets:

case class ScalaIssue30Cfg(
  `foo-object`  : ScalaIssue30Cfg.`Foo-object`,
  `other#stuff` : scala.Int
)
object ScalaIssue30Cfg {
  case class `Foo-object`(
    `0`       : java.lang.String,
    `bar-baz` : java.lang.String
  )
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant