MODULE; IMPORT Bundle, ObLibOnline, ObValue, Obliq, ObliqParser, SynScan, SynWr, SynParse, TextRd; REVEAL T = Public BRANDED OBJECT env : Obliq.Env; parser : SynParse.T; bundle : Bundle.T; OVERRIDES init := Init; load := Load; get := Get; END; PROCEDURE ObProtoLoader Init (self : T; bundle: Bundle.T) : T = BEGIN self.env := Obliq.EmptyEnv (); self.parser := ObliqParser.New (SynWr.out); self.bundle := bundle; ObLibOnline.RegisterScanner (self.parser.Scanner ()); RETURN self; END Init; PROCEDURELoad (self : T; name : TEXT) = <* FATAL ObValue.Error, ObValue.Exception *> BEGIN WITH rd = TextRd.New (Bundle.Get (self.bundle, name)) DO ObliqParser.ReadFrom (self.parser, "", rd, TRUE, TRUE); END; LOOP TRY SynScan.FirstPrompt (self.parser.Scanner()); WITH phrase = ObliqParser.ParsePhrase (self.parser) DO EVAL ObliqParser.EvalPhrase (self.parser, phrase, self.env); END; EXCEPT | ObliqParser.Eof => RETURN; END; END; END Load; PROCEDUREGet (self : T; qualName : TEXT) : Obliq.Val = <* FATAL ObliqParser.Eof, ObValue.Error, ObValue.Exception *> BEGIN ObliqParser.ReadFrom (self.parser, "", TextRd.New (qualName & ";"), TRUE); RETURN Obliq.EvalPhrase (ObliqParser.ParsePhrase (self.parser), self.env); END Get; BEGIN END ObProtoLoader.