d-lex 0.0.2

lexer generator application for d


To use this package, put the following dependency into your project's dependencies section:

dub.json
dub.sdl

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);
Authors:
theoldmoon0602
Dependencies:
none
Versions:
0.0.2 2017-Aug-25
0.0.1 2017-Aug-14
~master 2017-Aug-25
Show all 3 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 2 downloads this month

  • 2 downloads total