markwatson/expander
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Repository files navigation
Expander lets one run code in other code by allowing one to define functions
that are expanded out by executing them and putting their results back in the
file. The prupose is that given a file or directory, we can expand "macros"
using a given language.
For example:
Macro definition ("hello" is the name, and "python" is the language):
??defm:hello:python(arg1, arg2){{
print "puts 'Hello, %s!!!' \n%s" % (arg1, arg2)
}}
Macro call (eg, in ruby code):
??hello??'Joe'??'puts "Why, dude?"'??
Result:
puts 'Hello, Joe!!!'
puts "Why, dude?"
To call:
python expander.py [FILE|DIRECTORY]
If a file is passed in, the expanded output is printed to stdout. If a
directory is passed in, all files matching *.exp.* will be expanded into
*.* (the '.exp.' being removed).