lojix/logic/src/main/com/thesett/aima/logic/fol/isoprologparser/PrologParser.java
public Term term() throws SourceCodeException
    {
        List<Term> terms;
        terms = terms(new LinkedList<Term>());

        Term[] flatTerms = terms.toArray(new Term[terms.size()]);

        if (flatTerms.length > 1)
        {
            return operatorParser.parseOperators(flatTerms);
        }
        else
        {
            Term result = flatTerms[0];

            // If a single candidate op symbol has been parsed, promote it to a constant.
            if (result instanceof CandidateOpSymbol)
            {
                CandidateOpSymbol candidate = (CandidateOpSymbol) result;

                int nameId = interner.internFunctorName(candidate.getTextName(), 0);
                result = new Functor(nameId, null);
            }

            return result;
        }
    }
public Term term() throws SourceCodeException
    {
        List<Term> terms;
        terms = terms(new LinkedList<Term>());

        Term[] flatTerms = terms.toArray(new Term[terms.size()]);

        if (flatTerms.length > 1)
        {
            return operatorParser.parseOperators(flatTerms);
        }
        else
        {
            Term result = flatTerms[0];

            // If a single candidate op symbol has been parsed, promote it to a constant.
            if (result instanceof CandidateOpSymbol)
            {
                CandidateOpSymbol candidate = (CandidateOpSymbol) result;

                int nameId = interner.internFunctorName(candidate.getTextName(), 0);
                result = new Functor(nameId, null);
            }

            return result;
        }
    }
Parses multiple sequential terms, and if more than one is encountered then the flat list of terms encountered
must contain operators in order to be valid Prolog syntax. In that case the flat list of terms is passed to the
{@link DynamicOperatorParser#parseOperators(Term[])} method for 'deferred decision parsing' of dynamic operators.

@return A single first order logic term.

@throws SourceCodeException If the sequence of tokens does not form a valid syntactical construction as a first
order logic term.