| Java-like dot notation [message #490016] |
Tue, 06 October 2009 17:28  |
Eclipse User |
|
|
|
Hi everyone,
I'm trying to implement a java-like syntax for accessing class members. Namely,
class type1{
int a = 1;
}
class type2{
type1 aType1;
}
class type3{
type2 aType2;
int b = aType2.aType1.a;
}
should work, to infinite depth.
I've done some scoping that's similar, but I'm having some trouble putting it together with the grammar rules.
I'm using the rule
Dotted_field
: lhField=[Class_var] ('.' rhs=Dotted_field)?
;
Does this work when there are no spaces around the dot? It doesn't seem to.
Then I'm using scoping to restrict class_var to choices within scope, either the vars of the current class or the type of the previous part of the dotted list.
I'd appreciate any feedback or pointers.
|
|
|