aboutsummaryrefslogtreecommitdiffstats
path: root/lib/diameter/src/compiler/diameter_dict_scanner.erl
diff options
context:
space:
mode:
authorAnders Svensson <[email protected]>2011-12-03 16:32:06 +0100
committerAnders Svensson <[email protected]>2011-12-04 17:47:45 +0100
commit337102b0220929f1f0b65302021ddead68292db4 (patch)
treeea0d6077cc1571129e90c633115d31e7b3034520 /lib/diameter/src/compiler/diameter_dict_scanner.erl
parenta6268f2f49882e06c2b79f34e1d43e36f7d361c9 (diff)
downloadotp-337102b0220929f1f0b65302021ddead68292db4.tar.gz
otp-337102b0220929f1f0b65302021ddead68292db4.tar.bz2
otp-337102b0220929f1f0b65302021ddead68292db4.zip
Add diameter_dict_util:format/1 for reconstructing a dictionary file
Diffstat (limited to 'lib/diameter/src/compiler/diameter_dict_scanner.erl')
-rw-r--r--lib/diameter/src/compiler/diameter_dict_scanner.erl21
1 files changed, 15 insertions, 6 deletions
diff --git a/lib/diameter/src/compiler/diameter_dict_scanner.erl b/lib/diameter/src/compiler/diameter_dict_scanner.erl
index 74bf0cb06a..963b58fdfc 100644
--- a/lib/diameter/src/compiler/diameter_dict_scanner.erl
+++ b/lib/diameter/src/compiler/diameter_dict_scanner.erl
@@ -26,6 +26,8 @@
-export([scan/1,
format_error/1]).
+-export([is_name/1]).
+
%% -----------------------------------------------------------
%% # scan/1
%% -----------------------------------------------------------
@@ -77,10 +79,19 @@ scan(S, {Lineno, Acc}) ->
{error, {Reason, S, Lineno}}
end.
+%% format_error/1
+
format_error({Reason, Input, Lineno}) ->
io_lib:format("~s at line ~p: ~s",
[Reason, Lineno, head(Input, [], 20, true)]).
+%% is_name/1
+
+is_name([H|T]) ->
+ is_alphanum(H) andalso lists:all(fun is_name_ch/1, T).
+
+%% ===========================================================================
+
head(Str, Acc, N, _)
when [] == Str;
0 == N;
@@ -161,12 +172,10 @@ split([$'|T]) ->
case splitwith(fun(C) -> not lists:member(C, "'\r\n") end, T) of
{[_|_] = A, [$'|Rest]} ->
{{word, A}, Rest};
- {[_|_], _} -> %% not terminated on same line
- "Unterminated atom";
- {[], []} -> %% last character
- "Unterminated atom";
- {[], _} ->
- "Empty atom"
+ {[], [$'|_]} ->
+ "Empty string";
+ _ -> %% not terminated on same line
+ "Unterminated string"
end;
%% Line ending of various forms.