Class Operands
java.lang.Object
org.projog.core.parser.Operands
Collection of operands.
Prolog allows functors (names of predicates) to be defined as "operators". The use of operators allows syntax to be easier to read.
Infix operators are placed between their two arguments. Prefix operators are placed before their single argument. Postfix operators are placed after their single argument.
A common use of operators is in the definition of arithmetic operations. By declaring is and - as
infix operators we can write valid prolog syntax like X is 1 + 2. instead of is(X, +(1, 2)).
Each KnowledgeBase has a single unique Operands instance.
- See Also:
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddOperand(String operandName, String associativityName, int precedence) Adds a new operator.booleanReturnstrueifoprepresents a prefix operator with associativity offx, elsefalse.booleanReturnstrueifoprepresents a prefix operator with associativity offy, elsefalse.intReturns the priority (precedence/level) of the infix operator represented byop.intReturns the priority (precedence/level) of the postfix operator represented byop.intReturns the priority (precedence/level) of the prefix operator represented byop.booleanReturnstrueifoprepresents an infix operator, elsefalse.booleanReturnstrueifcommandNamerepresents any known operator, elsefalse.booleanReturnstrueifoprepresents a postfix operator, elsefalse.booleanReturnstrueifoprepresents a prefix operator, elsefalse.booleanReturnstrueifoprepresents a postfix operator with associativity ofxf, elsefalse.booleanReturnstrueifoprepresents an infix operator with associativity ofxfx, elsefalse.booleanReturnstrueifoprepresents an infix operator with associativity ofxfy, elsefalse.booleanReturnstrueifoprepresents a postfix operator with associativity ofyf, elsefalse.booleanReturnstrueifoprepresents an infix operator with associativity ofyfx, elsefalse.
-
Constructor Details
-
Operands
public Operands()
-
-
Method Details
-
addOperand
Adds a new operator.- Parameters:
operandName- the name of the new operatorassociativityName- the operators associativity (must be one of: xfx, xfy, yfx, fx, fy, xf or yf)precedence- used to specify the ordering of terms where it is not made explicit by the use of brackets
-
getInfixOperand
-
getPrefixOperand
-
getPostfixOperand
-
getInfixPriority
Returns the priority (precedence/level) of the infix operator represented byop. -
getPrefixPriority
Returns the priority (precedence/level) of the prefix operator represented byop. -
getPostfixPriority
Returns the priority (precedence/level) of the postfix operator represented byop. -
infix
Returnstrueifoprepresents an infix operator, elsefalse. -
yfx
Returnstrueifoprepresents an infix operator with associativity ofyfx, elsefalse. -
xfy
Returnstrueifoprepresents an infix operator with associativity ofxfy, elsefalse. -
xfx
Returnstrueifoprepresents an infix operator with associativity ofxfx, elsefalse. -
prefix
Returnstrueifoprepresents a prefix operator, elsefalse. -
fx
Returnstrueifoprepresents a prefix operator with associativity offx, elsefalse. -
fy
Returnstrueifoprepresents a prefix operator with associativity offy, elsefalse. -
postfix
Returnstrueifoprepresents a postfix operator, elsefalse. -
xf
Returnstrueifoprepresents a postfix operator with associativity ofxf, elsefalse. -
yf
Returnstrueifoprepresents a postfix operator with associativity ofyf, elsefalse. -
isDefined
ReturnstrueifcommandNamerepresents any known operator, elsefalse.
-