Skip to content

A D compile time library that handle lexing, parsing and compilation with an associated syntax free grammar for scripting at compile time and code translation

License

Notifications You must be signed in to change notification settings

DaemonSnake/metaComp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

metaComp

A D library to compile scripts into D at compile time

It handles lexing, parsing and compilation. Has its own associated syntax free grammar based on EBNF.

Example

grammar.txt

root = [var | assign | action]*(';')
var = ["var" id:name ['=' int:value]?:initial ]
assign = [id:name '=' int:value]
action = [id:what [id | int]*(','):args ]

script.txt

var i;
var j;

i = 250;
j = 25;

print i, j, 30;

usage in D

struct Script
{
    mixin fileToGrammar!("grammar.txt"); //create a struct root, var, assign and action
    
    string parser(root value)() { ... } //user implementation
    string parser(var value)() { ... } //user implementation
    string parser(assign value)() { ... } //user implementation
    string parser(action value)() { ... } //user implementation
}

void main()
{
     mixin CompileFile!("scipt.txt", Script.root, Script);
}

Example of output at compile time:

250 25 30

About

A D compile time library that handle lexing, parsing and compilation with an associated syntax free grammar for scripting at compile time and code translation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages