[erlang-questions] Strings as Lists
Thu Feb 14 00:25:42 CET 2008
On 13/02/2008, Christian S <> wrote:
> On Feb 13, 2008 5:00 AM, Zvi <> wrote:
> > How Ragel is better, than other lexical analysers? Do you use it
> > because it's parsing binary input, why Erlang leexer working with lists?
> Leex is very cool and I have been playing with it some. It generates
> erlang code which is good. I mostly see it as the solution for parsing
Leex works anything, it assumes the input is a list of integers. However
when building the DFA for generating the scanner it assumes 8 bit input. :-(
This, however, is not critical and I have code which would work on *any*
input characters. :-) It would then be able to handle any characters in the
leex .xrl file if you could write the (32-bit) characters and read them in
as a list of integers. Once you get the file into a list you could probably
get it into the Erlang scanner without to much trouble. Just as long you
were a little careful.
As I said lists *are* wonderful for representing strings.
As an aside I can mention that a new regexp package I have does work
directly on binaries. But, much more fun, it also works on lists of
anything, not just integers. So you can define regexps that work on lists of
atoms or tuples or whatever. Do that with UTF-8! :-)
I want non-greedy matching, and also some push down automata support.
> Ragel can do this. With it you can parse quoted strings as a single
> token, and still have incremental parsing (i.e. in chunks). The fact
> that you generate C code from Ragel can also be beneficial in speed
> but of course risky. The higher-level programming of using Ragel can
> hopefully decrease risk of security problems.
Non-greedy is a bit difficult to do if you compile down to pure code like
leex (or lex) but if you do it by interpreting a datastructure then it is
I'm really just experimenting with Ragel as a tool. I still suck at it
> after having spent ~6 hours or so with it.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions