首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用erl_tidy和erl_lint?

如何使用erl_tidy和erl_lint?
EN

Stack Overflow用户
提问于 2011-08-02 04:13:49
回答 1查看 1.7K关注 0票数 3

我知道文档解释了这些工具,但我不理解这些解释。有人能举一两个例子吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-08-02 12:56:54

对于erl_tidy,最简单也是最直接的方法是直接从Eshell中使用它

代码语言:javascript
复制
$ erl
1> m(erl_tidy).
% output snipped
2> erl_tidy:dir().  % recursively tidy the present directory and its children
% output snipped
3> erl_tidy:dir("", [{recursive, false}]).  % just the present directory
reading module `./bad.erl'.
made backup of file `./bad.erl'.
writing to file `./bad.erl'.
4>

在这种情况下,bad.erl

代码语言:javascript
复制
-module(bad).
-compile(export_all).

bad(0)->1;bad(1)->2;bad(N)->3.bad()->0.

给整洁的人

代码语言:javascript
复制
-module(bad).

-compile(export_all).

bad ( 0 ) -> 1 ; bad ( 1 ) -> 2 ; bad ( N ) -> 3 . bad ( ) -> 0 .

..。好吧,它不是魔术师:-)

也可以通过erl的参数调用erl_tidy,如下所示

代码语言:javascript
复制
$ # unix prompt
$ erl -s erl_tidy dir
tidying directory `./wesnoth'.
tidying directory `./wesnoth/Vix'.
tidying directory `./wesnoth/Vix/utils'.
...

然而,erl_lint则完全不同。要了解如何使用它,首先要了解this string evaluation example中发生了什么。erl_lint被设计成作用于Erlang源代码的中间表示,而不是它的字符串。

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6903903

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档