eignnx / affix-grammar

An affix-grammar format and sentence generator.
Mozilla Public License 2.0
0 stars 0 forks source link

formalizing/expanding data-variant abbreviations #4

Closed eignnx closed 4 years ago

eignnx commented 4 years ago

I'd like to allow any subset of the name of a data-variant or data-variable to be used in place of the full name.

Example, all of these uses should be allowed:

data Gender = nonbinary | feminine | masculine | neutral

rule start
  = @Gender
  | @G
  | @Gend
  | @Gndr -- note that it's not just a substring, it's a subset
  | @nb -- nonbinary
  | @m -- masculine
  | @f -- feminine
  | @ntrl -- neutral (I don't think this is a great abbreviation, but it should be allowable)

These should be allowed as long as the abbreviations aren't ambiguous, i.e. they couldn't possibly refer to two salient identifiers.

Example of Ambiguity

data Argument = variable | variant
data Archetype = hero | villain

rule start
  = @Art -- could be any of {Argument, Archetype}
  | @Arg @Arch -- these would be acceptable abbreviations
  | @var -- could be any of {variable, variant}
  | @vbl @vnt -- these would be acceptable abbreviations
  | @via -- hilariously bad {variable, variant, villain}

Considerations

One thing to consider is that if the user introduces new data variants declarations, they may need to go back through their grammar and reevaluate every use of some of their abbreviations, but I think that's acceptable.

At this time I'm not convinced this feature should be applied to rule-references. You should still (for the time being) have to write out the full rule name.