Skip to content

sealed classes instead of multiple nullable values?! #178

@andretietz

Description

@andretietz

Hey during using this awesome library, I noticed a thing that bugs me a bit.

a parser rule that has multiple options

document: rule EOF;
rule
  : OPTIONA
  | OPTIONB;

generates into:

val rule = document.rule()
rule.getOptiona() // nullable
rule.getOptionb() // nullable

I would very much prefer if that generates into:

sealed class Rule {
   data class Optiona(...) : Rule
   data class Optionb(...) : Rule
}

Would that be possible?

Can you hint me to the generation part where this part happening, may be I take a look myself?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions