heck 2 years ago
commit
d785394f35
  1. 2
      .gitignore
  2. 13
      README.md
  3. 36
      compiler/RecipeLang.ysl2
  4. 12
      grammar/RecipeLang.yml2
  5. 35
      src/Makefile
  6. 23
      src/main.RecipeLang

2
.gitignore

@ -0,0 +1,2 @@
*.md
*.xml

13
README.md

@ -0,0 +1,13 @@
# Hello YML2 DSL
Hello world style template-project to create
a DSL in yml2
project template featuring:
* dir structure
* build system
* incremental builds

36
compiler/RecipeLang.ysl2

@ -0,0 +1,36 @@
include yslt.yml2
tstylesheet {
include standardlib.ysl2
template "/" {
apply "/DSLName//recipe", 0
}
template "recipe" document "build/recipe_{@name}.md", "text" {
||
# «@name»
## Ingedients
``apply "ingredients", 0
## Preparation
«text()»
||
}
template "ingredients", "text" {
||
The ingredients you need:
``apply "item", 0
||
}
template "item", "text" {
||
* «@name»
||
}
}

12
grammar/RecipeLang.yml2

@ -0,0 +1,12 @@
// Example language grammar
DSLName {
dls_data {
a;
b;
c;
}
};
decl recipe @name;
decl item @name;

35
src/Makefile

@ -0,0 +1,35 @@
# TODO:
# Incremental compilation impossible without redundantly specifying
# files that will be generated in the makefile
DSLNAME=RecipeLang
YML_PATH+=:../grammar
COMPILER=../compiler/$(DSLNAME).ysl2
BUILD_DIR=./build
SRC=$(wildcard *.$(DSLNAME))
SRC_XML=$(addsuffix .xml, $(basename $(SRC)))
$(info $(SRC))
$(info $(SRC_XML))
.PHONY: all compile xml clean
all: compile xml
compile: $(BUILD_DIR)/*
xml: $(SRC_XML)
$(BUILD_DIR)/*: $(BUILD_DIR) $(SRC) $(COMPILER)
YML_PATH=$(YML_PATH) yml2proc -y $(COMPILER) $(SRC)
$(BUILD_DIR):
mkdir $(BUILD_DIR)
%.xml: %.$(DSLNAME)
YML_PATH=$(YML_PATH) yml2proc -P $< -o $@
clean:
rm -rf \
./$(BUILD_DIR)/* \
$(SRC_XML)

23
src/main.RecipeLang

@ -0,0 +1,23 @@
DSLName {
include RecipeLang.yml2
recipe aspargus_soup {
ingredients {
item salt;
item peppa;
};
"long long instructions";
};
recipe crepes {
ingredients {
item flour;
item egg;
item mill;
};
"""
whisk all that stuff together and enjoy
Ow yeah and dont forget to bake it before...
""";
};
};
Loading…
Cancel
Save