aboutsummaryrefslogtreecommitdiffstats
path: root/lib/parsetools/include/yeccpre.hrl
diff options
context:
space:
mode:
authorHans Bolinder <[email protected]>2014-10-31 08:38:49 +0100
committerBjörn Gustavsson <[email protected]>2015-04-30 12:15:24 +0200
commitcfdcd9e762212a8fb9b4755a69bf715d937f5563 (patch)
tree06ad957e47af3fe654834db029ff29da75f6c594 /lib/parsetools/include/yeccpre.hrl
parentb63838ebab1750171ad60e086126431407f0c1b6 (diff)
downloadotp-cfdcd9e762212a8fb9b4755a69bf715d937f5563.tar.gz
otp-cfdcd9e762212a8fb9b4755a69bf715d937f5563.tar.bz2
otp-cfdcd9e762212a8fb9b4755a69bf715d937f5563.zip
parsetools: Use module erl_anno
Diffstat (limited to 'lib/parsetools/include/yeccpre.hrl')
-rw-r--r--lib/parsetools/include/yeccpre.hrl33
1 files changed, 11 insertions, 22 deletions
diff --git a/lib/parsetools/include/yeccpre.hrl b/lib/parsetools/include/yeccpre.hrl
index 855bff5fdc..b9bba9a7c2 100644
--- a/lib/parsetools/include/yeccpre.hrl
+++ b/lib/parsetools/include/yeccpre.hrl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1996-2013. All Rights Reserved.
+%% Copyright Ericsson AB 1996-2015. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -124,21 +124,10 @@ yecc_end(Line) ->
{'$end', Line}.
yecctoken_end_location(Token) ->
- try
- {text, Str} = erl_scan:token_info(Token, text),
- {line, Line} = erl_scan:token_info(Token, line),
- Parts = re:split(Str, "\n"),
- Dline = length(Parts) - 1,
- Yline = Line + Dline,
- case erl_scan:token_info(Token, column) of
- {column, Column} ->
- Col = byte_size(lists:last(Parts)),
- {Yline, Col + if Dline =:= 0 -> Column; true -> 1 end};
- undefined ->
- Yline
- end
- catch _:_ ->
- yecctoken_location(Token)
+ try erl_anno:end_location(element(2, Token)) of
+ undefined -> yecctoken_location(Token);
+ Loc -> Loc
+ catch _:_ -> yecctoken_location(Token)
end.
-compile({nowarn_unused_function, yeccerror/1}).
@@ -149,15 +138,15 @@ yeccerror(Token) ->
-compile({nowarn_unused_function, yecctoken_to_string/1}).
yecctoken_to_string(Token) ->
- case catch erl_scan:token_info(Token, text) of
- {text, Txt} -> Txt;
- _ -> yecctoken2string(Token)
+ try erl_scan:text(Token) of
+ undefined -> yecctoken2string(Token);
+ Txt -> Txt
+ catch _:_ -> yecctoken2string(Token)
end.
yecctoken_location(Token) ->
- case catch erl_scan:token_info(Token, location) of
- {location, Loc} -> Loc;
- _ -> element(2, Token)
+ try erl_scan:location(Token)
+ catch _:_ -> element(2, Token)
end.
-compile({nowarn_unused_function, yecctoken2string/1}).