public void testNotExistingLookSensorValues() {

    List<InternToken> internTokenList = new LinkedList<InternToken>();
    internTokenList.add(new InternToken(InternTokenType.SENSOR, ""));
    InternFormulaParser internParser = new InternFormulaParser(internTokenList);
    FormulaElement parseTree = internParser.parseFormula();

    assertNull("Invalid sensor parsed:   NOT_EXISTING_SENSOR)", parseTree);
    int errorTokenIndex = internParser.getErrorTokenIndex();
    assertEquals("Error Token Index is not as expected", 0, errorTokenIndex);
  }
  public void testNotExistingUservariable() {
    List<InternToken> internTokenList = new LinkedList<InternToken>();
    internTokenList.add(
        new InternToken(InternTokenType.USER_VARIABLE, "NOT_EXISTING_USER_VARIABLE"));
    InternFormulaParser internParser = new InternFormulaParser(internTokenList);
    FormulaElement parseTree = internParser.parseFormula();

    assertNull("Invalid user variable parsed:   NOT_EXISTING_USER_VARIABLE)", parseTree);
    int errorTokenIndex = internParser.getErrorTokenIndex();
    assertEquals("Error Token Index is not as expected", 0, errorTokenIndex);
  }
  public static boolean saveFormulaForUserBrickParameterChange() {
    InternFormulaParser formulaToParse = formulaEditorEditText.getFormulaParser();
    FormulaElement formulaParseTree = formulaToParse.parseFormula();

    switch (formulaToParse.getErrorTokenIndex()) {
      case PARSER_OK:
        currentFormula.setRoot(formulaParseTree);
        if (onFormulaChangedListener != null) {
          onFormulaChangedListener.onFormulaChanged(
              formulaBrick, currentBrickField, currentFormula);
        }
        if (formulaEditorBrick != null) {
          currentFormula.refreshTextField(brickView);
        }
        formulaEditorEditText.formulaSaved();
        return true;
    }
    return false;
  }
  public boolean saveFormulaIfPossible() {
    InternFormulaParser formulaToParse = formulaEditorEditText.getFormulaParser();
    FormulaElement formulaParseTree = formulaToParse.parseFormula();

    switch (formulaToParse.getErrorTokenIndex()) {
      case PARSER_OK:
        currentFormula.setRoot(formulaParseTree);
        if (onFormulaChangedListener != null) {
          onFormulaChangedListener.onFormulaChanged(
              formulaBrick, currentBrickField, currentFormula);
        }
        if (formulaEditorBrick != null) {
          currentFormula.refreshTextField(brickView);
        }
        formulaEditorEditText.formulaSaved();
        showToast(R.string.formula_editor_changes_saved, false);
        return true;
      case PARSER_STACK_OVERFLOW:
        return checkReturnWithoutSaving(PARSER_STACK_OVERFLOW);
      default:
        formulaEditorEditText.setParseErrorCursorAndSelection();
        return checkReturnWithoutSaving(PARSER_INPUT_SYNTAX_ERROR);
    }
  }