<s> from . state import EOF <EOL> from . tokens import TokenEof <EOL> from . tokens_base import TOKEN_COMMAND_GLOBAL <EOL> from . tokens_base import TokenOfCommand <EOL> from . parser import parse_command_line <EOL> from Vintageous import ex <EOL> @ ex . command ( '<STR_LIT>' , '<STR_LIT:g>' ) <EOL> class TokenCommandGlobal ( TokenOfCommand ) : <EOL> def __init__ ( self , params , * args , ** kwargs ) : <EOL> super ( ) . __init__ ( params , <EOL> TOKEN_COMMAND_GLOBAL , <EOL> '<STR_LIT>' , * args , ** kwargs ) <EOL> self . addressable = True <EOL> self . target_command = '<STR_LIT>' <EOL> @ property <EOL> def pattern ( self ) : <EOL> return self . params [ '<STR_LIT>' ] <EOL> @ property <EOL> def subcommand ( self ) : <EOL> return self . params [ '<STR_LIT>' ] <EOL> def scan_command_global ( state ) : <EOL> params = { <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : parse_command_line ( '<STR_LIT>' ) . command <EOL> } <EOL> c = state . consume ( ) <EOL> bang = c == '<STR_LIT:!>' <EOL> sep = c if not bang else c . consume ( ) <EOL> assert c in '<STR_LIT>' , '<STR_LIT>' <EOL> state . ignore ( ) <EOL> while True : <EOL> c = state . consume ( ) <EOL> if c == EOF : <EOL> raise ValueError ( '<STR_LIT>' + state . source ) <EOL> if c == sep : <EOL> state . backup ( ) <EOL> params [ '<STR_LIT>' ] = state . emit ( ) <EOL> state . consume ( ) <EOL> state . ignore ( ) <EOL> break <EOL> command = state . match ( r'<STR_LIT>' ) . group ( <NUM_LIT:0> ) . strip ( ) <EOL> command = parse_command_line ( command ) . command or params [ '<STR_LIT>' ] <EOL> params [ '<STR_LIT>' ] = command <EOL> return None , [ TokenCommandGlobal ( params , forced = bang ) , TokenEof ( ) ] </s>
