What is cons? Any explaination?
Hi there,
I am looking at SDF for creating a new DSL like mobl. I have gone through all the documentation of SDF but haven’t found any docs explaining these kind of keywords.
Here is the cons used in the syntax:
"configuration" Setting* -> Start {cons("Configuration")}
Thank you in advance.
Submitted by Bhushan Firake on 19 June 2014 at 09:58
Bhushan
Issue Log
Hi,
make sure to have a look at the documentation of SDF3.
"configuration" Setting* -> Start {cons("Configuration")}
is old SDF2 syntax. In SDF3, you should write this instead:
Start.Configuration = "configuration" Setting*
Essentially, the
cons
keyword specifies the constructor used in the abstract syntax.
Hi Guido,
As far as I know, you have just made my statement to productive form. Previously, it was in reductive form.
Thank you for the explanation of
cons
. How and where will it be used as a constructor?
Constructors are used in abstract syntax trees. Given a SDF grammar
Exp.Add = Exp "+" Exp {left} Exp.Int = INT Exp.Var = ID
parsing
3+x
will result inAdd(Int("3"), Var("x"))
.
Log in to post comments