def read_logic(s, logic_parser=None, encoding=None):
 if (encoding is not None):
  s = s.decode(encoding)
 if (logic_parser is None):
  logic_parser = LogicParser()
 statements = []
 for (linenum, line) in enumerate(s.splitlines()):
  line = line.strip()
  if (line.startswith(u'#') or (line == u'')):
   continue
  try:
   statements.append(logic_parser.parse(line))
  except LogicalExpressionException:
   raise ValueError((u'Unable to parse line %s: %s' % (linenum, line)))
 return statements

def read_logic ( s , logic_parser = None , encoding = None ) : if ( encoding is not None ) : s = s . decode ( encoding ) if ( logic_parser is None ) : logic_parser = LogicParser ( ) statements = [ ] for ( linenum , line ) in enumerate ( s . splitlines ( ) ) : line = line . strip ( ) if ( line . startswith ( u'#' ) or ( line == u'' ) ) : continue try : statements . append ( logic_parser . parse ( line ) ) except LogicalExpressionException : raise ValueError ( ( u'Unable to parse line %s: %s' % ( linenum , line ) ) ) return statements
convert a file of first order formulas into a list of {expression}s .