eignnx / affix-grammar

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

allow use of parameter names in rule body #16

Open eignnx opened 4 years ago

eignnx commented 4 years ago

basically this is annoying to have to do:

rule subj.Number.Gender =
  .Number1.Gender1 -> pronoun.Number1.Person.Gender1

when we wanna forward some parameters, why not just pretend they already exist and have been given names based on the rule signature:

rule subj.Number1.Gender1 = pronoun.Number1.Person.Gender1

Drawbacks

this could get confusing because i think ppl's default is to use an unnumbered variable both:

  1. when declaring the parameter type in the rule signature, and
  2. when attempting to introduce a fresh variable in order to call a rule.

example:

rule subj.Number.Gender = pronoun.Number.Person.Gender

does the previous example pass two fresh variable instantiations to pronoun? or does it use the parameters passed into subj?

that's ambiguous and there needs to be one of:

eignnx commented 4 years ago

ok well with respect to that ambiguous example:

rule subj.Number.Gender = pronoun.Number.Person.Gender

the most common behavior would be to instantiate a new variable if it's unnamed, so i guess the behavior of that code outta be to instantiate new variables.

so then some special syntax is needed to do what i wanted to do originally.

another concern to be accounted for is: what if you have two parameters of the same type? like:

rule string.Bit.Bit = substring.Bit@1.Bit@2

Proposed Syntax

rule something.Number.Gender.Gender = something_else.Number#1.Person.Gender#1.Gender#2
rule something.Number.Gender.Gender = something_else.#1.Person.#2.#3
-- now we've lost all self-documentation of types, so i'm concerned w this sol'n.
rule something.Number.Gender.Gender = something_else.Number@1.Person.Gender@2.Gender@3
rule something.Number.Gender.Gender = something_else.Number::1.Person.Gender::2.Gender::3
rule something.Number.Gender.Gender = something_else.Number::1.Person.Gender::2.Gender::3
rule something.Number.Gender.Gender = something_else.Number^1.Person.Gender^2.Gender^3
rule something.Number.Gender.Gender2 = something_else.^Number.Person.^Gender.^Gender2
-- here the number is only required if the system can't tell which `Gender` is being referred to.
-- the sigil is always required tho.
rule something.Number.Gender.Gender2 = something_else.@Number.Person.@Gender.@Gender2
rule something.Number.Gender.Gender2 = something_else.#Number.Person.#Gender.#Gender2
rule something.Number.Gender.Gender2 = something_else.::Number.Person.::Gender.::Gender2
rule something.Number.Gender.Gender2 = something_else.%Number.Person.%Gender.%Gender2
rule something.Number.Gender.Gender2 = something_else.*Number.Person.*Gender.*Gender2
rule something.Number.Gender.Gender2 = something_else.~Number.Person.~Gender.~Gender2
rule something.Number.Gender.Gender2 = something_else.$Number.Person.$Gender.$Gender2
rule something.Number.Gender.Gender2 = something_else.&Number.Person.&Gender.&Gender2

maybe you use some sigil to both:

  1. indicate the variable should be taken from the parameters, and
  2. the number of repetitions of the sigil indicates the relative position of the variable to be used (2 repetitions means use the second variable with given name)
rule something.Number.Gender.Gender = something_else.Number`.Person.Gender`.Gender``
rule something.Number.Gender.Gender = something_else.Number!.Person.Gender!.Gender!!
rule something.Number.Gender.Gender = something_else.Number#.Person.Gender#.Gender##
rule something.Number.Gender.Gender = something_else.^Number.Person.^Gender.^^Gender
rule something.Number.Gender.Gender = something_else.@Number.Person.@Gender.@@Gender
rule something.Number.Gender.Gender = something_else.#Number.Person.#Gender.##Gender
rule something.Number.Gender.Gender = something_else.*Number.Person.*Gender.**Gender
rule something.Number.Gender.Gender = something_else.%Number.Person.%Gender.%%Gender
rule something.Number.Gender.Gender = something_else.&Number.Person.&Gender.&&Gender
eignnx commented 4 years ago

this will be resolved by #17