1
- -file (" /usr/local/Cellar/erlang/19.0.2 /lib/erlang/lib/parsetools-2.1.2 /include/leexinc.hrl" , 0 ).
1
+ -file (" /usr/local/Cellar/erlang/20.1.5 /lib/erlang/lib/parsetools-2.1.5 /include/leexinc.hrl" , 0 ).
2
2
% % The source of this file is part of leex distribution, as such it
3
3
% % has the same Copyright as the other files in the leex
4
4
% % distribution. The Copyright is defined in the accompanying file
16
16
17
17
dismiss_backslash ([$\\ |Chars ]) -> Chars .
18
18
19
- -file (" /usr/local/Cellar/erlang/19.0.2 /lib/erlang/lib/parsetools-2.1.2 /include/leexinc.hrl" , 14 ).
19
+ -file (" /usr/local/Cellar/erlang/20.1.5 /lib/erlang/lib/parsetools-2.1.5 /include/leexinc.hrl" , 14 ).
20
20
21
21
format_error ({illegal ,S }) -> [" illegal characters " ,io_lib :write_string (S )];
22
22
format_error ({user ,S }) -> S .
@@ -37,12 +37,14 @@ string(Ics0, L0, Tcs, Ts) ->
37
37
case yystate (yystate (), Ics0 , L0 , 0 , reject , 0 ) of
38
38
{A ,Alen ,Ics1 ,L1 } -> % Accepting end state
39
39
string_cont (Ics1 , L1 , yyaction (A , Alen , Tcs , L0 ), Ts );
40
- {A ,Alen ,Ics1 ,L1 ,_S1 } -> % Accepting transition state
40
+ {A ,Alen ,Ics1 ,L1 ,_S1 } -> % Accepting transistion state
41
41
string_cont (Ics1 , L1 , yyaction (A , Alen , Tcs , L0 ), Ts );
42
42
{reject ,_Alen ,Tlen ,_Ics1 ,L1 ,_S1 } -> % After a non-accepting state
43
43
{error ,{L0 ,? MODULE ,{illegal ,yypre (Tcs , Tlen + 1 )}},L1 };
44
- {A ,Alen ,_Tlen ,_Ics1 ,_L1 ,_S1 } ->
45
- string_cont (yysuf (Tcs , Alen ), L0 , yyaction (A , Alen , Tcs , L0 ), Ts )
44
+ {A ,Alen ,Tlen ,_Ics1 ,L1 ,_S1 } ->
45
+ Tcs1 = yysuf (Tcs , Alen ),
46
+ L2 = adjust_line (Tlen , Alen , Tcs1 , L1 ),
47
+ string_cont (Tcs1 , L2 , yyaction (A , Alen , Tcs , L0 ), Ts )
46
48
end .
47
49
48
50
% % string_cont(RestChars, Line, Token, Tokens)
@@ -112,8 +114,10 @@ token(S0, Ics0, L0, Tcs, Tlen0, Tline, A0, Alen0) ->
112
114
{reject ,_Alen1 ,Tlen1 ,Ics1 ,L1 ,_S1 } -> % No token match
113
115
Error = {Tline ,? MODULE ,{illegal ,yypre (Tcs , Tlen1 + 1 )}},
114
116
{done ,{error ,Error ,L1 },Ics1 };
115
- {A1 ,Alen1 ,_Tlen1 ,_Ics1 ,_L1 ,_S1 } -> % Use last accept match
116
- token_cont (yysuf (Tcs , Alen1 ), L0 , yyaction (A1 , Alen1 , Tcs , Tline ))
117
+ {A1 ,Alen1 ,Tlen1 ,_Ics1 ,L1 ,_S1 } -> % Use last accept match
118
+ Tcs1 = yysuf (Tcs , Alen1 ),
119
+ L2 = adjust_line (Tlen1 , Alen1 , Tcs1 , L1 ),
120
+ token_cont (Tcs1 , L2 , yyaction (A1 , Alen1 , Tcs , Tline ))
117
121
end .
118
122
119
123
% % token_cont(RestChars, Line, Token)
@@ -186,9 +190,11 @@ tokens(S0, Ics0, L0, Tcs, Tlen0, Tline, Ts, A0, Alen0) ->
186
190
% % Skip rest of tokens.
187
191
Error = {L1 ,? MODULE ,{illegal ,yypre (Tcs , Tlen1 + 1 )}},
188
192
skip_tokens (yysuf (Tcs , Tlen1 + 1 ), L1 , Error );
189
- {A1 ,Alen1 ,_Tlen1 ,_Ics1 ,_L1 ,_S1 } ->
193
+ {A1 ,Alen1 ,Tlen1 ,_Ics1 ,L1 ,_S1 } ->
190
194
Token = yyaction (A1 , Alen1 , Tcs , Tline ),
191
- tokens_cont (yysuf (Tcs , Alen1 ), L0 , Token , Ts )
195
+ Tcs1 = yysuf (Tcs , Alen1 ),
196
+ L2 = adjust_line (Tlen1 , Alen1 , Tcs1 , L1 ),
197
+ tokens_cont (Tcs1 , L2 , Token , Ts )
192
198
end .
193
199
194
200
% % tokens_cont(RestChars, Line, Token, Tokens)
@@ -240,9 +246,11 @@ skip_tokens(S0, Ics0, L0, Tcs, Tlen0, Tline, Error, A0, Alen0) ->
240
246
{done ,{error ,Error ,L1 },eof };
241
247
{reject ,_Alen1 ,Tlen1 ,_Ics1 ,L1 ,_S1 } ->
242
248
skip_tokens (yysuf (Tcs , Tlen1 + 1 ), L1 , Error );
243
- {A1 ,Alen1 ,_Tlen1 ,_Ics1 ,L1 ,_S1 } ->
249
+ {A1 ,Alen1 ,Tlen1 ,_Ics1 ,L1 ,_S1 } ->
244
250
Token = yyaction (A1 , Alen1 , Tcs , Tline ),
245
- skip_cont (yysuf (Tcs , Alen1 ), L1 , Token , Error )
251
+ Tcs1 = yysuf (Tcs , Alen1 ),
252
+ L2 = adjust_line (Tlen1 , Alen1 , Tcs1 , L1 ),
253
+ skip_cont (Tcs1 , L2 , Token , Error )
246
254
end .
247
255
248
256
% % skip_cont(RestChars, Line, Token, Error)
@@ -274,6 +282,17 @@ yyrev(List, Tail) -> lists:reverse(List, Tail).
274
282
yypre (List , N ) -> lists :sublist (List , N ).
275
283
yysuf (List , N ) -> lists :nthtail (N , List ).
276
284
285
+ % % adjust_line(TokenLength, AcceptLength, Chars, Line) -> NewLine
286
+ % % Make sure that newlines in Chars are not counted twice.
287
+ % % Line has been updated with respect to newlines in the prefix of
288
+ % % Chars consisting of (TokenLength - AcceptLength) characters.
289
+
290
+ adjust_line (N , N , _Cs , L ) -> L ;
291
+ adjust_line (T , A , [$\n |Cs ], L ) ->
292
+ adjust_line (T - 1 , A , Cs , L - 1 );
293
+ adjust_line (T , A , [_ |Cs ], L ) ->
294
+ adjust_line (T - 1 , A , Cs , L ).
295
+
277
296
% % yystate() -> InitialState.
278
297
% % yystate(State, InChars, Line, CurrTokLen, AcceptAction, AcceptLen) ->
279
298
% % {Action, AcceptLen, RestChars, Line} |
@@ -284,7 +303,7 @@ yysuf(List, N) -> lists:nthtail(N, List).
284
303
% % return signal either an unrecognised character or end of current
285
304
% % input.
286
305
287
- -file (" src/link_text_lexer.erl" , 286 ).
306
+ -file (" src/link_text_lexer.erl" , 305 ).
288
307
yystate () -> 10 .
289
308
290
309
yystate (11 , [33 |Ics ], Line , Tlen , _ , _ ) ->
@@ -476,4 +495,4 @@ yyaction_9(TokenChars, TokenLine) ->
476
495
yyaction_10 (TokenChars , TokenLine ) ->
477
496
{ token , { verbatim , TokenLine , TokenChars } } .
478
497
479
- -file (" /usr/local/Cellar/erlang/19.0.2 /lib/erlang/lib/parsetools-2.1.2 /include/leexinc.hrl" , 290 ).
498
+ -file (" /usr/local/Cellar/erlang/20.1.5 /lib/erlang/lib/parsetools-2.1.5 /include/leexinc.hrl" , 309 ).
0 commit comments