Skip to content
lexer library for d
D
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
source/dlex
.gitignore
README.md
dub.json

README.md

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);
You can’t perform that action at this time.