private void checkFirstAndSecond(final Form form) throws ParseException { SExpression initVal = form.getChild(1); // als init-Wert ist Symbol (oder Subtyp) oder eine Form erlaubt. // Nur s-expression reicht nicht aus if (!initVal.isNil() && !(initVal instanceof Symbol) && initVal.getTyp() != TSExpression.FORM) { error("form or symbol expected", form.getChild(1)); } }
private ParameterDefinition suppliedTestInit(final Form form) throws ParseException { // invariante: laenge childs == 3 checkFirstAndSecond(form); if (form.getChild(2).getTyp() != TSExpression.SYMBOL) { error("symbol expected", form.getChild(2)); } return new ParameterDefinition( form.getFunctionSymbol(), form.getChild(1), (Symbol) form.getChild(2)); }
private ParameterDefinition initForm(final Form form) throws ParseException { if (form.isNil()) { error("NIL not allowed here", form); } List<SExpression> childs = form.getChildren(); if (childs.size() == 2) { return simpleInit(form); } else if (childs.size() == 3) { return suppliedTestInit(form); } else { error("Parameter list must be of length 2 or 3", form); return null; // wird nie erreicht } }
private ParameterDefinition simpleInit(final Form form) throws ParseException { // invariante: laenge childs == 2 checkFirstAndSecond(form); return new ParameterDefinition(form.getFunctionSymbol(), form.getChild(1), null); }