Пример #1
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;
  }
Пример #2
0
  // $ANTLR start "expr1"
  // nu/cotentin/parsing/cotentinel/CotentinELTree.g:42:1: expr1 returns [ExprNode result] : (left=
  // atom (op= op2 right= atom )* ) ;
  public final ExprNode expr1() throws RecognitionException {
    ExprNode result = null;

    ExprNode left = null;

    ExprNode op = null;

    ExprNode right = null;

    try {
      // nu/cotentin/parsing/cotentinel/CotentinELTree.g:42:32: ( (left= atom (op= op2 right= atom
      // )* ) )
      // nu/cotentin/parsing/cotentinel/CotentinELTree.g:43:2: (left= atom (op= op2 right= atom )* )
      {
        // nu/cotentin/parsing/cotentinel/CotentinELTree.g:43:2: (left= atom (op= op2 right= atom )*
        // )
        // nu/cotentin/parsing/cotentinel/CotentinELTree.g:43:2: left= atom (op= op2 right= atom )*
        {
          pushFollow(FOLLOW_atom_in_expr1106);
          left = atom();

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

          if (state.backtracking == 0) {
            result = left;
          }

          // nu/cotentin/parsing/cotentinel/CotentinELTree.g:43:30: (op= op2 right= atom )*
          loop2:
          do {
            int alt2 = 2;
            switch (input.LA(1)) {
              case OP_ADD:
              case OP_SUB:
                {
                  alt2 = 1;
                }
                break;
            }

            switch (alt2) {
              case 1:
                // nu/cotentin/parsing/cotentinel/CotentinELTree.g:43:31: op= op2 right= atom
                {
                  pushFollow(FOLLOW_op2_in_expr1113);
                  op = op2();

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

                  pushFollow(FOLLOW_atom_in_expr1117);
                  right = atom();

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

                  if (state.backtracking == 0) {
                    op.getChildren().add(result);
                    op.getChildren().add(right);
                    result = op;
                  }
                }
                break;

              default:
                break loop2;
            }
          } while (true);
        }
      }

    } catch (RecognitionException re) {
      reportError(re);
      recover(input, re);
    } finally {
      // do for sure before leaving
    }
    return result;
  }
Пример #3
0
  // $ANTLR start "objExpr"
  // nu/cotentin/parsing/cotentinel/CotentinELTree.g:56:1: objExpr returns [ExprNode result] : (
  // (loc= LOCATOR )? prop= propertyExpr ) ;
  public final ExprNode objExpr() throws RecognitionException {
    ExprNode result = null;

    CommonTree loc = null;
    ExprNode prop = null;

    try {
      // nu/cotentin/parsing/cotentinel/CotentinELTree.g:56:34: ( ( (loc= LOCATOR )? prop=
      // propertyExpr ) )
      // nu/cotentin/parsing/cotentinel/CotentinELTree.g:57:2: ( (loc= LOCATOR )? prop= propertyExpr
      // )
      {
        // nu/cotentin/parsing/cotentinel/CotentinELTree.g:57:2: ( (loc= LOCATOR )? prop=
        // propertyExpr )
        // nu/cotentin/parsing/cotentinel/CotentinELTree.g:57:2: (loc= LOCATOR )? prop= propertyExpr
        {
          // nu/cotentin/parsing/cotentinel/CotentinELTree.g:57:5: (loc= LOCATOR )?
          int alt6 = 2;
          switch (input.LA(1)) {
            case LOCATOR:
              {
                alt6 = 1;
              }
              break;
          }

          switch (alt6) {
            case 1:
              // nu/cotentin/parsing/cotentinel/CotentinELTree.g:57:5: loc= LOCATOR
              {
                loc = (CommonTree) match(input, LOCATOR, FOLLOW_LOCATOR_in_objExpr223);
                if (state.failed) return result;
              }
              break;
          }

          pushFollow(FOLLOW_propertyExpr_in_objExpr228);
          prop = propertyExpr();

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

        if (state.backtracking == 0) {
          result = prop;
          if (loc != null) {
            result = new ContextNode();
            result.getChildren().add(prop);
          } else {
            result = prop;
          }
        }
      }

    } catch (RecognitionException re) {
      reportError(re);
      recover(input, re);
    } finally {
      // do for sure before leaving
    }
    return result;
  }
Пример #4
0
  // $ANTLR start "expr"
  // nu/cotentin/parsing/cotentinel/CotentinELTree.g:39:1: expr returns [ExprNode result] : (left=
  // expr1 (op= op1 right= expr1 )* ) ;
  public final ExprNode expr() throws RecognitionException {
    ExprNode result = null;

    ExprNode left = null;

    ExprNode op = null;

    ExprNode right = null;

    try {
      // nu/cotentin/parsing/cotentinel/CotentinELTree.g:39:31: ( (left= expr1 (op= op1 right= expr1
      // )* ) )
      // nu/cotentin/parsing/cotentinel/CotentinELTree.g:40:2: (left= expr1 (op= op1 right= expr1 )*
      // )
      {
        // nu/cotentin/parsing/cotentinel/CotentinELTree.g:40:2: (left= expr1 (op= op1 right= expr1
        // )* )
        // nu/cotentin/parsing/cotentinel/CotentinELTree.g:40:2: left= expr1 (op= op1 right= expr1
        // )*
        {
          pushFollow(FOLLOW_expr1_in_expr76);
          left = expr1();

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

          if (state.backtracking == 0) {
            result = left;
          }

          // nu/cotentin/parsing/cotentinel/CotentinELTree.g:40:31: (op= op1 right= expr1 )*
          loop1:
          do {
            int alt1 = 2;
            switch (input.LA(1)) {
              case OP_DIV:
              case OP_MUL:
                {
                  alt1 = 1;
                }
                break;
            }

            switch (alt1) {
              case 1:
                // nu/cotentin/parsing/cotentinel/CotentinELTree.g:40:32: op= op1 right= expr1
                {
                  pushFollow(FOLLOW_op1_in_expr83);
                  op = op1();

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

                  pushFollow(FOLLOW_expr1_in_expr87);
                  right = expr1();

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

                  if (state.backtracking == 0) {
                    op.getChildren().add(result);
                    op.getChildren().add(right);
                    result = op;
                  }
                }
                break;

              default:
                break loop1;
            }
          } while (true);
        }
      }

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