def _query(cmd):
action = upkey(cmd).setResultsName("<STR_LIT:action>")<EOL>consist = upkey("<STR_LIT>").setResultsName("<STR_LIT>")<EOL>order_by = (Suppress(upkey("<STR_LIT>") + upkey("<STR_LIT>")) + var).setResultsName("<STR_LIT>")<EOL>ordering = (upkey("<STR_LIT>") | upkey("<STR_LIT>")).setResultsName("<STR_LIT>")<EOL>save = (Suppress(upkey("<STR_LIT>")) + filename).setResultsName("<STR_LIT>")<EOL>return (<EOL>action<EOL>+ Optional(consist)<EOL>+ selection<EOL>+ from_<EOL>+ table<EOL>+ Optional(keys_in | where)<EOL>+ Optional(using)<EOL>+ Optional(limit)<EOL>+ Optional(scan_limit)<EOL>+ Optional(order_by)<EOL>+ Optional(ordering)<EOL>+ Optional(throttle)<EOL>+ Optional(save)<EOL>)<EOL>
Create the grammar for a scan/query