The iter-n and iter-n-sep patterns in SDF cannot be imploded by implode-asfix.
Consider the following definition niter-test.sdf :
—-
module niter-test
exports
sorts Foo Bar

lexical syntax
[ 13
] -> LAYOUT
“foo” -> Foo

context-free syntax
“(” {Foo “,”}2+ “)” -> Bar {cons(“TwoOrMore”)}
“(” {Foo “,”}+ “)” -> Bar {cons(“OneOrMore”)}

context-free restrictions
LAYOUT? -/- [ 13
]

context-free priorities
“(” {Foo “,”}2+ “)” -> Bar
> “(” {Foo “,”}+ “)” -> Bar
—-

and an example file: test.nit
—-
(foo, foo)
—-

packing and table-generation goes fine, but when running
$ sglri -i test.nit -p niter-test.tbl | pp-aterm
or
$ sglr -i test.nit -p niter-test.tbl -2 | implode-asfix |
pp-aterm

the following output is produced:
—-
TwoOrMore(
appl(
prod(
[ cf(sort(“Foo”))
, cf(opt(layout))
, lit(“,”)
, cf(opt(layout))
, cf(iter-sep(sort(“Foo”), lit(“,”)))
]
, cf(iter-sep-n(sort(“Foo”), lit(“,”), 2))
, no-attrs
)
, [“foo”, None, lit(“,”), Some(" "), [“foo”]]
)
)
—-

When the 2+ production is left out, all parsing into the ‘OneOrMore’ constructor goes just fine. I also tried an 1+ pattern, but this is desugared into a normal + in some earlier stage.
And, as said: the above also fails for the iter-n (w/o separator)

Submitted on 21 March 2004 at 11:51

On 21 March 2004 at 14:55 Jira commented:

STR-26, adam:
In asfix-tools/src/implode/implode-asfix.str iter-n and iter-sep-n are indeed left out, except for one occurrence each:

implode-lexical =

//<+ ?appl(prod(,varsym(cf(iter-n())),),); !meta-listvar()
//<+ ?appl(prod(,varsym(cf(iter-sep-n(,))),),_); !meta-listvar()

Both lines were introduced 18 months ago by Eelco (lines 237-238, see:
http://cvs.cs.uu.nl/cgi-bin/cvsweb.cgi/XT-OLD/asfix-tools/src/implode/implode-asfix.r?annotate=1.13 ), but they have always been commented, I don’t know the reason for that.


On 26 March 2004 at 12:51 Jira commented:

STR-26, martin:
iter-n’ nor ‘iter-sep-n’ will no longer be available in future versions of SDF. It is not worth the effort to fix it in implode-asfix. Please avoid iter-n and iter-sep-n.

Log in to post comments