class_docstr: Logical expression
class_docstr_tok: ["Logical","expression"]
docstr: Logic from string with space around & and | but none after !.
  
  e.g.
  
  !a & b | c
docstr_tok: ["Logic","from","string","with","space","around","&","and","|","but","none","after","!",".","e.g",".","!","a","&","b","|","c"]
code: def fromstring(text):
      """Logic from string with space around & and | but none after !.
  
      e.g.
  
      !a & b | c
      """
      lexpr = None  # current logical expression
      schedop = None  # scheduled operation
      for term in text.split():
          # operation symbol
          if term in "&|":
              if schedop is not None:
                  raise ValueError(
                      'double op forbidden: "%s %s"' % (term, schedop)
                  )
              if lexpr is None:
                  raise ValueError(
                      "%s cannot be in the beginning of expression"
                      % term
                  )
              schedop = term
              continue
          if "&" in term or "|" in term:
              raise ValueError("& and | must have space around them")
          if term[0] == "!":
              if len(term) == 1:
                  raise ValueError('do not include space after "!"')
              term = Not(term[1:])
  
          # already scheduled operation, e.g. '&'
          if schedop:
              lexpr = Logic.op_2class[schedop](lexpr, term)
              schedop = None
              continue
  
          # this should be atom
          if lexpr is not None:
              raise ValueError(
                  'missing op between "%s" and "%s"' % (lexpr, term)
              )
  
          lexpr = term
  
      # let's check that we ended up in correct state
      if schedop is not None:
          raise ValueError('premature end-of-expression in "%s"' % text)
      if lexpr is None:
          raise ValueError('"%s" is empty' % text)
  
      # everything looks good now
      return lexpr
  
imports: from __future__ import annotations
  from typing import Optional
label_desc: Use image node_id 9 for calling the Logic obj's underlying member method code with example usage: obj.fromstring(text) and returns: lexpr