too fucking tired... going to bed
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
-module(wfc_pp).
|
||||
|
||||
-export([
|
||||
eval_result/1,
|
||||
sentence/1,
|
||||
word/1,
|
||||
ltr/1
|
||||
]).
|
||||
|
||||
|
||||
-spec eval_result(wfc_eval:eval_result()) -> string().
|
||||
|
||||
eval_result(noop) -> "";
|
||||
eval_result(S = {s, _}) -> sentence(S).
|
||||
|
||||
-spec sentence(wfc_sentence:sentence()) -> string().
|
||||
|
||||
sentence({s, []}) ->
|
||||
"(+)";
|
||||
sentence({s, Words}) ->
|
||||
wfc_utils:str("(+ ~s)", [words(Words)]).
|
||||
|
||||
|
||||
-spec words([wfc_word:word()]) -> iolist().
|
||||
% @private
|
||||
|
||||
words([W]) -> word(W);
|
||||
words([W | More]) -> [word(W), " ", words(More)];
|
||||
words([]) -> "".
|
||||
|
||||
|
||||
-spec word(wfc_word:word()) -> string().
|
||||
|
||||
word({w, []}) ->
|
||||
"(*)";
|
||||
word({w, Letters}) ->
|
||||
wfc_utils:str("(* ~s)", [letters(Letters)]).
|
||||
|
||||
|
||||
-spec letters([wfc_ltr:ltr()]) -> iolist().
|
||||
% @private
|
||||
|
||||
letters([W]) -> ltr(W);
|
||||
letters([W | More]) -> [ltr(W), " ", letters(More)];
|
||||
letters([]) -> "".
|
||||
|
||||
|
||||
-spec ltr(wfc_ltr:ltr()) -> string().
|
||||
|
||||
ltr({c, Binary}) -> unicode:characters_to_list(Binary).
|
||||
Reference in New Issue
Block a user