Skip to content

Commit

Permalink
Add indent support for stand alone data structures
Browse files Browse the repository at this point in the history
The current indenter expects that there are functions and definitions which
works well on source files i.e. code.  When attempting to indent config files
(e.g. app.config) then indenter would align everything to column 0.

This patch makes indenting of config files work as well.
  • Loading branch information
zerotao committed Feb 4, 2013
1 parent 76ece96 commit e07878b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions indent/erlang_indent.erl
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,16 @@ parse_tokens(Tokens = [{'-', _} | _]) ->
parse_attribute(Tokens, #state{});
parse_tokens(Tokens = [{atom, _, _} | _]) ->
parse_function(Tokens, #state{});
parse_tokens(Tokens = [{T, _} | _]) when T == '['; T == '{'; T == '('; T = '<<' ->
parse_datum(Tokens, #state{});
parse_tokens(Tokens) ->
throw({parse_error, Tokens, #state{}, ?LINE}).

parse_datum([T | Tokens], State) ->
parse_next(Tokens, indent(push(State, T, 0), 1));
parse_datum([], State) ->
State.

parse_attribute([T = {'-', _}, {atom, _, export} | Tokens], State = #state{stack = []}) ->
parse_next(Tokens, push(State, T, -1));
parse_attribute([T1 = {'-', _}, T2, T3 | Tokens], State = #state{stack = []}) when ?IS(T2, atom), ?IS(T3, atom) ->
Expand Down

0 comments on commit e07878b

Please sign in to comment.