@@ -1131,7 +1131,7 @@ def build_statement(code)
11311131 end
11321132
11331133 code . force_encoding ( @context . io . encoding )
1134- if ( command , arg = parse_command ( code ) )
1134+ if ( command , arg = @context . parse_command ( code ) )
11351135 command_class = Command . load_command ( command )
11361136 Statement ::Command . new ( code , command_class , arg )
11371137 else
@@ -1140,35 +1140,8 @@ def build_statement(code)
11401140 end
11411141 end
11421142
1143- ASSIGN_OPERATORS_REGEXP = Regexp . union ( %w[ = += -= *= /= %= **= &= |= &&= ||= ^= <<= >>= ] )
1144-
1145- def parse_command ( code )
1146- command_name , arg = code . strip . split ( /\s +/ , 2 )
1147- return unless code . lines . size == 1 && command_name
1148-
1149- arg ||= ''
1150- command = command_name . to_sym
1151- # Command aliases are always command. example: $, @
1152- if ( alias_name = @context . command_aliases [ command ] )
1153- return [ alias_name , arg ]
1154- end
1155-
1156- # Assignment-like expression is not a command
1157- return if arg . start_with? ( ASSIGN_OPERATORS_REGEXP ) && !arg . start_with? ( /==|=~/ )
1158-
1159- # Local variable have precedence over command
1160- return if @context . local_variables . include? ( command )
1161-
1162- # Check visibility
1163- public_method = !!Kernel . instance_method ( :public_method ) . bind_call ( @context . main , command ) rescue false
1164- private_method = !public_method && !!Kernel . instance_method ( :method ) . bind_call ( @context . main , command ) rescue false
1165- if Command . execute_as_command? ( command , public_method : public_method , private_method : private_method )
1166- [ command , arg ]
1167- end
1168- end
1169-
11701143 def command? ( code )
1171- !!parse_command ( code )
1144+ !!@context . parse_command ( code )
11721145 end
11731146
11741147 def configure_io
0 commit comments