Related articles |
---|
dynamic lex library package? bothner@xenon.stanford.edu (1992-07-14) |
Re: dynamic lex library package? kanze@us-es.sel.de (1992-07-15) |
Re: dynamic lex library package? henry@zoo.toronto.edu (1992-07-15) |
Newsgroups: | comp.compilers |
From: | kanze@us-es.sel.de |
Organization: | Compilers Central |
Date: | Wed, 15 Jul 1992 12:14:43 GMT |
Keywords: | lex, question |
References: | 92-07-042 |
bothner@xenon.stanford.edu (Per
M. Bothner) writes:
[looking for a dynamic lexer library]
I've got a regular expression class in C++ that does something like this.
An example of how I've used it:
RegExpr re ;
re |= RegExpr ("[1-9][0-9]*" , 10) ;
re |= RegExpr ("0[0-7]*" , 8) ;
re |= RegExpr ("0[xX][0-9A-Fa-f]+" , 16) ;
use:
const char * str ;
char * endStr ;
int base = re.match (str , &endStr) ;
"base" will contain the base of the numeric string, or -1 if there is no
match. "endStr" will point to the first character *not* part of the
matched string.
The class normally builds a NFA, then builds the DFA by lazy evaluation
(in "match()"). However, there is a function to force it to build the
complete DFA, as well as functions to access the resulting DFA (say to
dump the tables to disk).
I have received several requests (via email) to make the class public, but
there is no anonymous ftp access at my site. Also, I do not presently
have the time to do any maintenance on the classs. (There is at present
at least one known bug: the regular expression will never match an empty
string.) At present, it runs with the Zortech compiler (under MS-DOS).
If someone who has an anonymous ftp on their site is willing to take it
over, I'll try to clean it up, get it to compiler under Sun C++ and g++
(the two compilers I have here) and mail them the sources. All I ask is
that my name rest attached. (I'm a consultant, and I need the publicity
:-)).
--
James Kanze GABI Software, SARL
email: kanze@us-es.sel.de 8 rue du Faisan
67000 Strasbourg
France
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.