erl_scan 模块摘要 Erlang令牌扫描仪。 描述 该模块包含将字符标记(扫描)到Erlang令牌中的功能。 数据类型 category() = atom() error_description() = term() error_info() = {erl_anno:location(), module(),error_description()} option() = return | ...
上面的代码其实很简单,最核心的部分,在于parse_func_string/1函数,他利用erl_scan:string/1将一段字符串转换成了tokens, 接下来用erl_parse:parse_form/1将这段tokens解析成ASF (就是erlang的erlang 的Abstract Format,关于ASF,大家可以移步erlang的文档http://www.erlang.org/doc/apps/erts/absform.html,这里...
%%String = "[test1,test2,4]."注意最后面的结束小句号!string_to_args(String) ->{ok, Scan1, _}=erl_scan:string(String), {ok,P}=erl_parse:parse_exprs(Scan1), {value,Value,[]}=erl_eval:exprs(P, []), Value. 以上合适List中所有的参数都是绑定的:,如果是有Test1这样的变量,我也没试...
功能column(),end_location(),line(),location(),和text()中erl_scan模块能够用于在令牌检查注释。 功能anno_from_term(),anno_to_term(),fold_anno(),map_anno(),mapfold_anno(),和new_anno(),在所述erl_parse模块可用于在抽象代码操纵注释。
通常情况下我们在eshell 里面输入的东西都是动态eval的. erl还支持命令行动态解释. erl -eval e init.erl start_it({eval,Bin}) -> Str = binary_to_list(Bin), {ok,Ts,_} = erl_scan:string(Str), Ts1 = case reverse(Ts) of [{dot,_}|_] -> Ts; ...
5> erl_scan:string("\"\x{400}\"."). {ok,[{'[',1},{integer,1,1024},{']',1},{dot,1}],1}6> erl_scan:string("\"16#400\"."). {ok,[{string,1,"16#400"},{dot,1}],1} 注意正则表达式中\x{4e00}就使用了这样的表达方式 ...
analysis结果已经保存到bar.analysis中,此文件可以通过erl_scan and erl_parse, file:consult/1 or io:read/2进行读取分析。 下面我们看看analysis内容: 引用 %% Analysis results: { analysis_options, [{callers, true}, {sort, acc}, {totals, false}, ...
23> io:scan_erl_exprs('enter>'). enter>abc(), "hey". {ok,[{atom,1,abc},{'(',1},{')',1},{',',1},{string,1,"hey"},{dot,1}],2} 24> io:scan_erl_exprs('enter>'). enter>1.0er. {error,{1,erl_scan,{illegal,float}},2}scan...
Argument Options is passed on as argument Options of function erl_scan:tokens/4. The data is tokenized and parsed as if it was a sequence of Erlang expressions until a final dot (.) is reached. The function returns: {ok, ExprList, EndLocation} The parsing was successful. {eof, End...
Erlsom:scan/2 does not create new atoms. It uses string_to_existing_atom to create the atoms that are used in the records. Erlsom:compile_xsd does create atoms. However, usually this function won’t be called with arbitrary end user input as its argument, so normally this should not be...