Non-left-recursive PEG grammar for an “expression”
It's either a simple identifier (like cow ) something surrounded by brackets ( (...) ) something that looks like a method call ( ...(...) ) or something that looks like a member access ( thing.member ): def expr = identifier | "(" ~> expr <~ ")" | expr ~ ("(" ~> expr <~ ")") | expr ~ "." ~ identifier It's given in Scala Parser Combinator syntax, but it should be pretty straightforward to understand. It's similar to how expressions end up looking in many programming languages (hence the name expr ) However, as it stands, it is left-recursive and causes my nice PEG parser to explode. I have not