diff options
author | Kostis Sagonas <[email protected]> | 2010-03-19 19:49:24 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2010-06-03 14:34:26 +0200 |
commit | 414b47a55fef49852354e1f480fa4d0bb5a125f5 (patch) | |
tree | 2b8c99f47f3477275aec150dd1f122a724316d55 /lib | |
parent | 7d672e4ee4ceb693267f22701388d060d5f19a87 (diff) | |
download | otp-414b47a55fef49852354e1f480fa4d0bb5a125f5.tar.gz otp-414b47a55fef49852354e1f480fa4d0bb5a125f5.tar.bz2 otp-414b47a55fef49852354e1f480fa4d0bb5a125f5.zip |
erl_scan: Add declarations for exported types
While at it, added some types to a record
and did some cleanups suggested by tidier.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/stdlib/src/erl_scan.erl | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/lib/stdlib/src/erl_scan.erl b/lib/stdlib/src/erl_scan.erl index c179c3d067..18f64c46d0 100644 --- a/lib/stdlib/src/erl_scan.erl +++ b/lib/stdlib/src/erl_scan.erl @@ -55,18 +55,13 @@ token_info/1,token_info/2, attributes_info/1,attributes_info/2,set_attribute/3]). -%%% Local record. --record(erl_scan, - {resword_fun=fun reserved_word/1, - ws=false, - comment=false, - text=false}). +-export_type([error_info/0, line/0, tokens_result/0]). %%% -%%% Exported functions +%%% Defines and type definitions %%% --define(COLUMN(C), is_integer(C), C >= 1). +-define(COLUMN(C), (is_integer(C) andalso C >= 1)). %% Line numbers less than zero have always been allowed: -define(ALINE(L), is_integer(L)). -define(STRING(S), is_list(S)). @@ -95,6 +90,15 @@ -type error_description() :: term(). -type error_info() :: {location(), module(), error_description()}. +%%% Local record. +-record(erl_scan, + {resword_fun = fun reserved_word/1 :: resword_fun(), + ws = false :: boolean(), + comment = false :: boolean(), + text = false :: boolean()}). + +%%---------------------------------------------------------------------------- + -spec format_error(Error :: term()) -> string(). format_error({string,Quote,Head}) -> lists:flatten(["unterminated " ++ string_thing(Quote) ++ @@ -307,10 +311,10 @@ options(Opt) -> options([Opt]). opts(Options, [Key|Keys], L) -> - V = case lists:keysearch(Key, 1, Options) of - {value,{reserved_word_fun,F}} when ?RESWORDFUN(F) -> + V = case lists:keyfind(Key, 1, Options) of + {reserved_word_fun,F} when ?RESWORDFUN(F) -> {ok,F}; - {value,{Key,_}} -> + {Key,_} -> badarg; false -> {ok,default_option(Key)} @@ -333,12 +337,13 @@ expand_opt(O, Os) -> [O|Os]. attr_info(Attrs, Item) -> - case catch lists:keysearch(Item, 1, Attrs) of - {value,{Item,Value}} -> - {Item,Value}; + try lists:keyfind(Item, 1, Attrs) of + {_Item, _Value} = T -> + T; false -> - undefined; - _ -> + undefined + catch + _:_ -> erlang:error(badarg, [Attrs, Item]) end. |