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

SCM Repository

[smlnj] Annotation of /sml/trunk/src/compiler/MiscUtil/util/source.sml
ViewVC logotype

Annotation of /sml/trunk/src/compiler/MiscUtil/util/source.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 651 - (view) (download)

1 : monnier 245 (* <source.sml>= *)
2 :     (* source.sml
3 :     *
4 :     * COPYRIGHT (c) 1996 Bell Laboratories.
5 :     *
6 :     *)
7 :    
8 :     structure Source : SOURCE =
9 :     struct
10 :    
11 :     type inputSource = {
12 :     sourceMap: SourceMap.sourcemap,
13 :     fileOpened: string,
14 :     anyErrors: bool ref,
15 :     errConsumer: PrettyPrint.ppconsumer,
16 :     interactive: bool,
17 :     sourceStream: TextIO.instream
18 :     }
19 :    
20 :     fun say (msg : string) = Control.Print.say msg
21 :    
22 :     val lexer_initial_position = 2 (* position of first char according to ml-lex *)
23 :    
24 :     fun newSource(fileName,lineNum,sourceStream,interactive, errConsumer) =
25 :     {sourceMap=SourceMap.newmap(lexer_initial_position,
26 :     {fileName=fileName, line=lineNum, column=1}),
27 :     sourceStream=sourceStream,interactive=interactive,fileOpened=fileName,
28 :     errConsumer=errConsumer,anyErrors=ref false}
29 :    
30 :     fun closeSource ({interactive=true, ...} : inputSource) = ()
31 :     | closeSource ({sourceStream, ...}) = (
32 :     (* app say ["[closing ", (Pathnames.trim fileName), "]\n"];*)
33 :     TextIO.closeIn sourceStream handle IO.Io _ => ())
34 :    
35 :     fun filepos({sourceMap,...}: inputSource) pos =
36 :     let val {fileName, line, column} = SourceMap.filepos sourceMap pos
37 :     in (fileName, line, column)
38 :     end
39 :    
40 :     end (* structure Source *)
41 :    

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