Commit 273423be authored by Miklos Magyari's avatar Miklos Magyari
Browse files

OOP: add chained function refs to AST


Signed-off-by: Miklos Magyari's avatarMiklos Magyari <miklos.magyari@sigmatechnology.se>
parent d8b1c190
...@@ -164,6 +164,7 @@ public final class Unknown_Instance_Statement extends Statement { ...@@ -164,6 +164,7 @@ public final class Unknown_Instance_Statement extends Statement {
realStatement.setFullNameParent(this); realStatement.setFullNameParent(this);
realStatement.setLocation(location); realStatement.setLocation(location);
realStatement.setMyStatementBlock(getMyStatementBlock(), statementIndex); realStatement.setMyStatementBlock(getMyStatementBlock(), statementIndex);
realStatement.check(timestamp);
} }
} else { } else {
reference.getLocation().reportSemanticError(MessageFormat.format(FUNCTIONORALTSTEPEXPECTED, assignment.getFullName())); reference.getLocation().reportSemanticError(MessageFormat.format(FUNCTIONORALTSTEPEXPECTED, assignment.getFullName()));
......
...@@ -6631,31 +6631,64 @@ pr_USI returns[List<String> uid_elements] ...@@ -6631,31 +6631,64 @@ pr_USI returns[List<String> uid_elements]
pr_RParen pr_RParen
); );
pr_ReferencedValue returns[Value value, Reference ref] pr_ReferencedValue returns[Value value]
@init { @init {
$value = null; $value = null;
$ref = null;
Reference temporalReference = null; Reference temporalReference = null;
ParsedActualParameters parameters = null;
ParameterisedSubReference parSubReference = null;
List<ISubReference> subReferences = null; List<ISubReference> subReferences = null;
Token start = null;
Token stop = null;
}: }:
( (
( (
pr_Identifier DOT fi = pr_Identifier LPAREN pr_FunctionActualParList? RPAREN pr_ExtendedFieldReference? { i1 = pr_Identifier { start = $i1.start; }
$ref = new Reference($fi.identifier); DOT
fi = pr_Identifier
lp = pr_LParen
(par = pr_FunctionActualParList {
parameters = $par.parsedParameters;
parameters.setLocation(getLocation($par.start, $par.stop));
})?
rp = pr_RParen
{
if (parameters == null) {
parameters = new ParsedActualParameters();
parameters.setLocation(getLocation($lp.start, $rp.stop));
}
stop = $rp.stop;
} }
| t = pr_ValueReference { temporalReference = $t.reference; } (fe = pr_ExtendedFieldReference { subReferences = $fe.subReferences; stop = $fe.stop; } )?
{
temporalReference = new Reference(null);
temporalReference.setLocation(getLocation($i1.start, $i1.stop));
FieldSubReference subReference = new FieldSubReference($i1.identifier);
subReference.setLocation($i1.identifier.getLocation());
temporalReference.addSubReference(subReference);
}
| t = pr_ValueReference {
temporalReference = $t.reference;
start = $t.start;
stop = $t.stop;
}
( e = pr_ExtendedFieldReference { subReferences = $e.subReferences; stop = $e.stop; } )?
| pr_Identifier DOT i = pr_PredefOrIdentifier pr_ExtendedFieldReference? // { temporalReference = new Reference($i.identifier); } | pr_Identifier DOT i = pr_PredefOrIdentifier pr_ExtendedFieldReference? // { temporalReference = new Reference($i.identifier); }
| pr_Identifier DOT pr_ObjectIdentifierValue DOT pr_Identifier pr_ExtendedFieldReference? | pr_Identifier DOT pr_ObjectIdentifierValue DOT pr_Identifier pr_ExtendedFieldReference?
) )
( e = pr_ExtendedFieldReference { subReferences = $e.subReferences; } )?
) )
{ {
if(temporalReference != null) { if(temporalReference != null) {
if(subReferences != null) { if(subReferences != null) {
if (parameters != null) {
parSubReference = new ParameterisedSubReference($fi.identifier, parameters);
parSubReference.setLocation(getLocation($lp.stop, $rp.start));
temporalReference.addSubReference(parSubReference);
}
for(ISubReference subReference: subReferences) { for(ISubReference subReference: subReferences) {
temporalReference.addSubReference(subReference); temporalReference.addSubReference(subReference);
} }
temporalReference.setLocation(getLocation( $t.start, $e.stop == null ? $t.stop : $e.stop)); temporalReference.setLocation(getLocation( start, stop ));
} }
if(subReferences == null && temporalReference.getModuleIdentifier() == null && temporalReference.getSubreferences().size() == 1) { if(subReferences == null && temporalReference.getModuleIdentifier() == null && temporalReference.getSubreferences().size() == 1) {
...@@ -6663,7 +6696,7 @@ pr_ReferencedValue returns[Value value, Reference ref] ...@@ -6663,7 +6696,7 @@ pr_ReferencedValue returns[Value value, Reference ref]
} else { } else {
$value = new Referenced_Value(temporalReference); $value = new Referenced_Value(temporalReference);
} }
$value.setLocation(getLocation( $t.start, $e.stop == null ? $t.stop : $e.stop)); $value.setLocation(getLocation( start, $e.stop == null ? $t.stop : $e.stop));
} }
}; };
...@@ -7068,7 +7101,13 @@ pr_BehaviourStatements returns[Statement statement] ...@@ -7068,7 +7101,13 @@ pr_BehaviourStatements returns[Statement statement]
| pr_LParen // this is a syntactically erroneous state only used to report better error messages | pr_LParen // this is a syntactically erroneous state only used to report better error messages
) )
) )
| pr_ReferencedValue | v2 = pr_ReferencedValue {
if ($v2.value instanceof Referenced_Value) {
Referenced_Value rv = (Referenced_Value)$v2.value;
$statement = new Unknown_Instance_Statement(rv.getReference());
$statement.setLocation(getLocation( $v2.start, $v2.stop));
}
}
| BREAK | BREAK
{ $statement = new Break_Statement(); { $statement = new Break_Statement();
$statement.setLocation(getLocation( $BREAK)); $statement.setLocation(getLocation( $BREAK));
......
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