def scan_command_global(state):
    params = {
        'pattern': None,
        'subcommand': parse_command_line('print').command
    }

    c = state.consume()

    bang = c == '!'
    sep = c if not bang else c.consume()
    # TODO: we're probably missing legal separators.
    assert c in '!:?/\\&$', 'bad separator'

    state.ignore()

    while True:
        c = state.consume()

        if c == EOF:
            raise ValueError('unexpected EOF in: ' + state.source)

        if c == sep:
            state.backup()
            params['pattern'] = state.emit()
            state.consume()
            state.ignore()
            break

    command = state.match(r'.*$').group(0).strip()
    command = parse_command_line(command).command or params['subcommand']
    params['subcommand'] = command

    return None, [TokenCommandGlobal(params, forced=bang), TokenEof()]
dataset/ETHPy150Open guillermooo/Vintageous/ex/parser/scanner_command_global.py/scan_command_global/original