<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Dec 17, 2015 at 9:52 PM, Sparr <span dir="ltr"><<a href="mailto:sparr0@gmail.com" target="_blank">sparr0@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><p dir="ltr">Figured it out with help from #erlang on freenode. If hello.erl is missing the trailing newline then the last form gets missed. I'm going to try to figure out how to account for that.</p></blockquote><div><br></div><div>You don't need a newline specifically -- a space character will also work, for example. Just change this:</div><div><br></div><div>  Forms = scan(erl_scan:tokens([],binary_to_list(B),1),[]),<br></div><div><br></div><div>to this:</div><div><br></div><div>  Forms = scan(erl_scan:tokens([],binary_to_list(B)++" ",1),[]),<br></div><div><br></div><div>--steve</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><p dir="ltr"> </p><div class=""><div class="h5">
<div class="gmail_quote">On Dec 17, 2015 18:32, "Steve Vinoski" <<a href="mailto:vinoski@ieee.org" target="_blank">vinoski@ieee.org</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Dec 17, 2015 at 1:45 PM, Sparr <span dir="ltr"><<a href="mailto:sparr0@gmail.com" target="_blank">sparr0@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div>I'm trying to use erl_lint() to build a simple Erlang syntax and style checker. I've gotten far enough to load the file and parse it into Forms and to get erl_lint to partially understand it, but then erl_lint complains about undefined functions that are defined. What am I doing wrong?<br><br>erlint.erl :</div><div><br></div><div>    -module(erlint).</div><div>    -export([lint/1]).</div><div><br></div><div>    % based on <a href="http://stackoverflow.com/a/28086396/13675" target="_blank">http://stackoverflow.com/a/28086396/13675</a></div><div><br></div><div>    lint(File) -> </div><div>        {ok, B} = file:read_file(File),</div><div>        Forms = scan(erl_scan:tokens([],binary_to_list(B),1),[]),</div><div>        F = fun(X) -> {ok,Y} = erl_parse:parse_form(X), Y end,</div><div>        erl_lint:module([F(X) || X <- Forms],File).</div><div><br></div><div>    scan({done,{ok,T,N},S},Res) -></div><div>        scan(erl_scan:tokens([],S,N),[T|Res]);</div><div>    scan(_,Res) -></div><div>        lists:reverse(Res).</div><div><br></div><div>hello.erl :</div><div><br></div><div>    -module(hello).</div><div>    -export([hello_world/0]).</div><div><br></div><div>    hello_world() -> io:fwrite("hello, world\n").</div><div><br></div><div>attempt to use :</div><div><br></div><div>    1> c(erlint).</div><div>    {ok,erlint}</div><div>    2> erlint:lint("hello.erl").</div><div>    {error,[{"hello.erl",</div><div>             [{2,erl_lint,{undefined_function,{hello_world,0}}}]}],</div><div>           []}</div></div></blockquote><div><br></div><div>I copied both erlint and hello directly out of your email, pasted them into source modules, compiled erlint, and ran erlint:lint("hello.erl"), same as you show. It returned {ok,[]}. I then changed the first double quote in hello.erl to a single quote to introduce an obvious syntax error, and retried. That gave me the same result you're seeing, which makes sense because the module is exporting a function that it never defines due to the syntax error. You might want to check your hello.erl source, or just try to compile it, to make sure its contents are correct.</div><div><br></div><div>--steve</div></div></div></div>
</blockquote></div>
</div></div></blockquote></div><br></div></div>