STR-692: Enable user sugar like concrete syntax
Attachement:
- Sugar.sdf: Extend Stratego with an equal operator (a bit ambiguous, don’t care in this case)
- suger-test.str: A sample of program which use the previous grammar to exetend Stratego
- sugar-test.meta: Just call the previous grammar.This test was used to test the possibility to add a very small useless sugar in Stratego which can be plug-in strc.
> parse-stratego -i sugar-test.str | pp-aterm
…
, SDefNoArgs(
“sugar-test”
, Seq(
Call(
SVar(“eq”)
, [Build(NoAnnoList(Int(“1”))), Build(NoAnnoList(Int(“1”)))]
)
, Cong(
“eq”
, [Build(NoAnnoList(Int(“1”))), Build(NoAnnoList(Int(“1”)))]
)
)
)
…> parse-stratego -i sugar-test.str | pp-stratego -a | parse-stratego | pp-aterm
…
, SDefNoArgs(
“sugar-test”
, Seq(
Call(
SVar(“eq”)
, [Build(NoAnnoList(Int(“1”))), Build(NoAnnoList(Int(“1”)))]
)
, Call(
SVar(“eq”)
, [Build(NoAnnoList(Int(“1”))), Build(NoAnnoList(Int(“1”)))]
)
)
)
…So, at this time it is possible to do it by parse one time and print it before trying to compile the file.
Submitted on 22 January 2007 at 11:54
It’s a small test and it can’t handle all sugar of Stratego.
Issue Log
STR-692, pierron:
In the grammar the Build operator can be removed by replaceing the following rules in the grammar:StrategoTerm -> SBuild {cons("Build")} SBuild -> S {cons("FromTerm")}
So it is possible to write something like that:
main = eq(!1, !1); 1 == 1
The idea of sdf-astgen (transformers-generic-tools) can may be plug-in the stratego concrete syntax to handle a good transformation without having to hack the system.
Log in to post comments