// FILE. . . . . d:/hak/hlt/src/hlt/fot/fuz/syntax/sources/fff-ancillary-classes.grm // EDIT BY . . . Hassan Ait-Kaci // ON MACHINE. . Hak-Laptop // STARTED ON. . Tue Aug 21 05:20:57 2018 // Last modified on Wed Nov 28 15:10:47 2018 by hak %% /** * This is the class for terms being partially parsed as syntactic * objects and eventually translated into a FirstOrderTerm. * N.B.: numbers are not parsed as we consider only * symbolic functors. */ class SyntacticTerm { String symbol = null; Vector body = null; Functor functor = null; FirstOrderTerm term = null; FirstOrderTerm[] arguments = null; boolean isVariable = false; SyntacticTerm markAsVariable () { isVariable = true; return this; } SyntacticTerm (String symbol) { this.symbol = symbol; } SyntacticTerm (String symbol, Vector body) { this.symbol = symbol; this.body = body; } final boolean hasBody () { return (body != null && !body.isEmpty()); } public String toString () { if (!hasBody()) return symbol; StringBuffer s = new StringBuffer(symbol); s.append("("); for (int i=0; iSyntacticTerm into an actual * FirstOrderTerm where functors are registered in the * provided Signature and in the provided * name -> functor table functorTable. */ FirstOrderTerm canonical (Signature signature, HashMap functorTable) { if (isVariable) return Variable.getVariable(symbol); if (!hasBody()) { FuzzyFOTLatticeMain.parser.registerFunctor (symbol,functor = signature.functor(symbol,0)); return new FirstOrderTermStructure(functor); } FuzzyFOTLatticeMain.parser.registerFunctor (symbol,functor = signature.functor(symbol,body.size())); arguments = new FirstOrderTerm[body.size()]; term = new FirstOrderTermStructure(functor,arguments); for (int i = 0; i < arguments.length; i++) arguments[i] = ((SyntacticTerm)body.get(i)).canonical(signature,functorTable); return term; } } /* ************************************************************************ */