From 1f1d0b41ac545150ab544b1f504e26d78fc53af0 Mon Sep 17 00:00:00 2001
From: Botond Baranyi <botond.baranyi@ericsson.com>
Date: Mon, 21 Jan 2019 13:57:37 +0100
Subject: [PATCH] Fixed port.setencode rule to allow subreferences

Change-Id: If311080c40a9c740ee8c53b4982e11fb8d6d66b1
Signed-off-by: Botond Baranyi <botond.baranyi@ericsson.com>
---
 compiler2/ttcn3/compiler.l |  2 +-
 compiler2/ttcn3/compiler.y | 28 +++++++++++++++++-----------
 2 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/compiler2/ttcn3/compiler.l b/compiler2/ttcn3/compiler.l
index a61697e9b..612b8e2be 100644
--- a/compiler2/ttcn3/compiler.l
+++ b/compiler2/ttcn3/compiler.l
@@ -619,7 +619,7 @@ oct2str		RETURN(oct2strKeyword);
 regexp		RETURN(regexpKeyword);
 replace		RETURN(replaceKeyword);
 rnd			RETURN(rndKeyword);
-setencode RETURN(setencodeKeyword);
+setencode RETURN_DOT(SetencodeKeyword);
 sizeof		RETURN(sizeofKeyword);
 str2bit		RETURN(str2bitKeyword);
 str2float	RETURN(str2floatKeyword);
diff --git a/compiler2/ttcn3/compiler.y b/compiler2/ttcn3/compiler.y
index 4f4b8effe..373395f49 100644
--- a/compiler2/ttcn3/compiler.y
+++ b/compiler2/ttcn3/compiler.y
@@ -846,6 +846,7 @@ static const string anyname("anytype");
 %token DotStopKeyword
 %token DotTimeoutKeyword
 %token DotTriggerOpKeyword
+%token DotSetencodeKeyword
 
 /* Predefined function identifiers */
 
@@ -889,7 +890,7 @@ static const string anyname("anytype");
 %token replaceKeyword
 %token rndKeyword
 %token testcasenameKeyword
-%token setencodeKeyword
+%token SetencodeKeyword
 %token sizeofKeyword
 %token str2floatKeyword
 %token str2intKeyword
@@ -8992,32 +8993,37 @@ SetstateStatement:
   }
 
 SetencodeStatement:
-  IDentifier '.' setencodeKeyword '(' Type ',' SingleExpression ')'
+  Reference DotSetencodeKeyword '(' Type ',' SingleExpression ')'
   {
-    delete $1;
-    delete $5;
-    delete $7;
+    if ($1.is_ref) {
+      delete $1.ref;
+    }
+    else {
+      delete $1.id;
+    }
+    delete $4;
+    delete $6;
     Location loc(infile, @$);
-    loc.error("'Port.setencode' is not currently supported.");
+    loc.error("'<port>.setencode' is not currently supported.");
     $$ = new Statement(Statement::S_ERROR);
     $$->set_location(infile, @$);
   }
-| AllKeyword PortKeyword '.' setencodeKeyword '(' Type ',' SingleExpression ')'
+| AllKeyword PortKeyword DotSetencodeKeyword '(' Type ',' SingleExpression ')'
   {
-    delete $6;
-    delete $8;
+    delete $5;
+    delete $7;
     Location loc(infile, @$);
     loc.error("'all port.setencode' is not currently supported.");
     $$ = new Statement(Statement::S_ERROR);
     $$->set_location(infile, @$);
   }
-| SelfKeyword '.' setencodeKeyword '(' Type ',' SingleExpression ')'
+| SelfKeyword DotSetencodeKeyword '(' Type ',' SingleExpression ')'
   {
     if (legacy_codec_handling) {
       Location loc(infile, @$);
       loc.error("'setencode' is not allowed when using legacy codec handling");
     }
-    $$ = new Statement(Statement::S_SETENCODE, $5, $7);
+    $$ = new Statement(Statement::S_SETENCODE, $4, $6);
     $$->set_location(infile, @$);
   }
 ;
-- 
GitLab