@@ -69,63 +69,57 @@ defmodule IEx.Evaluator do
6969 """
7070 def parse ( input , opts , parser_state )
7171
72- def parse ( input , opts , [ ] ) , do: parse ( input , opts , { [ ] , :other } )
73-
74- def parse ( @ break_trigger , opts , _parser_state ) do
75- :elixir_errors . parse_error (
76- [ line: opts [ :line ] ] ,
77- opts [ :file ] ,
78- "incomplete expression" ,
79- "" ,
80- { ~c" " , Keyword . get ( opts , :line , 1 ) , Keyword . get ( opts , :column , 1 ) , 0 }
81- )
82- end
72+ def parse ( input , opts , [ ] ) , do: parse ( input , opts , :other )
8373
84- def parse ( input , opts , { buffer , last_op } ) do
85- input = buffer ++ input
74+ def parse ( input , opts , last_op ) do
8675 file = Keyword . get ( opts , :file , "nofile" )
8776 line = Keyword . get ( opts , :line , 1 )
8877 column = Keyword . get ( opts , :column , 1 )
8978
90- result =
91- with { :ok , tokens } <- :elixir . string_to_tokens ( input , line , column , file , opts ) ,
92- { :ok , adjusted_tokens , adjusted_op } <-
93- adjust_operator ( tokens , line , column , file , opts , last_op ) ,
94- { :ok , forms } <- :elixir . tokens_to_quoted ( adjusted_tokens , file , opts ) do
95- last_op =
96- case forms do
97- { := , _ , [ _ , _ ] } -> :match
98- _ -> :other
99- end
100-
101- forms =
102- if adjusted_op != nil do
103- quote do
104- IEx.Evaluator . assert_no_error! ( )
105- unquote ( forms )
79+ if List . ends_with? ( input , @ break_trigger ) do
80+ triplet = { ~c" " , line , column , 0 }
81+ :elixir_errors . parse_error ( [ line: line ] , file , "incomplete expression" , "" , triplet )
82+ else
83+ result =
84+ with { :ok , tokens } <- :elixir . string_to_tokens ( input , line , column , file , opts ) ,
85+ { :ok , adjusted_tokens , adjusted_op } <-
86+ adjust_operator ( tokens , line , column , file , opts , last_op ) ,
87+ { :ok , forms } <- :elixir . tokens_to_quoted ( adjusted_tokens , file , opts ) do
88+ last_op =
89+ case forms do
90+ { := , _ , [ _ , _ ] } -> :match
91+ _ -> :other
10692 end
107- else
108- forms
109- end
11093
111- { :ok , forms , last_op }
112- end
94+ forms =
95+ if adjusted_op != nil do
96+ quote do
97+ IEx.Evaluator . assert_no_error! ( )
98+ unquote ( forms )
99+ end
100+ else
101+ forms
102+ end
113103
114- case result do
115- { :ok , forms , last_op } ->
116- { :ok , forms , { [ ] , last_op } }
117-
118- { :error , { _ , _ , "" } } ->
119- { :incomplete , { input , last_op } }
120-
121- { :error , { location , error , token } } ->
122- :elixir_errors . parse_error (
123- location ,
124- file ,
125- error ,
126- token ,
127- { input , line , column , 0 }
128- )
104+ { :ok , forms , last_op }
105+ end
106+
107+ case result do
108+ { :ok , forms , last_op } ->
109+ { :ok , forms , last_op }
110+
111+ { :error , { _ , _ , "" } } ->
112+ { :incomplete , last_op }
113+
114+ { :error , { location , error , token } } ->
115+ :elixir_errors . parse_error (
116+ location ,
117+ file ,
118+ error ,
119+ token ,
120+ { input , line , column , 0 }
121+ )
122+ end
129123 end
130124 end
131125
0 commit comments