def _ex_route_print(state): command = TokenCommand('print') command.addressable = True command.cooperates_with_global = True while True: c = state.consume() state.skip(' ') state.ignore() if c == state.EOF: break c = state.consume() if c.isdigit(): state.match(r'\d*') command.params['count'] = state.emit() continue state.backup() m = state.expect_match(r'[l#p]+') command.params['flags'] = list(m.group(0)) state.ignore() state.expect_eof() break return command
def _ex_route_print(state): command = TokenCommand('print') command.addressable = True command.cooperates_with_global = True # TODO [review] count param looks unused. params = {'count': '', 'flags': []} while True: c = state.consume() state.skip(' ') state.ignore() if c == state.EOF: command.params = params return None, [command, TokenEof()] if c.isdigit(): state.match(r'\d*') params['count'] = state.emit() continue m = state.expect_match(r'[l#p]+') params['flags'] = list(m.group(0)) state.ignore() state.expect_eof() break command.params = params return None, [command, TokenEof()]
def _ex_route_delete(state): command = TokenCommand('delete') command.cooperates_with_global = True command.addressable = True params = {'register': '"', 'count': None} state.skip(' ') state.ignore() c = state.consume() if c == state.EOF: command.params = params return command state.backup() state.skip(' ') state.ignore() m = state.expect_match( r'(?P<register>[a-zA-Z0-9"])(?:\s+(?P<count>\d+))?\s*$') params.update(m.groupdict()) if params['count']: raise NotImplementedError('parameter not implemented') command.params = params return command