Article View: comp.lang.functional
Article #27Re: Functional Parsers
From: Stephen J Bevan
Date: Sun, 01 Nov 1992 14:13
Date: Sun, 01 Nov 1992 14:13
61 lines
3175 bytes
3175 bytes
There have been a few requests regarding parsing recently so I thought
I'd bundle up a (incomplete) paper I wrote and make it available. You
can get it by anonymous ftp as :-
pub/haskell/library/bevan/parsing.tar.Z:anonymous@animal.cs.chalmers.se
Here is the README file that comes with it :-
The associated DVI file contains an _incomplete_ _draft_[1] of a paper
about a simple method for parsing LL(1) languages[2]. It discusses a
variation[3] of the LL(1) method using continuations to drive the parsing
process. The paper describes the construction of a parser and lexer
for the toy language Asple. Haskell is used as the implementation
language and use is made of Haskell's ability to declare infix
operators so that the programs look similar to ordinary BNF.
The complete code is available as either "asple.gs" (for Gofer) or
"asple.hs" (see details at the end).
Note there is no discussion of constructing an abstract syntax tree
(that is due in a later paper, when I've actually finished the current
one!), for information on how to do this, see the file "asple_cc.shar"
which contains a parser that builds an abstract syntax for Asple and
then checks the associated context conditions. The code does contain
comments so it shouldn't be too hard to work out what is going on.
-------
[1] I intended to finish it back in August, but events have overtaken
me. I'm only making it available in its incomplete form since
there have been a number of requests regarding writing (simple)
parsers in functional languages.
[2] With judicious fiddling of the continuations, it should be possible
to create a backtracking parser and so deal with a large class of
grammars.
[3] Since writing most of the paper I found the same sort of method
being used in an example file in the Edinburgh ML library. The
difference being that there "exceptions" are used instead of
continuations.
Obtaining source code
---------------------
The files mentioned previously are all available by anonymous ftp from
the Haskell library (as is this file) :-
pub/haskell/library:anonymous@dcs.glasgow.ac.uk
pub/haskell/library:anonymous@nebula.cs.yale.edu
pub/haskell/library:anonymous@animal.cs.chalmers.se
pub/haskell/library/bevan:anonymous@animal.cs.chalmers.se
or by mail server :-
To: bevan@cs.man.ac.uk
Subject: b-server-request
send haskell/asple.gs
... etc. for other files.
If you have any problems obtaining files, comments on the paper or
code, ... etc., feel free to contact me :-
Stephen J. Bevan <bevan@cs.man.ac.uk> 19921101
Technical Details
Message-ID:
<BEVAN.92Nov1141304@otter.cs.man.ac.uk>Path:
arc1-ca.pugleaf.net!sparky!uunet!haven.umd.edu!ames!agate!doc.ic.ac.uk!uknet!mucs!m1!bevanReferences:
<1992Oct29.095529.17894@Informatik.TU-Muenchen.DE>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!haven.umd.edu!ames!agate!doc.ic.ac.uk!uknet!mucs!m1!bevan From: bevan@cs.man.ac.uk (Stephen J Bevan) Newsgroups: comp.lang.functional Subject: Re: Functional Parsers Message-ID: <BEVAN.92Nov1141304@otter.cs.man.ac.uk> Date: 1 Nov 92 14:13:04 GMT References: <1992Oct29.095529.17894@Informatik.TU-Muenchen.DE> Sender: news@cs.man.ac.uk Organization: Department of Computer Science, University of Manchester Lines: 61 In-reply-to: nipkow@Informatik.TU-Muenchen.DE's message of 29 Oct 92 09:55:29 GMT