marijnh/acorn — pull request #137 by xiemaisi (2014-10-09 08:21:46+00:00)
Title: Add option for representing parenthesized expressions in the AST.

Traditionally, most AST formats don't explicitly represent parenthesized expressions, and the SpiderMonkey format is no exception. Nevertheless, for some applications it is convenient to do so, and unlike other bits of concrete syntax (like whitespace or comments), parentheses fit naturally into the structure of the AST.

I've maintained a patch to support a representation of parenthesized expressions for a while, but I think this could be useful to others as well, hence this PR.

The proposal is to add a flag `preserveParens` to Acorn. If set to `true`, parenthesized expressions will be represented in the AST by (non-standard) `ParenthesizedExpression` nodes:

```java
interface ParenthesizedExpression <: Expression {
type: "ParenthesizedExpression";
expression: Expression;
}
```

If the flag is set to `false`, which is the default, nothing changes.