1st commit
This commit is contained in:
commit
8682ec1c2e
|
@ -0,0 +1,5 @@
|
|||
Cebolla
|
||||
=======
|
||||
|
||||
WIP
|
||||
Atm it's an awk file and a shell script, they transform a file with curly braces and extension .cepa (like **Allium cepa**) into a hopefully valid Nim file.
|
|
@ -0,0 +1,8 @@
|
|||
all: install
|
||||
|
||||
install:
|
||||
cp cebolla.sh cebolla
|
||||
chmod +x cebolla
|
||||
cp cebolla cebolla.awk $(HOME)/bin
|
||||
|
||||
.PHONY: all install
|
|
@ -0,0 +1,43 @@
|
|||
BEGIN {
|
||||
a[1] = ""
|
||||
gap = ""
|
||||
sep = " "
|
||||
indentation_level = 0
|
||||
skip_main = 0
|
||||
i = 0
|
||||
}
|
||||
|
||||
/{[ \t]*$/ {
|
||||
skip_main = 1
|
||||
if(indentation_level > 0) {
|
||||
gsub(/^[ \t][ \t]*/, "")
|
||||
for(i = 0; i < indentation_level; i++) {
|
||||
$0 = sep $0
|
||||
}
|
||||
}
|
||||
indentation_level++
|
||||
gsub(/{[ \t]*$/, "")
|
||||
}
|
||||
|
||||
/^[ \t]*}[ \t]*$/ {
|
||||
indentation_level--
|
||||
if(indentation_level < 0) {
|
||||
indentation_level = 0
|
||||
}
|
||||
gsub(/^[ \t]*}[ \t]*$/, "")
|
||||
}
|
||||
|
||||
{
|
||||
if(skip_main) {
|
||||
skip_main = 0
|
||||
}
|
||||
else {
|
||||
if(indentation_level > 0) {
|
||||
gsub(/^[ \t][ \t]*/, "")
|
||||
for(i = 0; i < indentation_level; i++) {
|
||||
$0 = sep $0
|
||||
}
|
||||
}
|
||||
}
|
||||
print
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
set -x
|
||||
find . -type f | grep '\.cepa$' | {
|
||||
while read f ; do
|
||||
AWKPATH="$AWKPATH:$PATH" awk -f cebolla.awk <$(realpath $f) >$(realpath $f | sed 's/.cepa$/.nim/')
|
||||
done
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
all: ceb file.nim
|
||||
nim c -o:do file.nim
|
||||
|
||||
ceb:
|
||||
cebolla
|
||||
|
||||
.PHONY: all ceb
|
Loading…
Reference in New Issue