Example #1
0
 private Number getNumber(CommonTree tree) {
   String text = tree.getText();
   if (text.contains(".")) {
     return Double.parseDouble(text);
   } else {
     return Integer.parseInt(text);
   }
 }
Example #2
0
 private String getLocatorName(CommonTree tree) {
   String text = tree.getText();
   if (text.endsWith("://")) {
     return text.substring(0, text.length() - 3);
   } else {
     return null;
   }
 }
Example #3
0
 private String getString(CommonTree tree) {
   return tree.getText().substring(1, tree.getText().length() - 1);
 }
Example #4
0
  // $ANTLR start "propertyExpr"
  // nu/cotentin/parsing/cotentinel/CotentinELTree.g:67:1: propertyExpr returns [ExprNode result] :
  // (id= ID (acc= accessor )? (prop= propertyExpr )? ) ;
  public final ExprNode propertyExpr() throws RecognitionException {
    ExprNode result = null;

    CommonTree id = null;
    ExprNode acc = null;

    ExprNode prop = null;

    try {
      // nu/cotentin/parsing/cotentinel/CotentinELTree.g:67:39: ( (id= ID (acc= accessor )? (prop=
      // propertyExpr )? ) )
      // nu/cotentin/parsing/cotentinel/CotentinELTree.g:68:2: (id= ID (acc= accessor )? (prop=
      // propertyExpr )? )
      {
        // nu/cotentin/parsing/cotentinel/CotentinELTree.g:68:2: (id= ID (acc= accessor )? (prop=
        // propertyExpr )? )
        // nu/cotentin/parsing/cotentinel/CotentinELTree.g:68:2: id= ID (acc= accessor )? (prop=
        // propertyExpr )?
        {
          id = (CommonTree) match(input, ID, FOLLOW_ID_in_propertyExpr246);
          if (state.failed) return result;

          // nu/cotentin/parsing/cotentinel/CotentinELTree.g:68:11: (acc= accessor )?
          int alt7 = 2;
          switch (input.LA(1)) {
            case NUMBER:
            case STRING:
              {
                alt7 = 1;
              }
              break;
          }

          switch (alt7) {
            case 1:
              // nu/cotentin/parsing/cotentinel/CotentinELTree.g:68:11: acc= accessor
              {
                pushFollow(FOLLOW_accessor_in_propertyExpr250);
                acc = accessor();

                state._fsp--;
                if (state.failed) return result;
              }
              break;
          }

          // nu/cotentin/parsing/cotentinel/CotentinELTree.g:68:26: (prop= propertyExpr )?
          int alt8 = 2;
          switch (input.LA(1)) {
            case ID:
              {
                alt8 = 1;
              }
              break;
          }

          switch (alt8) {
            case 1:
              // nu/cotentin/parsing/cotentinel/CotentinELTree.g:68:26: prop= propertyExpr
              {
                pushFollow(FOLLOW_propertyExpr_in_propertyExpr255);
                prop = propertyExpr();

                state._fsp--;
                if (state.failed) return result;
              }
              break;
          }
        }

        if (state.backtracking == 0) {
          result = new IdentifierNode(id.getText());
          ExprNode cur = result;
          if (acc != null) {
            result.getChildren().add(acc);
            cur = acc;
          }
          if (prop != null) {
            cur.getChildren().add(prop);
          }
        }
      }

    } catch (RecognitionException re) {
      reportError(re);
      recover(input, re);
    } finally {
      // do for sure before leaving
    }
    return result;
  }