coregrammars 0.1.3

Grammars containing core language features, for creating DSLs and embedded languages


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:

coregrammars

A collection of basic grammars in D / pegged compiled as modules.

Tu use

import coregrammars.gen.json;

enum input = `
{
"Number": 42,
"Decimal": 123.456,
"String": "abc",
"NullString": "",
"Escape": "\uAAAA\n\\Hello",
"Array" : [0,1,2],
"Array2": [0, [0,1,2], "abc"],
"Obj"   : { "Member":0, "Member":[0,1,2] },
"True"  : true,
"False" : false,
"Null"  : null,
"Empty" : {}
}`;

enum nodes = JSONGrammar(input);

assert(nodes[0][0][0].matches == ["Number"]);
assert(nodes[0][0][1].matches == ["42"]);

And so on for the other grammars.

Here is the list of grammars:

  • Terminals: basic terminal expressions such as strings, numbers and booleans.
  • Expressions: arithmetic expressions.
  • INI: standard INI file syntax
  • JSON: standard JSON syntax
  • Markdown: standard markdown syntax

These exist as .peg files in the resources folder.

To regenerate the modules from .peg files, run:

dub test -c modgen && dub run -c modgen && dub test
Authors:
  • Mark Fisher
Dependencies:
pegged
Versions:
0.4.0 2024-Mar-08
0.3.0 2024-Mar-04
0.2.2 2024-Feb-22
0.2.1 2023-Feb-10
0.2.0 2023-Feb-02
Show all 13 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 44 downloads total

Score:
0.6
Short URL:
coregrammars.dub.pm