A test project can be found at: https://github.com/arian/spoofax-parens-bug
Related by in my own project: https://github.com/arian/metac/issues/25

Consider the program:

(1 + 2) * 3

This can be parsed with SDF3 by:

module parens-test

imports
  Common

context-free start-symbols

  Expr

context-free syntax

  Expr = <(<Expr>)> {bracket}

  Expr.Plus = <<Expr> + <Expr>> {left}

  Expr.Mult = <<Expr> * <Expr>> {left}

  Expr.Num = INT

context-free priorities
  { left: Expr.Mult } >
  { left: Expr.Plus }

The AST will look as follows, which is expected:

Mult(Plus(Num("1"), Num("2")), Num("2"))

However when running the pp-debug rule on this AST, the result is:

1 + 2 * 3

Which has not same meaning as the original expression.

pp-parens-test-string runs parenthesize-parens-test from include/parens-test-parenethesize, but that rule is just id, so does not add parenthesis at the right AST nodes.

Submitted by Arian on 23 December 2015 at 12:39

On 23 December 2015 at 12:44 Arian commented:

Looking at the build logs, this seems to be a problem:

sdf2parenthesize:
 [trycatch] Caught exception: required attribute nativepath not set

On 23 December 2015 at 13:56 Arian commented:

I think it’s broken since https://github.com/metaborg/strategoxt/commit/551e0d9bfabc8842c3b023a0d4605ca3ca09d86a

<arg value="--nativepath" />
<arg value="" />

Should be added to https://github.com/metaborg/spoofax/blob/new-spoofax-plugin/org.metaborg.spoofax.meta.core/src/main/resources/org/metaborg/spoofax/meta/core/build.xml

But instead of an empty value, it should be the location of sdf2table

Or maybe the <attribute name="nativepath" /> is not be necessary in https://github.com/metaborg/strategoxt/blob/new-spoofax-plugin/strategoxt/ant-contrib/org/strategoxt/antcontrib/strategoxt-antlib.xml for sdf2parenthesize.


On 23 December 2015 at 14:39 Gabriël Konat commented:

Nice catch, we don’t use the parenthesizer often so we didn’t notice it was broken. I’ll fix it in the ant build and new build system that I am integrating.


On 4 January 2016 at 11:05 Gabriël Konat commented:

Fixed with the new build system


On 4 January 2016 at 11:05 Gabriël Konat closed this issue.

Log in to post comments