This is a stop-gap to reduce dialyzer errors in generated parsers, i.e. until a more thorough approach can be taken. Essentially neotoma's parser tracks which combinators are used by in grammar, and then the generator emits macros at the top of the Erlang output to ensure that those used combinators are present, but no others. peg_includes.hrl wraps each optional combinator in appropriate -ifdef macros. There's still a possibility that a successful sub-tree of a failed branch will cause an unused function to be included, but most grammars should not encounter this problem. Globally-unused combinators were also removed from peg_includes.hrl, namely p_and/1 and p/4. p_eof/0 remains for future use but is guarded by a macro. The line/1 and column/1 functions must be manually turned on by defining the 'line' and/or 'column' macros in the global code block. Fixed the remaining dialyzer bugs in neotoma.erl, removing an unnecessary clause of validate_params/4 and fixing the option() type to include an option used by the escript. Provided additional specs for the remaining functions in peg_includes.hrl.
In 03a316e, the following change was made that removed a space after `->`: ``` - ")(I,D) end, fun(Node, Idx) -> ",Transform," end)."] + ")(I,D) end, fun(", TransformArgs, ") ->",Transform," end)."] ``` The previous behavior is more idiomatic for human readers. Restoring the previous behavior makes it easier to review diffs of generated parsers when verifying changes.
When neotoma is escript-ized, use escript:script_name to determine the location of neotoma's priv dir and peg_includes.hrl file. Using code:priv_dir or code:where_is_file in escript context give incorrect/difficult to interpret results.