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/src/cm/parse/parse.sml
ViewVC logotype

Diff of /sml/trunk/src/cm/parse/parse.sml

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

revision 297, Thu May 27 08:29:19 1999 UTC revision 301, Fri May 28 09:43:39 1999 UTC
# Line 6  Line 6 
6   * Author: Matthias Blume (blume@kurims.kyoto-u.ac.jp)   * Author: Matthias Blume (blume@kurims.kyoto-u.ac.jp)
7   *)   *)
8  signature CMPARSE = sig  signature CMPARSE = sig
9      val parse : Primitive.configuration -> AbsPath.t -> CMSemant.group option      val parse :
10            GeneralParams.param -> AbsPath.t
11            -> (CMSemant.group * GeneralParams.info) option
12  end  end
13    
14  structure CMParse :> CMPARSE = struct  structure CMParse :> CMPARSE = struct
# Line 25  Line 27 
27                       structure Lex = CMLex                       structure Lex = CMLex
28                       structure LrParser = LrParser)                       structure LrParser = LrParser)
29    
30      fun parse primconf group = let      fun parse param group = let
31    
32          val groupreg = GroupReg.new ()          val groupreg = GroupReg.new ()
33          val fnpolicy = FilenamePolicy.default          val ginfo = { param = param, groupreg = groupreg }
         val params = { groupreg = groupreg,  
                        fnpolicy = fnpolicy,  
                        primconf = primconf,  
                        keep_going = false }  
34    
35          val gc = ref AbsPathMap.empty   (* the "group cache" *)          (* The "group cache" -- we store "group options";  having
36             * NONE registered for a group means that a previous attempt
37             * to parse it had failed. *)
38            val gc = ref (AbsPathMap.empty: CMSemant.group option AbsPathMap.map)
39    
40          fun mparse (group, groupstack) =          fun mparse (group, groupstack) =
41              case AbsPathMap.find (!gc, group) of              case AbsPathMap.find (!gc, group) of
# Line 113  Line 114 
114                       CMSemant.emptyGroup group)                       CMSemant.emptyGroup group)
115    
116                  fun doMember (p, p1, p2, c) =                  fun doMember (p, p1, p2, c) =
117                      CMSemant.member (params, recParse (p1, p2))                      CMSemant.member (ginfo, recParse (p1, p2))
118                                      { sourcepath = p, class = c,                                      { sourcepath = p, class = c,
119                                        group = (group, (p1, p2)) }                                        group = (group, (p1, p2)) }
120    
121                    (* Build the argument for the lexer; the lexer's local
122                     * state is encapsulated here to make sure the parser
123                     * is re-entrant. *)
124                  val lexarg = let                  val lexarg = let
125                      (* local state *)                      (* local state *)
126                      val depth = ref 0                      val depth = ref 0
# Line 185  Line 189 
189                      CMParse.parse (lookAhead, tokenStream,                      CMParse.parse (lookAhead, tokenStream,
190                                     fn (s,p1,p2) => error (p1, p2) s,                                     fn (s,p1,p2) => error (p1, p2) s,
191                                     (group, context, error, recParse,                                     (group, context, error, recParse,
192                                      doMember, params))                                      doMember, ginfo))
193              in              in
194                  TextIO.closeIn stream;                  TextIO.closeIn stream;
195                  if !(#anyErrors source) then NONE                  if !(#anyErrors source) then NONE
# Line 198  Line 202 
202                | [] => normal_processing ()                | [] => normal_processing ()
203          end          end
204    
205            fun finalResult g =
206                (SmlInfo.forgetAllBut (Reachable.reachable g);
207                 (g, ginfo))
208      in      in
209          mparse (group, [])          Option.map finalResult (mparse (group, []))
210      end      end
211  end  end

Legend:
Removed from v.297  
changed lines
  Added in v.301

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