|Trie algorithms? email@example.com (Tim McDaniel) (1996-04-29)|
|Re: Trie algorithms? firstname.lastname@example.org (1996-05-04)|
|Re: Trie algorithms? email@example.com (1996-05-06)|
|From:||firstname.lastname@example.org (Timothy A. McDaniel)|
|Date:||6 May 1996 23:19:05 -0400|
|Organization:||CRL Network Services (415) 705-6060 [Login: guest]|
Tim McDaniel <email@example.com> wrote:
>I'm looking for algorithms for quick matching of one of a set of
>fixed strings. ...
>[I'd just use flex, following some of the hints in the documentation
>to make lexers work faster. -John]
Oh, dear,, I was oversimplifying and writing badly.
- I'm really not trying to match strings of characters. They're a
sequence of numeric patterns, not guaranteed to be in the range 0..127
or 0.256. The problem is *isomorphic* to string matching, just with
an integer alphabet. The application is rule-based matching, with
1 1 7 6 : 23 23 3 33
(To be even more detailed: the LHS numbers are token types as returned
by lex. 1 1 7 6 might be "T_alphastring T_alphastring T_twochar
T_digitstring", and 23 23 3 33 might then represent "CITY CITY
- They're not a "fixed" set of patterns. Gad, that was bad wording!
There is a control file that has the list of rules to apply to the
input. That control file is parsed once and all control structures
are set up. Then the rules are applied to each record of the input.
They're only "fixed" in the sense that they don't change while reading
the main input. The rules may change from run to run. Even if flex
could be modified to allow a larger "alphabet", we can't depend on our
customers having it at their sites.
So, with this correction (and I am sorry!), what matching algorithms
would look reasonable? Trie structures look nice, and the property
that an unmatched alphabet character is passed thru unchanged is
actually what we want. However, the algorithms from the 2nd
ed. dragon book don't consider output.
I've received several replies already -- many thanks! Any other
ideas? I would like something easy to find and implement, as I don't
have much time at all to spend on this project.
(Work is firstname.lastname@example.org.)
Never use email@example.com.
Return to the
Search the comp.compilers archives again.