Boost logo

Boost :

From: John Max Skaller (skaller_at_[hidden])
Date: 2001-05-29 11:35:49


Douglas Gregor wrote:

> I mentioned the Acceptor interface because most automata are presented as
> acceptors: DFAs [..] accept or reject a given string

        But while this is theoretically interesting, it is not
as useful in practice as a lexer. A maximal munch lexer is
an easy modification to a DFA. It does two extra things:
first, it multiple Accept symbols (one for each Token kind),
and second, it recognizes and returns a _prefix_ of a string,
not a whole string

> We probably don't want the user to have to subclass Terminal or Nonterminal
> merely for classification purposes - it would get in the way of allowing
> arbitrary types (i.e., char or std::string) as terminals. A trait and/or
> policy class would likely suffice.

        What has subclassing got to do with it??
There is No OO here. Terminal and Nonterminal are concrete
template argument types.

        Actually, there is a problem, because C++ doesn't support
discriminated unions: a grammar production is a list of Symbols,
and a Symbol is either a Terminal or a NonTerminal. This is very
hard to represent correctly in C++.

-- 
John (Max) Skaller, mailto:skaller_at_[hidden]
10/1 Toxteth Rd Glebe NSW 2037 Australia voice: 61-2-9660-0850
checkout Vyper http://Vyper.sourceforge.net
download Interscript http://Interscript.sourceforge.net

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk