🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.functional
Article #560

Including files from ml-lex and -yacc

#560
From: Urban Engberg
Date: Tue, 10 Nov 1992 14:28
29 lines
1567 bytes
In the language of a parser I am writing I want to use the parser
directive %Include <filename> meaning that the file <filename> is to
be included in the parsed file just as if its contents were actually
put there.  I would like to do this inside ml-lex and/or -yacc, which
means that I have to do some operations on the streams that are
generated in the lexer and passed on to the parser.  Has anyone done
this?  How?

This is how I construct the parser:

structure PreParser : PREPARSER =
  struct
    val parse = fn s =>
      let val dev    = open_in s
          val stream = PreParserParser.makeLexer (fn i => input(dev, i))
          val _      = PreParserLex.UserDeclarations.pos := (1, 0)
          val error  = fn (e, (oldline:int, oldchar:int),
			      (newline:int, newchar:int)) => 
            		  output(std_out, "...")
      in PreParserParser.parse(30, stream, error, ()) before close_in dev
      end
  end


--
Urban Engberg					Computer Science Department
urban@daimi.aau.dk				Aarhus University
Phn: +45 86 20 27 11 - 50 91			Ny Munkegade
Fax: +45 86 13 57 25				DK-8000 Aarhus C  --  DENMARK
Technical Details
Message-ID: <1992Nov10.142821.8095@daimi.aau.dk>
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!sunic!dkuug!daimi!urban

Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.functional
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!sunic!dkuug!daimi!urban
From: urban@daimi.aau.dk (Urban Engberg)
Subject: Including files from ml-lex and -yacc
Message-ID: <1992Nov10.142821.8095@daimi.aau.dk>
Keywords: ml-lex ml-yacc sml
Sender: urban@daimi.aau.dk (Urban Engberg)
Organization: DAIMI: Computer Science Department, Aarhus University, Denmark
Date: Tue, 10 Nov 92 14:28:21 GMT
Lines: 29