1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
|
<HTML>
<HEAD>
<!-- refpage -->
<TITLE>erl_scan</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<CENTER>
<A HREF="http://www.erlang.se"><IMG BORDER=0 ALT="[Erlang Systems]" SRC="min_head.gif"></A>
<H1>erl_scan</H1>
</CENTER>
<H3>MODULE</H3>
<UL>
erl_scan</UL>
<H3>MODULE SUMMARY</H3>
<UL>
The Erlang Token Scanner</UL>
<H3>DESCRIPTION</H3>
<UL>
<P>This module contains functions for tokenizing characters into
Erlang tokens.
</UL>
<H3>EXPORTS</H3>
<P><A NAME="string%2"><STRONG><CODE>string(CharList,StartLine]) -> {ok, Tokens, EndLine} | Error</CODE></STRONG></A><BR>
<A NAME="string%1"><STRONG><CODE>string(CharList) -> {ok, Tokens, EndLine} | Error</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>CharList = string()</CODE></STRONG><BR>
<STRONG><CODE>StartLine = EndLine = Line = integer()</CODE></STRONG><BR>
<STRONG><CODE>Tokens = [{atom(),Line}|{atom(),Line,term()}]</CODE></STRONG><BR>
<STRONG><CODE>Error = {error, ErrorInfo, EndLine}</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>Takes the list of characters <CODE>CharList</CODE> and tries to scan (tokenize) them. Returns <CODE>{ok, Tokens, EndLine}</CODE>, where <CODE>Tokens</CODE> are the Erlang tokens
from <CODE>CharList</CODE>. <CODE>EndLine</CODE> is the last line where a token was found.
<P><CODE>StartLine</CODE> indicates the initial line when scanning starts. <CODE>string/1</CODE> is equivalent to <CODE>string(CharList,1)</CODE>.
<P><CODE>{error, ErrorInfo, EndLine}</CODE> is returned if an error occurs.
<CODE>EndLine</CODE> indicates where the error occurred.
</UL>
<P><A NAME="tokens%3"><STRONG><CODE>tokens(Continuation, CharList, StartLine) ->Return</CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>Return = {done, Result, LeftOverChars} | {more, Continuation}</CODE></STRONG><BR>
<STRONG><CODE>Continuation = [] | string()</CODE></STRONG><BR>
<STRONG><CODE>CharList = string()</CODE></STRONG><BR>
<STRONG><CODE>StartLine = EndLine = integer()</CODE></STRONG><BR>
<STRONG><CODE>Result = {ok, Tokens, EndLine} | {eof, EndLine}</CODE></STRONG><BR>
<STRONG><CODE>Tokens = [{atom(),Line}|{atom(),Line,term()}]</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>This is the re-entrant scanner which scans characters until
a <STRONG>dot</STRONG> ('.' whitespace) has been reached. It returns:
<P><DL>
<DT><CODE>{done, Result, LeftOverChars}</CODE></DT>
<DD> This return indicates that there is sufficient input data to get an
input. <CODE>Result</CODE> is:
<BR>
<BR>
<DL>
<DT><CODE>{ok, Tokens, EndLine}</CODE></DT>
<DD> The scanning was successful. <CODE>Tokens</CODE> is the
list of tokens including <STRONG>dot</STRONG>.
<BR>
</DD>
<DT><CODE>{eof, EndLine}</CODE></DT>
<DD> End of file was encountered before any more tokens.
<BR>
</DD>
<DT><CODE>{error, ErrorInfo, EndLine}</CODE></DT>
<DD> An error occurred.
<BR>
</DD>
</DL>
</DD>
<DT><CODE>{more, Continuation}</CODE></DT>
<DD> More data is required for building a term.
<CODE>Continuation</CODE> must be passed in a new call to
<CODE>tokens/3</CODE> when more data is available.
<BR>
</DD>
</DL>
</UL>
<P><A NAME="reserved_word%1"><STRONG><CODE>reserved_word(Atom) -> bool()</CODE></STRONG></A><BR>
<UL>
<P>Returns <CODE>true</CODE> if <CODE>Atom</CODE> is an Erlang reserved
word, otherwise <CODE>false</CODE>.
</UL>
<P><A NAME="format_error%1"><STRONG><CODE>format_error(ErrorDescriptor) -> string() </CODE></STRONG></A><BR>
<P><UL>Types:
<UL>
<STRONG><CODE>ErrorDescriptor = errordesc()</CODE></STRONG><BR>
</UL>
</UL>
<UL>
<P>Takes an <CODE>ErrorDescriptor</CODE> and returns a string which
describes the error or warning. This function is usually
called implicitly when processing an <CODE>ErrorInfo</CODE>
structure (see below).
</UL>
<H3>Error Information</H3>
<UL>
<P>The <CODE>ErrorInfo</CODE> mentioned above is the standard
<CODE>ErrorInfo</CODE> structure which is returned from all IO
modules. It has the following format:
<PRE> {ErrorLine, Module, ErrorDescriptor}</PRE><P>A string which describes the error is obtained with the following call:
<PRE>apply(Module, format_error, ErrorDescriptor)</PRE></UL>
<H3>Notes</H3>
<UL>
<P>The continuation of the first call to the re-entrant input
functions must be <CODE>[]</CODE>. Refer to Armstrong, Virding and Williams, 'Concurrent Programming in Erlang', Chapter 13, for a complete description of how
the re-entrant input scheme works.
</UL>
<H3>See Also</H3>
<UL>
<P><A HREF="io.html">io</A>
<A HREF="erl_parse.html">erl_parse</A>
</UL>
<H3>AUTHORS</H3>
<UL>
Robert Virding - support@erlang.ericsson.se<BR>
</UL>
<CENTER>
<HR>
<FONT SIZE=-1>stdlib 1.10<BR>
Copyright © 1991-2001
<A HREF="http://www.erlang.se">Ericsson Utvecklings AB</A><BR>
<!--#include virtual="/ssi/otp_footer.html"-->
</FONT>
</CENTER>
</BODY>
</HTML>
|