BinPy.dev package

Submodules

BinPy.dev.parseEquation module

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

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. 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>)[source]
findMatchingBrace(position, string)[source]

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

parse()[source]
removeBraces(position, equation)[source]

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

truthTable()[source]

Module contents

Table Of Contents

Previous topic

BinPy.Shell package

Next topic

BinPy.ic package

This Page