X10
  1. X10
  2. XTENLANG-2199

Annotating ExpressionStatement causes a compiler error

    Details

    • Number of attachments :
      0

      Description

      In x10.g we have:

      Statement ::= AnnotationStatement
                      | ExpressionStatement
      
      And the rules relevant to expressions with annotations are:
      UnaryExpression ::= UnannotatedUnaryExpression
                            | Annotations UnannotatedUnaryExpression
          
      

      First, it doesn't make sense to me how the parser thinks that:

      @Ann (2+4)
      

      is an annotation on an UnannotatedUnaryExpression!

      Second, we get a parsing error for:

      interface Ann extends MethodAnnotation, ClassAnnotation, FieldAnnotation, ImportAnnotation, PackageAnnotation, TypeAnnotation, ExpressionAnnotation, StatementAnnotation {}
      class Test {
      	def m(Any)=1;
      	def test() {		
      		m(@Ann m(2));// ok
      		@Ann m(2); // todo: it should parse!
      	}
      }
      
      
      C:\cygwin\home\Yoav\test\Hello.x10:4,15-34
      Message: Syntax Error: Syntax error: Token "*" expected instead of this input
      
      Position:
      C:\cygwin\home\Yoav\test\Hello.x10:5,25-26
      Message: Syntax Error: Syntax error: Token "PackageDeclaration" expected after this input
      
      Position:
      C:\cygwin\home\Yoav\test\Hello.x10:13,16-14,17
      Message: Syntax Error: Syntax error: Token(s) inserted to complete scope: "}"
      
      Position:
      C:\cygwin\home\Yoav\test\Hello.x10:16,1-2
      Message: Syntax Error: Syntax error: Unexpected input ignored: "ERROR_TOKEN"
      

        Issue Links

          Activity

          Hide
          Yoav Zibin added a comment -

          ok, found the answer to the first question:

          PostfixExpression ::= CastExpression
          CastExpression ::= Primary
                               | ExpressionName
                               | CastExpression as Type
              
          

          (but I still don't understand why a CastExpression might not include as!)

          And the parser couldn't parse the expression:

          @Ann m(2);
          

          with these rules:

          Statement ::= ExpressionStatement
          ExpressionStatement ::= StatementExpression ;
          
          StatementExpression ::= Assignment
                                    | PreIncrementExpression
                                    | PreDecrementExpression
                                    | PostIncrementExpression
                                    | PostDecrementExpression
                                    | MethodInvocation
                                    | ClassInstanceCreationExpression
          
          
          and here I'm stuck. So the parser correctly failed to parse that expression...
          
          Expression ::= AssignmentExpression
          AssignmentExpression ::= ConditionalExpression
          ConditionalExpression ::= ConditionalOrExpression
          ConditionalOrExpression ::= ConditionalAndExpression
          ConditionalAndExpression ::= InclusiveOrExpression
          InclusiveOrExpression ::= ExclusiveOrExpression
          ExclusiveOrExpression ::= AndExpression
          AndExpression ::= EqualityExpression
          EqualityExpression ::= RelationalExpression
          RelationalExpression ::= RangeExpression
          RangeExpression ::= ShiftExpression
          ShiftExpression ::= AdditiveExpression
          AdditiveExpression ::= MultiplicativeExpression
          MultiplicativeExpression ::= UnaryExpression
          UnaryExpression ::= Annotations UnannotatedUnaryExpression
          UnannotatedUnaryExpression ::= 
          UnannotatedUnaryExpression ::= UnaryExpressionNotPlusMinus
          UnaryExpressionNotPlusMinus ::= PostfixExpression
          PostfixExpression ::= CastExpression
          CastExpression ::= Primary
          
          Show
          Yoav Zibin added a comment - ok, found the answer to the first question: PostfixExpression ::= CastExpression CastExpression ::= Primary | ExpressionName | CastExpression as Type (but I still don't understand why a CastExpression might not include as !) And the parser couldn't parse the expression: @Ann m(2); with these rules: Statement ::= ExpressionStatement ExpressionStatement ::= StatementExpression ; StatementExpression ::= Assignment | PreIncrementExpression | PreDecrementExpression | PostIncrementExpression | PostDecrementExpression | MethodInvocation | ClassInstanceCreationExpression and here I'm stuck. So the parser correctly failed to parse that expression... Expression ::= AssignmentExpression AssignmentExpression ::= ConditionalExpression ConditionalExpression ::= ConditionalOrExpression ConditionalOrExpression ::= ConditionalAndExpression ConditionalAndExpression ::= InclusiveOrExpression InclusiveOrExpression ::= ExclusiveOrExpression ExclusiveOrExpression ::= AndExpression AndExpression ::= EqualityExpression EqualityExpression ::= RelationalExpression RelationalExpression ::= RangeExpression RangeExpression ::= ShiftExpression ShiftExpression ::= AdditiveExpression AdditiveExpression ::= MultiplicativeExpression MultiplicativeExpression ::= UnaryExpression UnaryExpression ::= Annotations UnannotatedUnaryExpression UnannotatedUnaryExpression ::= UnannotatedUnaryExpression ::= UnaryExpressionNotPlusMinus UnaryExpressionNotPlusMinus ::= PostfixExpression PostfixExpression ::= CastExpression CastExpression ::= Primary
          David Grove made changes -
          Field Original Value New Value
          Fix Version/s X10 2.1.2 [ 16498 ]
          Hide
          David Grove added a comment -

          defer all non-critical 2.1.2 issues to 2.2.

          Show
          David Grove added a comment - defer all non-critical 2.1.2 issues to 2.2.
          David Grove made changes -
          Fix Version/s X10 2.2 [ 16002 ]
          Fix Version/s X10 2.1.2 [ 16498 ]
          Hide
          Igor Peshansky added a comment -

          Not a backwards-incompatible issue, and needs language design. Deferring.

          Show
          Igor Peshansky added a comment - Not a backwards-incompatible issue, and needs language design. Deferring.
          Igor Peshansky made changes -
          Fix Version/s X10 2.2.1 [ 17131 ]
          Fix Version/s X10 2.2 [ 16002 ]
          Hide
          David Grove added a comment -

          bulk defer of open issues to 2.2.2.

          Show
          David Grove added a comment - bulk defer of open issues to 2.2.2.
          David Grove made changes -
          Fix Version/s X10 2.2.2 [ 17639 ]
          Fix Version/s X10 2.2.1 [ 17131 ]
          Hide
          David Grove added a comment -

          bulk defer of issues to 2.2.3.

          Show
          David Grove added a comment - bulk defer of issues to 2.2.3.
          David Grove made changes -
          Fix Version/s X10 2.2.3 [ 18146 ]
          Fix Version/s X10 2.2.2 [ 17639 ]
          David Grove made changes -
          Fix Version/s X10 2.3 [ 17009 ]
          Fix Version/s X10 2.2.3 [ 18146 ]
          Hide
          David Grove added a comment -

          bulk defer of 2.3.0 open issues to 2.3.1.

          Show
          David Grove added a comment - bulk defer of 2.3.0 open issues to 2.3.1.
          David Grove made changes -
          Fix Version/s X10 2.3.1 [ 18657 ]
          Fix Version/s X10 2.3 [ 17009 ]
          Hide
          David Grove added a comment -

          bulk defer to 2.3.2

          Show
          David Grove added a comment - bulk defer to 2.3.2
          David Grove made changes -
          Fix Version/s X10 2.3.2 [ 19010 ]
          Fix Version/s X10 2.3.1 [ 18657 ]
          Hide
          David Grove added a comment -

          bulk defer to 2.4.1.

          Show
          David Grove added a comment - bulk defer to 2.4.1.
          David Grove made changes -
          Fix Version/s X10 2.4.1 [ 19142 ]
          Fix Version/s X10 2.3.2 [ 19010 ]
          Hide
          David Grove added a comment -

          bulk defer to 2.4.2

          Show
          David Grove added a comment - bulk defer to 2.4.2
          David Grove made changes -
          Fix Version/s X10 2.4.2 [ 19827 ]
          Fix Version/s X10 2.4.1 [ 19142 ]
          Hide
          David Grove added a comment -

          bulk defer to 2.4.3

          Show
          David Grove added a comment - bulk defer to 2.4.3
          David Grove made changes -
          Fix Version/s X10 2.4.2 [ 19827 ]
          Fix Version/s X10 2.4.3 [ 20024 ]
          Hide
          David Grove added a comment -

          bulk defer to 2.4.4

          Show
          David Grove added a comment - bulk defer to 2.4.4
          David Grove made changes -
          Fix Version/s X10 2.4.3 [ 20024 ]
          Fix Version/s X10 2.4.4 [ 20386 ]
          David Grove made changes -
          Fix Version/s X10 2.4.4 [ 20386 ]
          Fix Version/s X10 2.5.1 [ 20503 ]
          Hide
          David Grove added a comment -

          bulk defer to 2.5.2

          Show
          David Grove added a comment - bulk defer to 2.5.2
          David Grove made changes -
          Fix Version/s X10 2.5.1 [ 20503 ]
          Fix Version/s X10 2.5.2 [ 20767 ]
          David Grove made changes -
          Link This issue is duplicated by XTENLANG-1559 [ XTENLANG-1559 ]

            People

            • Assignee:
              Unassigned
              Reporter:
              Yoav Zibin
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: