home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.functional
- Path: 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
-
- 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
-