parsing-stream 0.1.1

A simple string stream as a helper for building parsers


To use this package, run the following command in your project's root directory:

parsing-stream

A simple package to help build parsers.

import std.uni;
import std.algorithm;
import parsingstream;

auto stream = new ParsingSteram!char("a fox jumped over\tthe lazy brown dog");
auto words = ["a", "fox", "jumped", "over", "the", "lazy", "brown", "dog"];

while (stream) {

    // `skip` jumps over whitespace
    auto word = stream.skip.match(&isAlpha);
    assert(words.canFind(word));

}

UTF-16, UTF-32 and binary

You can give a type as an argument to the ParsingStream class to decide the type of the stream.

ParsingStream!char;   // UTF-8
ParsingStream!wchar;  // UTF-16
ParsingStream!dchar;  // UTF-32
ParsingStream!ubyte;  // Binary

You can also use it in other ways, for example to match tokens:

import my.tokenizer;

struct Token {

    enum Type { ... }

    Type type;
    string content;

}

auto tokens = tokenize("a fox jumped over the lazy brown dog");
auto stream = new ParsingStream!Token(tokens);

TODO

  • Finish code coverage.
  • Add look or lookAhead.
  • Add an method to repeat operations and return an array, preferably a.repeat(b => ...) also with an out variant.
  • Add untilNext.
  • Add match methods for substrings.
Authors:
  • Soaku
Dependencies:
none
Versions:
0.2.1 2020-Jul-26
0.2.0 2020-Jul-26
0.1.1 2020-Jul-26
0.1.0 2020-Jul-25
Show all 4 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 4 downloads this month

  • 4 downloads total

Score:
0.4
Short URL:
parsing-stream.dub.pm