klex/src/Main.m3


 Copyright (c) 2000 California Institute of Technology 
 All rights reserved. See the file COPYRIGHT for a full description. 
 $Id: Main.m3.html,v 1.3 2010-04-29 17:18:49 wagner Exp $ 

MODULE Main;
IMPORT TokParams;
IMPORT FileWr, Wr, Thread, OSError;
IMPORT FileRdErr;
IMPORT Pathname;
IMPORT LexFmt;
IMPORT Env;
<* FATAL Thread.Alerted, Wr.Failure, OSError.E *>
VAR
  tp := TokParams.Get("lex", ".l", "Lex.i3");
  tok := TokParams.ReadTokens(tp);
  rd := FileRdErr.Open(tp.source);
  lexFmt :=  LexFmt.New(rd, tok, tp.outBase, tp.tokOutBase);
  wr: Wr.T;
BEGIN
  wr := FileWr.Open(tp.out);
  lexFmt.writeInterface(wr);
  Wr.Close(wr);

  wr := FileWr.Open(Pathname.ReplaceExt(tp.out, "m3"));
  lexFmt.writeModule(wr);
  Wr.Close(wr);

  IF Env.Get("lexDEBUG")#NIL THEN lexFmt.test(); END;
END Main.