python - pyparsing to parse a string made of boolean -
i use package pyparsing parse following kind of strings. atomname * , atomindex 1,2,3 atomname xxx,yyy or atomtype rrr,sss thiol not atomindex 1,2,3 not (atomindex 4,5,6) or atomname * based on parsing, link matches specific function calls perform selection of atoms. all selection keywords (atomname,atomindex,thiol ...) stored in list (i.e. selkwds ). i tried failed: keyword = oneof(selkwds,caseless=true).setparseaction(self.__parse_keyword) func_call = forward() func_call << (keyword + commaseparatedlist).setparseaction(self.__parse_expression) func_call = operatorprecedence(func_call, [(not, 1, opassoc.right, self.__not), (and, 2, opassoc.left , self.__and), (or , 2, opassoc.left , self.__or)]) where self._and, self._or, self._not, self._parse_keyword, self._parse_expression method modify token future eval of transformed string. would have ide...