Commit b8502276 authored by Miklos Magyari's avatar Miklos Magyari

OOP: fix for constant list parsing

Signed-off-by: Miklos Magyari's avatarMiklos Magyari <miklos.magyari@sigmatechnology.se>
parent 38d41edb
......@@ -1887,10 +1887,10 @@ pr_ConstList[Type type] returns[List<Definition> array]
$array = new ArrayList<Definition>();
}:
( a = pr_SingleConstDef[type] { if($a.def_const != null) { $array.add($a.def_const); } }
| b = pr_SingleClassConstDef
| b = pr_SingleClassConstDef[type] { if($b.def_const != null) { $array.add($b.def_const); } }
( pr_Comma
( a = pr_SingleConstDef[type] { if($a.def_const != null) { $array.add($a.def_const); } }
| b = pr_SingleClassConstDef
| b = pr_SingleClassConstDef[type] { if($b.def_const != null) { $array.add($b.def_const); } }
)
)*
);
......@@ -9099,18 +9099,33 @@ pr_ClassConstructorDef
)
;
pr_SingleClassConstDef
:
pr_SingleClassConstDef[Type type] returns[ Def_Const def_const]
@init {
$def_const = null;
ArrayDimensions dimensions = null;
Type tempType = $type;
Value value = null;
}:
( i = pr_Identifier
( d = pr_ArrayDef
{
if ($d.dimensions != null) {
for (int i = $d.dimensions.size() - 1; i >= 0; i--) {
tempType = new Array_Type(tempType, $d.dimensions.get(i), false);
tempType.setLocation(getLocation( $i.stop, getLastVisibleToken()));
}
}
}
)?
( a = pr_AssignmentChar
v = pr_Expression )?
v = pr_Expression { value = $v.value; } )?
)
;
{
if($i.identifier != null) {
$def_const = new Def_Const($i.identifier, tempType, value);
$def_const.setLocation(getLocation( $i.start, getLastVisibleToken()));
}
};
pr_ClassTemplateDef
@init {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment