commit d785394f3562bb98834ba46043447ffb40c5dd2f Author: heck Date: Thu Jun 15 16:35:18 2023 +0200 Init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ec5d418 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.md +*.xml diff --git a/README.md b/README.md new file mode 100644 index 0000000..d07ea92 --- /dev/null +++ b/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 + + + + diff --git a/compiler/RecipeLang.ysl2 b/compiler/RecipeLang.ysl2 new file mode 100644 index 0000000..20616c2 --- /dev/null +++ b/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» + || + } + +} + diff --git a/grammar/RecipeLang.yml2 b/grammar/RecipeLang.yml2 new file mode 100644 index 0000000..a8bd01c --- /dev/null +++ b/grammar/RecipeLang.yml2 @@ -0,0 +1,12 @@ +// Example language grammar + +DSLName { + dls_data { + a; + b; + c; + } +}; + +decl recipe @name; +decl item @name; diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..85b963b --- /dev/null +++ b/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) diff --git a/src/main.RecipeLang b/src/main.RecipeLang new file mode 100644 index 0000000..f985db3 --- /dev/null +++ b/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... + """; + }; +}; \ No newline at end of file