sunjay / brain

A high level programming language that compiles into the brainfuck esoteric programming language

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Arbitrary Field Access

sunjay opened this issue · comments

In order to implement arbitrary field access, you technically need to apply left-recursion which is notoriously hard in a PEG grammar. To make things easier, this was left out of the initial parser code.

Implementation Notes

Do something like what was done to support conditionals: parse everything in sequence and then nest everything together in one step.

  • Be able to access fields to an arbitrary depth: a.b, a.b.c, a.b.c.d.e, etc.
  • Fields should be properly nested so that foo.bar.spam.car is equivalent to ((foo.bar).spam).car.
  • Should be able to access fields on pretty much any valid expression (identifiers, string literals, numbers, groups, etc.)
    • Note that this does not imply fields can be any other type other than identifier