Created
December 22, 2011 16:14
-
-
Save julienr/1510842 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
# This is a simple pre-processor for a boustrophedonic dialect of the C | |
# programming language : | |
# http://en.wikipedia.org/wiki/Boustrophedonic | |
# | |
# A sample program is : | |
# #include <stdio.h> | |
# { )( niam tni | |
# printf("Hello dlrow\n"); | |
# ;)"n\world olleH"(ftnirp | |
# return 0; | |
# } | |
# | |
# To compile, use ./boustrocc.py foobar.c, it will create a boustro executable | |
# in the current directory | |
from __future__ import with_statement | |
import sys | |
import os | |
if len(sys.argv) < 2: | |
print('Usage %s <input file>'%(sys.argv[0])) | |
TMP_FILE = '/tmp/boustro_file.c' | |
with open(sys.argv[1]) as f, open(TMP_FILE, 'wt') as o: | |
for i, l in enumerate(f): | |
if i%2: | |
o.write(l[::-1]) | |
else: | |
o.write(l) | |
os.system('gcc -o boustro %s'%TMP_FILE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
{ )( niam tni | |
printf("Hello dlrow\n"); | |
;)"n\world olleH"(ftnirp | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment