ivanakcheurov / desh.net

Parser, engine and tools for desh language in .net
MIT License
2 stars 0 forks source link

Implement inline parameters for operators #8

Open ivanakcheurov opened 5 years ago

ivanakcheurov commented 5 years ago

Instead of

age:
  - 0: new_born
  - between: [1, 4]
    decide: baby
  - between: [5, 12]
    decide: kid
  - between: [13, 19]
    decide: teen
  - else: adult

allow:

age:
  - 0: new_born
  - between 1 and 4: baby
  - between 5 and 12: kid
  - between 13 and 19: teen
  - else: adult

Possible solutions:

ivanakcheurov commented 5 years ago

Describing rules using a span range of values is a pretty common task. There should be a recommended standard way of doing it. Ideas how the ranges could look (in addition to the enumeration [2, 3, 5]: DECISION).

age:
  - 0: new_born
  - 1-4: baby
  - 5-12: kid
  - 13-19: teen
  - else: adult
age:
  - 0: new_born
  - 1...4: baby
  - 5...12: kid
  - 13...19: teen
  - else: adult
age:
  - 0: new_born
  - 1 up to 4: baby
  - 5 up to 12: kid
  - 13 up to 19: teen
  - else: adult
age:
  - 0: new_born
  - 1 through 4: baby
  - 5 through 12: kid
  - 13 through 19: teen
  - else: adult

Could also be a mix of enumeration and a span: [1, 2, 5, 7-20]: DECISION