Package nltk :: Package sem :: Module logic :: Class LogicParser
[hide private]
[frames] | no frames]

Class LogicParser

source code

Known Subclasses:

A lambda calculus expression parser.

Instance Methods [hide private]
 
__init__(self) source code
 
parse(self, data)
Parse the expression.
source code
 
process(self, data)
Put whitespace between symbols to make parsing easier
source code
 
get_all_symbols(self)
This method exists to be overridden
source code
 
inRange(self, location)
Return TRUE if the given location is within the buffer
source code
 
token(self, location=None)
Get the next waiting token.
source code
 
isvariable(self, tok) source code
 
parse_Expression(self, allow_adjuncts=True)
Parse the next complete expression from the stream and return it.
source code
 
handle(self, tok)
This method is intended to be overridden for logics that use different operators or expressions
source code
 
handle_negation(self) source code
 
make_NegatedExpression(self, expression) source code
 
handle_variable(self, tok) source code
 
handle_lambda(self, tok) source code
 
get_QuantifiedExpression_factory(self, tok)
This method serves as a hook for other logic parsers that have different quantifiers
source code
 
handle_quant(self, tok) source code
 
handle_open(self, tok) source code
 
attempt_EqualityExpression(self, expression)
Attempt to make a boolean expression.
source code
 
make_EqualityExpression(self, first, second)
This method serves as a hook for other logic parsers that have different equality expression classes
source code
 
attempt_BooleanExpression(self, expression)
Attempt to make a boolean expression.
source code
 
get_BooleanExpression_factory(self)
This method serves as a hook for other logic parsers that have different boolean operators
source code
 
make_BooleanExpression(self, type, first, second)
This method exists to be overridden by parsers with more complex logic for creating BooleanExpressions
source code
 
attempt_ApplicationExpression(self, expression)
Attempt to make an application expression.
source code
 
make_ApplicationExpression(self, function, argument) source code
 
make_VariableExpression(self, name) source code
 
make_LambdaExpression(self, variable, term) source code
 
assertToken(self, tok, expected) source code
 
__repr__(self) source code
Method Details [hide private]

parse(self, data)

source code 

Parse the expression.

Parameters:
  • data - str for the input to be parsed
Returns:
a parsed Expression

token(self, location=None)

source code 

Get the next waiting token. If a location is given, then return the token at currentIndex+location without advancing currentIndex; setting it gives lookahead/lookback capability.

attempt_EqualityExpression(self, expression)

source code 

Attempt to make a boolean expression. If the next token is a boolean operator, then a BooleanExpression will be returned. Otherwise, the parameter will be returned.

attempt_BooleanExpression(self, expression)

source code 

Attempt to make a boolean expression. If the next token is a boolean operator, then a BooleanExpression will be returned. Otherwise, the parameter will be returned.

attempt_ApplicationExpression(self, expression)

source code 

Attempt to make an application expression. The next tokens are a list of arguments in parens, then the argument expression is a function being applied to the arguments. Otherwise, return the argument expression.