Created
July 14, 2017 09:35
-
-
Save TellowKrinkle/dcc48094bbd8cbc0e620392246990b4b to your computer and use it in GitHub Desktop.
A program that strips comments and newlines from tatsu tags so they can be used
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/python | |
import sys | |
if len(sys.argv) < 2: | |
print("Usage: " + sys.argv[0] + " file.tatsu") | |
exit(1) | |
tatsuFileName = sys.argv[1] | |
try: | |
tatsuFile = open(tatsuFileName, "r") | |
except IOError as error: | |
print("Failed to open " + tatsuFileName + ", " + str(error)) | |
exit(1) | |
for line in tatsuFile: | |
line = line.lstrip().rstrip("\r\n") | |
if line.startswith("--"): | |
continue | |
if line.startswith("\\n"): | |
sys.stdout.write("\n") | |
line = line[2:] | |
sys.stdout.write(line) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment