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/trunk/compiler/Parse/lex/ml.lex
ViewVC logotype

Diff of /sml/trunk/compiler/Parse/lex/ml.lex

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

revision 4060, Fri May 29 07:28:12 2015 UTC revision 4061, Fri May 29 08:10:37 2015 UTC
# Line 4  Line 4 
4   *)   *)
5    
6  open ErrorMsg;  open ErrorMsg;
7    open UserDeclarations;
 structure TokTable = TokenTable(Tokens);  
 type svalue = Tokens.svalue  
 type pos = int  
 type lexresult = (svalue,pos) Tokens.token  
 type lexarg = {  
         comLevel : int ref,  
         sourceMap : SourceMap.sourcemap,  
         charlist : string list ref,  
         stringtype : bool ref,  
         stringstart : int ref, (* start of current string or comment*)  
         brack_stack : int ref list ref, (* for frags *)  
         err : pos*pos -> ErrorMsg.complainer  
       }  
 type arg = lexarg  
 type ('a,'b) token = ('a,'b) Tokens.token  
 fun eof ({comLevel,err,charlist,stringstart,sourceMap, ...} : lexarg) = let  
       val pos = Int.max(!stringstart+2, SourceMap.lastLinePos sourceMap)  
       in  
         if !comLevel>0  
           then err (!stringstart,pos) COMPLAIN "unclosed comment" nullErrorBody  
           else if !charlist <> []  
             then err (!stringstart,pos) COMPLAIN  
                   "unclosed string, character, or quotation" nullErrorBody  
   
             else ();  
         Tokens.EOF(pos,pos)  
       end  
 fun addString (charlist,s:string) = charlist := s :: (!charlist)  
 fun addChar (charlist, c:char) = addString(charlist, String.str c)  
 fun makeString charlist = (concat(rev(!charlist)) before charlist := nil)  
8    
9  local  local
10    fun cvt radix (s, i) =    fun cvt radix (s, i) =
11          #1(valOf(IntInf.scan radix Substring.getc (Substring.triml i (Substring.full s))))          #1(valOf(IntInf.scan radix Substring.getc (Substring.extract(s, i, NONE))))
12  in  in
13  val atoi = cvt StringCvt.DEC  val atoi = cvt StringCvt.DEC
14  val xtoi = cvt StringCvt.HEX  val xtoi = cvt StringCvt.HEX
# Line 55  Line 25 
25             | _ => impossible "ill-formed args in (*#line...*)"             | _ => impossible "ill-formed args in (*#line...*)"
26      end      end
27    
28  fun has_quote s =  fun has_quote s = CharVector.exists (fn #"`" => true | _ => false) s
     let fun loop i = ((String.sub(s,i) = #"`") orelse loop (i+1))  
                      handle _ => false  
      in loop 0  
     end  
29    
30  fun inc (ri as ref i) = (ri := i+1)  fun inc (ri as ref i) = (ri := i+1)
31  fun dec (ri as ref i) = (ri := i-1)  fun dec (ri as ref i) = (ri := i-1)
32  %%  %%
33  %reject  %reject
34  %s A S F Q AQ L LL LLC LLCQ;  %s A S F Q AQ L LL LLC LLCQ;
35  %header (functor MLLexFun(structure Tokens : ML_TOKENS));  %structure MLLex;
36  %arg ({  %arg ({
37    comLevel,    comLevel,
38    sourceMap,    sourceMap,

Legend:
Removed from v.4060  
changed lines
  Added in v.4061

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