code: protected TokenList.Token parseSubmatrixToExtract(TokenList.Token variableTarget,
                                                        TokenList tokens, Sequence sequence) {
  
  
          List<TokenList.Token> inputs = parseParameterCommaBlock(tokens, sequence);
  
          List<Variable> variables = new ArrayList<Variable>();
  
          // for the operation, the first variable must be the matrix which is being manipulated
          variables.add(variableTarget.getVariable());
  
          addSubMatrixVariables(inputs, variables);
          if( variables.size() != 2 && variables.size() != 3 ) {
              throw new ParseError("Unexpected number of variables.  1 or 2 expected");
          }
  
          // first parameter is the matrix it will be extracted from.  rest specify range
          Operation.Info info;
  
          // only one variable means its referencing elements
          // two variables means its referencing a sub matrix
          if( inputs.size() == 1 ) {
              Variable varA = variables.get(1);
              if( varA.getType() == VariableType.SCALAR ) {
                  info = functions.create("extractScalar", variables);
              } else {
                  info = functions.create("extract", variables);
              }
          } else if( inputs.size() == 2 ) {
              Variable varA = variables.get(1);
              Variable varB = variables.get(2);
  
              if( varA.getType() == VariableType.SCALAR && varB.getType() == VariableType.SCALAR) {
                  info = functions.create("extractScalar", variables);
              } else {
                  info = functions.create("extract", variables);
              }
          } else {
              throw new ParseError("Expected 2 inputs to sub-matrix");
          }
  
          sequence.addOperation(info.op);
  
          return new TokenList.Token(info.output);
      }
docs: Converts a submatrix into an extract matrix operation.
  @param variableTarget The variable in which the submatrix is extracted from