Class PrologTerm
java.lang.Object
com.igormaznitsa.prologparser.terms.PrologTerm
- All Implemented Interfaces:
Serializable, Comparable<PrologTerm>
- Direct Known Subclasses:
Op, PrologAtom, PrologCompound, PrologNumeric, PrologVar
Base class describes a Prolog term
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPrologTerm(String text, Quotation quotation) PrologTerm(String text, Quotation quotation, int line, int pos) -
Method Summary
Modifier and TypeMethodDescriptionprotected static StringintcompareTo(PrologTerm that) static QuotationfindQuotation(String atomText) Find appropriate quotation for text.flatComma(List<PrologTerm> list) Flat content of the term for comma, make sense for structures.intgetArity()Arity of element.Get the functor, make sense of structure and its successors, for primitive returns the same term.final intgetLine()Line of the term, first line is 1final intgetPos()Position of the term in the line, first position is 1intGet precedence of the term.Get quotation for the term.getText()Get the term text.abstract TermTypegetType()Get term type.booleanCheck the term describes '()' or '{}' block.booleanisBlock()Check the term describes '()' block.booleanCheck the term describes '{}' block.final voidsetLine(int line) final voidsetPos(int pos) stream()toString()
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
quotation
-
text
-
line
private int line -
pos
private int pos
-
-
Constructor Details
-
PrologTerm
-
PrologTerm
-
-
Method Details
-
findQuotation
-
assertNonEmptyString
-
flatComma
Flat content of the term for comma, make sense for structures.- Parameters:
list- list to be filled by comma separated terms- Returns:
- the same list
-
getArity
public int getArity()Arity of element.- Returns:
- arity of element, make sense for compound terms, for primitive terms is 1
-
isAnyBlock
public boolean isAnyBlock()Check the term describes '()' or '{}' block.- Returns:
- true if the term is structure describes any kind of supported block
- Since:
- 2.0.1
-
isBlock
public boolean isBlock()Check the term describes '()' block.- Returns:
- true if the term is structure with '()' as functor
-
isCurlyBlock
public boolean isCurlyBlock()Check the term describes '{}' block.- Returns:
- true if the term is structure with '{}' as functor
-
getQuotation
Get quotation for the term.- Returns:
- the quotation for the term, must not be null
-
getPos
public final int getPos()Position of the term in the line, first position is 1- Returns:
- position in line or -1 if unknown
-
setPos
public final void setPos(int pos) -
getLine
public final int getLine()Line of the term, first line is 1- Returns:
- line or -1 if unknown
-
setLine
public final void setLine(int line) -
getText
-
getPrecedence
public int getPrecedence()Get precedence of the term.- Returns:
- precedence, must not be negative
-
toString
-
getType
-
stream
-
getFunctor
Get the functor, make sense of structure and its successors, for primitive returns the same term.- Returns:
- functor for structure or the same term
-
compareTo
- Specified by:
compareToin interfaceComparable<PrologTerm>
-