Leex Character Class Complement

Brady McCary brady.mccary@REDACTED
Sat May 29 00:09:02 CEST 2010


erlang-questions,

I would like to have the complement of a character class in a leex
file, or to be able to subtract character classes. An example xrl file
is as follows:

%%% ---- Beginning of test.xrl ----

Definitions.

A = [ab]{-}[b]

Rules.

{A}+ : {token, {a, TokenLine, TokenChars}}.

Erlang code.

% Nothing

%%% ---- End of test.xrl ----

Compiling test.xrl and using is as follows:

1> leex:file(test,[{verbose, true}]), c(test), test:string("a").
Parsing file ./test.xrl, contained 1 rules.
NFA contains 9 states, DFA contains 6 states, minimised to 6 states.
Writing file ./test.erl, ok
{error,{1,test,{illegal,"a"}},1}

In the above test.xrl, I would hope that A = [a]. and that the rule
{A}+ would match the string "a", but it is not so. Does anybody know
how to do this? The reference for the analogous flex implementation of
the subtraction operator is (search for {-} on the page):

http://flex.sourceforge.net/manual/Patterns.html#Patterns

Brady


More information about the erlang-questions mailing list