|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
Fwd: Re: nested lists in SableCC 3
I have the following grammar
object_field
=
Abstract Syntax Tree
object_field =
but the parser complains with this message
java.lang.RuntimeException:
[138,93] object_field_name must be one of the elements on the left side of the
arrow or is already refered to in this alternative
What do you think is wrong here ?
Thank very much you for your help !
Federico Wiecko MSc Student, LSIS, Luxembourg University
Hi Federico,
--- Ехжы дроеп? Явюедк пв п.о хюрб тражрюиб хнигчи! http://www.pochta.ru/partner/ ----- End forwarded message ----- --- еУФШ ДПНЕО? ъБЧЕДЙ ОБ О.Н УЧПА РПЮФПЧХА УМХЦВХ! http://www.pochta.ru/partner/ _______________________________________________ SableCC-Discussion mailing list SableCC-Discussion@... http://lists.sablecc.org/listinfo/sablecc-discussion |
||
|
|
Re: Fwd: Re: nested lists in SableCC 3
Hi Federico,
In your parsing grammar, you define an object field as an object with many field names. I think that this is the source of your problem (at the philosophical level). Of course, the immediate technical problem is that SableCC is detecting an incoherency in your transformations. You transform every object_field_name into a list of names and a type. That's fine. You also try to transform a CST object which is composed of a list of object_field_name into an AST object which is composed of a list of name and a single type. Of course, SableCC is complaining, as every object_field_name has its own type. You are trying to replace a whole list of types by a single type; SableCC does not do this kind of transformation. SableCC's error message is less than clear, I admit (I didn't write this code). I promise that SableCC 4 will have clearer messages. A "technical" (yet wrong) solution to your problem is to keep a list of types: Productions ... {object} ... {->New object_field.object(..., [object_field_name.type])} ... Abstract Syntax Tree ... {object} name+ type+ ... But this is probably not what you want at the philosophical (i.e. semantic) level. I'll let you find the good solution as an exercise. Have fun! Etienne fedewi wrote :
-- Etienne M. Gagnon, Ph.D. SableCC: http://sablecc.org SableVM: http://sablevm.org _______________________________________________ SableCC-Discussion mailing list SableCC-Discussion@... http://lists.sablecc.org/listinfo/sablecc-discussion |
||
|
|
Re: Fwd: Re: nested lists in SableCC 3
Hi Etienne
I have read your answer many times but I am still having problems with this.
Why did
you say that defining an object with many field names in this case is
incorrectly at the philosophical level ?
I think I understand what you mean
in your email but I still need a way to match from
Thank you very much for your help and patience.
Federico Wiecko
.-
--- еУФШ ДПНЕО? ъБЧЕДЙ ОБ О.Н УЧПА РПЮФПЧХА УМХЦВХ! http://www.pochta.ru/partner/ _______________________________________________ SableCC-Discussion mailing list SableCC-Discussion@... http://lists.sablecc.org/listinfo/sablecc-discussion |
||
|
|
Re: Fwd: Re: nested lists in SableCC 3Hi Federico,
You really want an AST that looks similarly to: objects = declaration+; declaration = name+ type; This will keep the two levels of list that you need for keeping the relation between names and types. Have fun, Etienne fedewi wrote: > > In my languaje I want to permit expressions like this: > > object obj1, obj2,obj3 : type; > obj4, obj5, obj6 : type2; > > where object is a reserved word. > > I think I understand what you mean in your email but I still need a > way to match from > [ ([object_field_name.name], object_field_name.type ) ] ---> [ > ([names], type)] > Etienne M. Gagnon, Ph.D. SableCC: http://sablecc.org SableVM: http://sablevm.org _______________________________________________ SableCC-Discussion mailing list SableCC-Discussion@... http://lists.sablecc.org/listinfo/sablecc-discussion |
||
|
|
How to get line#?Hi guys, I had transformed my CST to AST. but for most situations, I did not keep Tokens in the AST, for example, ... exp = {l_value} l_value | {eq} [lhs]:exp [rhs]:exp | {lt} [lhs]:exp [rhs]:exp | {gt} [lhs]:exp [rhs]:exp ... however, when traversing the AST by extends the DepthFirstAdapter, I can not get the line# of an exp. How to solve it? -- Dehua (Andy) Zhang Sable Research Group, McGill University Montréal, Québec, Canada http://www.cs.mcgill.ca/~dzhang25 _______________________________________________ SableCC-Discussion mailing list SableCC-Discussion@... http://lists.sablecc.org/listinfo/sablecc-discussion |
| Free Forum Powered by Nabble | Forum Help |