Pyparsing - name not starting with a character -
i trying use pyparsing identify keyword not beginning $ following input:
$abc = 5 # not valid 1 abc123 = 10 # valid 1 abc$ = 23 # valid 1
i tried following
var = word(printables, excludechars='$') var.parsestring('$abc')
but doesn't allow $ in var. how can specify printable characters other $ in first character position? appreciated.
thanks abhijit
you can use method used define "all characters except x" before added excludechars parameter word class:
not_dollar_sign = ''.join(c c in printables if c != '$') keyword_not_starting_with_dollar = word(not_dollar_sign, printables)
this should bit more efficient building combine , notany. match anything, integers, words, valid identifiers, invalid identifiers, i'm skeptical of value of kind of expression in parser.
Comments
Post a Comment