d-lex 0.0.2
lexer generator application for d
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
D-Lex
Lexical analyzer implemented by D-lang.
___--^^^^^^^
/ o
/
vvvvvvvv
</
</ ___/
^^^^^ ___/
\______/
this is
_人人人人_\ > T-rex <\  ̄Y^Y^Y^Y^ ̄
Usage
See unittest in source/dlex/test.d
enum Type {
Ident,
Number,
Space
}
import std.uni;
auto dlex = new DLex!(Type);
dlex.Rules([
dlex.RuleT(Type.Ident, Pred(&isAlpha) + Pred(&isAlphaNum).Repeat),
dlex.RuleT(Type.Number, Pred(&isNumber).Repeat),
dlex.RuleT(Type.Space, Pred(&isSpace).Skip),
]);
auto rs = dlex.Lex("Int 123");
assert(rs.length == 2);
assert(rs[0].str == "Int");
assert(rs[0].pos.col == 1);
assert(rs[1].str == "123");
assert(rs[1].pos.col == 5);
- 0.0.2 released 7 years ago
- theoldmoon0602/D-lex
- MIT
- Copyright © 2017, theoldmoon0602
- Authors:
- Dependencies:
- none
- Versions:
-
0.0.2 2017-Aug-25 0.0.1 2017-Aug-14 ~master 2017-Aug-25 - Download Stats:
-
-
0 downloads today
-
0 downloads this week
-
0 downloads this month
-
0 downloads total
-
- Score:
- 0.6
- Short URL:
- d-lex.dub.pm