[NO-ISSUE][GRAPHIX] Fixing definition-body offset in grammar.

Details:
- Definition body should be offset differently with and without parentheses.

Change-Id: I81c21e2029e7269d891249c9253b4ad69788a1cf
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb-graph/+/16644
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Glenn Galvizo <ggalvizo@uci.edu>
diff --git a/asterix-graphix/src/main/resources/lang-extension/lang.txt b/asterix-graphix/src/main/resources/lang-extension/lang.txt
index 5338219..99952bf 100644
--- a/asterix-graphix/src/main/resources/lang-extension/lang.txt
+++ b/asterix-graphix/src/main/resources/lang-extension/lang.txt
@@ -387,6 +387,7 @@
 {
   Pair<List<Integer>, List<List<String>>> primaryKeyFields;
   Token beginPos = null, endPos = null;
+  int positionOffset = 0;
   Expression vertexDefinitionExpr;
   ElementLabel vertexLabel;
 }
@@ -400,11 +401,12 @@
     createNewScope();
   }
   (
-    vertexDefinitionExpr = ViewBody() { endPos = token; }
+    vertexDefinitionExpr = ViewBody() { endPos = token; positionOffset++; }
     | <LEFTPAREN> { beginPos = token; } vertexDefinitionExpr = ViewBody() { endPos = token; } <RIGHTPAREN>
   )
   {
-    String vDef = extractFragment(beginPos.beginLine, beginPos.beginColumn + 1, endPos.endLine, endPos.endColumn + 1);
+    String vDef = extractFragment(beginPos.beginLine, beginPos.beginColumn + positionOffset, endPos.endLine,
+      endPos.endColumn + 1);
     removeCurrentScope();
     GraphConstructor.VertexConstructor vertexConstructor = new GraphConstructor.VertexConstructor(vertexLabel,
       primaryKeyFields.second, primaryKeyFields.first, vertexDefinitionExpr, vDef);
@@ -431,6 +433,7 @@
   Pair<List<Integer>, List<List<String>>> keyFields;
   Token beginPos = null, endPos = null;
   Expression edgeDefinitionExpr = null;
+  int positionOffset = 0;
 
   List<Integer> destinationKeySourceIndicators = null;
   List<Integer> sourceKeySourceIndicators = null;
@@ -457,7 +460,7 @@
       createNewScope();
     }
     (
-      edgeDefinitionExpr = SelectExpression(true) { endPos = token; }
+      edgeDefinitionExpr = SelectExpression(true) { endPos = token; positionOffset++;  }
       | <LEFTPAREN> { beginPos = token; } edgeDefinitionExpr = SelectExpression(true) { endPos = token; } <RIGHTPAREN>
     )
   )
@@ -476,7 +479,8 @@
 
     String eDef = null;
     if (edgeDefinitionExpr != null) {
-      eDef = extractFragment(beginPos.beginLine, beginPos.beginColumn + 1, endPos.endLine, endPos.endColumn + 1);
+      eDef = extractFragment(beginPos.beginLine, beginPos.beginColumn + positionOffset, endPos.endLine,
+        endPos.endColumn + 1);
       removeCurrentScope();
     }