Package org.formulacompiler.compiler.internal.expressions

Examples of org.formulacompiler.compiler.internal.expressions.ExpressionNode


    }, _allowRanges );
  }

  private void convertRangesToCells( final ExpressionNodeSource _nodeSource, final boolean _allowRanges )
  {
    final ExpressionNode node = _nodeSource.getExpressionNode();
    if (node instanceof ExpressionNodeForOperator) {
      final ListIterator<ExpressionNode> nodeListIterator = node.arguments().listIterator();
      while (nodeListIterator.hasNext()) {
        final ExpressionNode argNode = nodeListIterator.next();
        convertRangesToCells( new ExpressionNodeSource()
        {
          public ExpressionNode getExpressionNode()
          {
            return argNode;
View Full Code Here



  private void buildCellModel( CellModel _cellModel, CellWithExpression _cell ) throws CompilerException
  {
    try {
      final ExpressionNode exprModel = buildExpressionModel( _cell.getExpression() );
      _cellModel.setExpression( exprModel );
    }
    catch (SpreadsheetException cause) {
      throw new CompilerException.UnsupportedExpression( cause );
    }
View Full Code Here

  }


  private ExpressionNode buildExpressionModel( ExpressionNode _exprDef ) throws CompilerException
  {
    final ExpressionNode result = buildRawExpressionModel( _exprDef );
    if (result != null) {
      result.setDerivedFrom( _exprDef );
    }
    return result;
  }
View Full Code Here

    else if (_exprDef instanceof ExpressionNodeForCell) {
      final CellIndex cell = ((ExpressionNodeForCell) _exprDef).getCellIndex();
      return buildExpressionModelForCell( cell );
    }
    else if (_exprDef instanceof ExpressionNodeForRangeShape) {
      final ExpressionNode expressionNode = _exprDef.arguments().get( 0 );
      final CellRange range;
      if (expressionNode instanceof ExpressionNodeForRange) {
        range = ((ExpressionNodeForRange) expressionNode).getRange();
      }
      else if (expressionNode instanceof ExpressionNodeForCell) {
        range = ((ExpressionNodeForCell) expressionNode).getCellIndex();
      }
      else {
        throw new IllegalArgumentException();
      }
      return new RangeExpressionBuilder( range, true ).build();
    }
    else if (_exprDef instanceof ExpressionNodeForRange) {
      final CellRange range = ((ExpressionNodeForRange) _exprDef).getRange();
      return new RangeExpressionBuilder( range, false ).build();
    }
    else {
      final ExpressionNode result = _exprDef.cloneWithoutArguments();
      for (ExpressionNode arg : _exprDef.arguments()) {
        final ExpressionNode argResult = buildExpressionModel( arg );
        if (argResult instanceof ExpressionNodeForSubstitution) {
          result.arguments().addAll( argResult.arguments() );
        }
        else {
          result.addArgument( argResult );
        }
      }
View Full Code Here


  @Override
  public String getExpressionText() throws SpreadsheetException
  {
    final ExpressionNode exp = getExpression();
    return exp != null ? exp.toString() : null;
  }
View Full Code Here

    private ExpressionNode buildOuterRange() throws CompilerException
    {
      final SectionPath path = new SectionPath( SectionModelCompiler.this );
      path.stepOut();
      final ExpressionNode outer = path.getSectionCompiler().new RangeExpressionBuilder( range, shaped, true )
          .build();
      if (shaped) {
        return path.wrapAround( outer );
      }
      else {
        return path.wrapAround( outer.arguments() );
      }
    }
View Full Code Here

          case CellRange.NO_INTERSECTION:
            break;

          case CellRange.CONTAINED: {
            final ExpressionNode expr = buildExpressionModelForInnerRange( inner, next );
            elts.add( expr );
            next = null;
            break;
          }

          case CellRange.FLOW_TILES: {
            final CellRange before = tiling[ CellRange.FLOW_BEFORE ];
            if (null != before) {
              /*
               * This is where we rely on proper sorting. It ensures that `before` cannot
               * possibly overlap one of the remaining inner section to scan.
               */
              if (shaped) {
                elts.add( buildExpressionModelForLocalRange( before ) );
              }
              else {
                buildExpressionModelsForLocalRangeCells( before, elts );
              }
            }
            elts.add( buildExpressionModelForInnerRange( inner, tiling[ CellRange.FLOW_INNER ] ) );
            next = tiling[ CellRange.FLOW_AFTER ];
            break;
          }

          default:
            throw new SpreadsheetException.SectionSpan( range.getShortName(), inner.toString() );

        }
        if (null == next) break;
      }
      if (null != next) {
        if (0 == elts.size() || !shaped) {
          buildExpressionModelsForLocalRangeCells( next, elts );
        }
        else {
          elts.add( buildExpressionModelForLocalRange( next ) );
        }
      }

      final CellIndex from = range.getFrom();
      final ExpressionNode result = (shaped) ? new ExpressionNodeForArrayReference( new ArrayDescriptor(
          from.getSheetIndex(), from.getRowIndex(), from.getColumnIndex(), sheets, rows, cols ) )
          : new ExpressionNodeForSubstitution();
      result.arguments().addAll( elts );
      return result;
    }
View Full Code Here

      makeDynamic( _inner.getOrientation() );
      final CellRange innerRange = _inner.getPrototypeRange( _range );
      final SectionPath path = new SectionPath( SectionModelCompiler.this );
      path.stepInto( _inner );
      final SectionModelCompiler innerDef = path.getSectionCompiler();
      final ExpressionNode expr = innerDef.new RangeExpressionBuilder( this, innerRange, shaped )
          .buildContainedRange();
      if (shaped) {
        return path.wrapAround( expr );
      }
      else {
        return path.wrapAround( expr.arguments() );
      }
    }
View Full Code Here

      final CellIndex from = _range.getFrom();
      final CellIndex to = _range.getTo();
      final int sheets = to.getSheetIndex() - from.getSheetIndex() + 1;
      final int rows = to.getRowIndex() - from.getRowIndex() + 1;
      final int cols = to.getColumnIndex() - from.getColumnIndex() + 1;
      final ExpressionNode result = new ExpressionNodeForArrayReference( new ArrayDescriptor( from.getSheetIndex(),
          from.getRowIndex(), from.getColumnIndex(), sheets, rows, cols ) );
      buildExpressionModelsForLocalRangeCells( _range, result.arguments() );
      return result;
    }
View Full Code Here

    private void buildExpressionModelsForLocalRangeCells( CellRange _range, Collection<ExpressionNode> _elts )
        throws CompilerException
    {
      for (CellIndex element : _range) {
        final ExpressionNode elementNode = buildExpressionModelForCell( element );
        _elts.add( elementNode );
      }
    }
View Full Code Here

TOP

Related Classes of org.formulacompiler.compiler.internal.expressions.ExpressionNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.