[Pyparsing] Help using Combine()
Brought to you by:
ptmcg
From: Joshua J. K. <jk...@sk...> - 2008-03-05 21:39:12
|
I have this construct: primary_key = (p.CaselessKeyword('primary') + p.CaselessKeyword('key') + p.Or([p.CaselessKeyword('clustered'), p.CaselessKeyword('nonclustered')]) + p.nestedExpr(content=p.delimitedList(bracket_quoted.setResultsName('key_column'))) + p.CaselessKeyword('on').suppress() + bracket_quoted.suppress() ) which I'm using to parse: PRIMARY KEY CLUSTERED ([login_id]) ON [PRIMARY] All is well, and that gives: ['primary', 'key', 'clustered', ['login_id']] I'd like that first element to be 'primary key' so I do: primary_key = (p.Combine(p.CaselessKeyword('primary') + p.CaselessKeyword('key'), joinString=' ') + p.Or([p.CaselessKeyword('clustered'), p.CaselessKeyword('nonclustered')]) + p.nestedExpr(content=p.delimitedList(bracket_quoted.setResultsName('key_column'))) + p.CaselessKeyword('on').suppress() + bracket_quoted.suppress() ) But that gives me: ParseException: Expected "key" (at char 7), (line:1, col:8) So apparently I'm not using Group as intended, and the docs don't provide an example of use. Might someone point me to the docs that explain how to accomplish what I'm trying to do? Thanks! j -- Joshua Kugler VOC/SigNet Provider (aka Web App Programmer) S&K Aerospace Alaska |