PEG.js Left Recursion

Sometimes it would be really easy to represent a rule using a Left-Recursive rule. For example:

    = object:MemberExpression '.' property:Identifier {
        return memberExpression(object, property, false);

Unfortunately PEG.js doesn't do LR grammars but there's actually a rather elegant solution when you rethink the problem:

    = object:Identifier properties:MemberExpressionProperty+ {
        return properties.reduce(function (o, p) {
            return memberExpression(o, p, false);
        }, object);

        = '.' property:Identifier {
          return property;

Neat, huh?