dev

Submodules

  • parseEquation

parseEquation

class BinPy.dev.parseEquation.Expr(equation, *var)

This class is used to parse any expression which contain boolean variables. Input String can be in the form of logical operators which can be parsed to Gates by this class. This is also used to obtain the truth tables”

Logical Operator form: Function takes only equation as an input. Gates Form: Needs The variable inputs also as an argument. .. rubric:: Examples

>>> from BinPy import *
>>> expr = Expr('A & B | C')
>>> expr.parse()
'AND(OR(C,B),A)'
>>> expr.truthTable()
A B C O
0 0 0 0
0 0 1 0
0 1 0 0
0 1 1 0
1 0 0 0
1 0 1 1
1 1 0 1
1 1 1 1
>>> expr = Expr('AND(NOT(A), B)', 'A', 'B')
>>> expr.parse()
'AND(NOT(A),B)'
>>> expr.truthTable()
A B O
0 0 0
0 1 1
1 0 0
1 1 0
eqnParse(eqn, isOperandtype=<method 'isalpha' of 'str' objects>)
findMatchingBrace(position, string)

Returns the index of the opposite matching brace for the brace at string[position]

parse()
removeBraces(position, equation)

Removes braces due to clubbing of the gates position indicates the index of the clubbed gate

truthTable()

Module contents