Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Diff of /sml/branches/SMLNJ/src/ml-lex/lexgen.tex
ViewVC logotype

Diff of /sml/branches/SMLNJ/src/ml-lex/lexgen.tex

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 7, Sun Jan 18 00:59:30 1998 UTC revision 8, Sun Jan 18 01:01:29 1998 UTC
# Line 284  Line 284 
284  \begin{description}  \begin{description}
285  \item[\tt \%reject]     create REJECT() function  \item[\tt \%reject]     create REJECT() function
286  \item[\tt \%count]      count newlines using yylineno  \item[\tt \%count]      count newlines using yylineno
287    \item[\tt \%posarg]     pass initial-position argument to makeLexer
288  \item[\tt \%full]       create lexer for the full 8-bit character set,  \item[\tt \%full]       create lexer for the full 8-bit character set,
289                            with characters in the range 0--255 permitted                            with characters in the range 0--255 permitted
290                            as input.                            as input.
# Line 361  Line 362 
362                                          string, or that matches the longest                                          string, or that matches the longest
363                                          possible prefix of this string,                                          possible prefix of this string,
364                                          is used instead.} \\                                          is used instead.} \\
365  {\tt yypos} & & Current character position from  {\tt yypos} & & \parbox[t]{2.6in}{The position of the first character
366                                          beginning of file.\\  of {\tt yytext}, relative to the beginning of the file.}\\
367  {\tt yylineno } & {\tt \%count} &         Current line number\\  {\tt yylineno } & {\tt \%count} &         Current line number\\
368  \\  \\
369  \end{tabular}  \end{tabular}
# Line 376  Line 377 
377  the lookahead operator {\tt /} will also slow down the entire lexer.  the lookahead operator {\tt /} will also slow down the entire lexer.
378  The character-position, {\tt yypos}, is not costly to maintain, however.  The character-position, {\tt yypos}, is not costly to maintain, however.
379    
380    \paragraph{Bug.} The position of the first character in the file
381    is reported as 2 (unless the {\tt \%posarg} feature is used).
382    To preserve compatibility, this bug has not been fixed.
383    
384  \section{Running ML-Lex}  \section{Running ML-Lex}
385    
386  From the Unix shell, run    {\tt sml-lex~myfile.lex}  From the Unix shell, run    {\tt sml-lex~myfile.lex}
# Line 393  Line 398 
398    
399  When the output file is loaded, it will create a structure Mlex that  When the output file is loaded, it will create a structure Mlex that
400  contains the function {\tt makeLexer} which takes a function from  contains the function {\tt makeLexer} which takes a function from
401  ${\it int} \rightarrow {\it string}$ and returns a lexing function.  ${\it int} \rightarrow {\it string}$ and returns a lexing function:
402    
403    \begin{verbatim}
404      val makeLexer : (int->string) -> yyarg -> lexresult
405    \end{verbatim}
406    where {\tt yyarg} is the type given in the {\tt \%yyarg} directive,
407    or {\tt unit} if there is no {\tt \%yyarg} directive.
408    
409  For example,  For example,
410    
# Line 403  Line 414 
414    
415  creates a lexer that operates on the file whose name is f.  creates a lexer that operates on the file whose name is f.
416    
417    When the {\tt \%posarg} directive is used, the type of
418    {\tt makeLexer} is
419    \begin{verbatim}
420      val makeLexer : ((int->string)*int) -> yyarg -> lexresult
421    \end{verbatim}
422    where the extra {\tt int} argument is one less than the {\tt yypos}
423    of the first character in the input.  The value $k$ would be used,
424    for example, when creating
425    a lexer to start in the middle of a file, when $k$ characters have
426    already been read.  At the beginning of the file, $k=0$ should be used.
427    
428  The ${\it int} \rightarrow {\it string}$ function  The ${\it int} \rightarrow {\it string}$ function
429  should read a string of characters  should read a string of characters
430  from the input stream.  It should return a null string to indicate  from the input stream.  It should return a null string to indicate

Legend:
Removed from v.7  
changed lines
  Added in v.8

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0