1
- # IEx needs to treat TokenMissingError error in a special way, so this one is
2
- # used only to distinguish from TokenMissingError in the rescue clause
3
- defexception IExTokenMissingError , [ message: nil ]
4
-
5
1
defmodule IEx.Server do
6
2
@ moduledoc false
7
3
@@ -28,29 +24,28 @@ defmodule IEx.Server do
28
24
# a special way (to allow for continuation of an expression on the next
29
25
# line in IEx). In case of any other error, we let :elixir_translator
30
26
# to re-raise it.
31
- { result , new_binding , scope } =
32
- case :elixir_translator . forms ( code , counter , file , [ ] ) do
33
- { :ok , forms } ->
27
+ case :elixir_translator . forms ( code , counter , "iex" , [ ] ) do
28
+ { :ok , forms } ->
29
+ { result , new_binding , scope } =
34
30
:elixir . eval_forms ( forms , config . binding , config . scope )
35
31
36
- { :error , { line , error , token } } ->
37
- if token == [ ] do
38
- # Let the rescue clause catch this error to wait for more input
39
- raise IExTokenMissingError [ ]
40
- else
41
- # Encountered malformed expression
42
- :elixir_translator . parse_error ( line , file , error , token )
43
- end
44
- end
45
-
46
- io_put result
47
-
48
- config = config . result ( result )
49
- update_history ( config . cache ( code ) . scope ( nil ) )
50
- config . update_counter ( & 1 + 1 ) . cache ( '' ) . binding ( new_binding ) . scope ( scope )
32
+ io_put result
33
+
34
+ config = config . result ( result )
35
+ update_history ( config . cache ( code ) . scope ( nil ) )
36
+ config . update_counter ( & 1 + 1 ) . cache ( '' ) . binding ( new_binding ) . scope ( scope )
37
+
38
+ { :error , { line , error , token } } ->
39
+ if token == [ ] do
40
+ # Update config.cache so that IEx continues to add new input to
41
+ # the unfinished expression in `code`
42
+ config . cache ( code )
43
+ else
44
+ # Encountered malformed expression
45
+ :elixir_translator . parse_error ( line , file , error , token )
46
+ end
47
+ end
51
48
rescue
52
- IExTokenMissingError ->
53
- config . cache ( code )
54
49
exception ->
55
50
print_stacktrace System . stacktrace , fn ->
56
51
"** (#{ inspect exception . __record__ ( :name ) } ) #{ exception . message } "
0 commit comments