Commit a47455b8 authored by Martti Käärik's avatar Martti Käärik
Browse files

Postfix chain: member access and casts in one loop, bindings on cast results.

parent 3b0c44d4
Loading
Loading
Loading
Loading
+7 −0
Changes for plugins/org.etsi.mts.tdl.common/src/org/etsi/mts/tdl/scoping/TDLScopeProvider.java: 7 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -344,6 +344,13 @@ public class TDLScopeProvider extends AbstractDeclarativeScopeProvider {
							return scope;
						}
					}
				} else if (context.eContainer() instanceof CastDataUse) {
					// bindings on a cast result (`x as T (m = v)`) address the members of the cast type
					DataType castType = ((CastDataUse) context.eContainer()).getDataType();
					if (castType instanceof StructuredDataType) {
						IScope scope = Scopes.scopeFor(((StructuredDataType) castType).allMembers());
						return scope;
					}
				} else if (context.eContainer() instanceof FunctionCall) {
//					if (((FunctionCall)context.eContainer()).getFunction().get instanceof StructuredDataInstance) {
						IScope scope = Scopes.scopeFor(((FunctionCall)context.eContainer()).getFunction().getFormalParameter());
+13 −2
Changes for plugins/org.etsi.mts.tdl.tx/src/org/etsi/mts/tdl/TDLtx.xtext: 13 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -477,10 +477,19 @@ UnaryMinusExpression returns tdl::DataUse:
    | PostfixExpression
;


PostfixExpression returns tdl::DataUse:
    DataUseWrapped
    (reduction+=MemberReference)*
    ('as' {tdl::CastDataUse.dataUse=current} dataType=[tdl::DataType|Identifier])?
    // One postfix loop for member access and casts. A single loop is also what
    // the serializer needs: with separate member-reference loops before and after `as`, a
    // CastDataUse could carry its members through either one
    (
        reduction+=MemberReference
        | ('as' {tdl::CastDataUse.dataUse=current} dataType=[tdl::DataType|Identifier]
            // Bindings on the cast result.
            ParameterBindingFragment?
          )
    )*
;

DataUseWrapped returns tdl::DataUse:
@@ -491,6 +500,8 @@ DataUseWrapped returns tdl::DataUse:
    | DynamicDataUse
	// CastDataUse is now postfix 'as Type' in PostfixExpression.
    // | CastDataUse
    // No binding fragment after the group: `(x as T)(field = 5)` was tried and made the
    // serializer's grouping parentheses indistinguishable from binding parentheses..
    | LParen DataUse RParen
;