當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


erlang scan_erl_exprs(Prompt)用法及代碼示例

scan_erl_exprs(Prompt) -> Result
scan_erl_exprs(Device, Prompt) -> Result
scan_erl_exprs(Device, Prompt, StartLocation) -> Result
scan_erl_exprs(Device, Prompt, StartLocation, Options) -> Result
OTP R16B
類型:
Device = device()
Prompt = prompt()
StartLocation = location()
Options = erl_scan:options()
Result = erl_scan:tokens_result() | server_no_data()
server_no_data() = {錯誤,錯誤說明::term()} |埃夫

從標準輸入讀取數據(IoDevice),提示它Prompt。讀取從位置開始StartLocation(1)。爭論Options作為參數傳遞Options函數的 erl_scan:tokens/4。數據被標記化,就好像它是 Erlang 表達式序列,直到最後一個點 (.) 到達了。該令牌也被返回。

該函數返回:


{ok, Tokens, EndLocation}

標記化成功。


{eof, EndLocation}

標記生成器遇到文件結尾。


eof

I/O 服務器遇到文件結尾。


{error, ErrorInfo, ErrorLocation}

標記化時發生錯誤。


{error, ErrorDescription}

其他(罕見)錯誤情況,例如從 NFS 文件係統讀取時為 {error, estale}

例子:

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}

相關用法


注:本文由純淨天空篩選整理自erlang.org大神的英文原創作品 scan_erl_exprs(Prompt) -> Result。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。