
commit
d785394f35
6 changed files with 121 additions and 0 deletions
@ -0,0 +1,2 @@ |
|||
*.md |
|||
*.xml |
@ -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 |
|||
|
|||
|
|||
|
|||
|
@ -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» |
|||
|| |
|||
} |
|||
|
|||
} |
|||
|
@ -0,0 +1,12 @@ |
|||
// Example language grammar |
|||
|
|||
DSLName { |
|||
dls_data { |
|||
a; |
|||
b; |
|||
c; |
|||
} |
|||
}; |
|||
|
|||
decl recipe @name; |
|||
decl item @name; |
@ -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) |
@ -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…
Reference in new issue