Skip to content

Instantly share code, notes, and snippets.

@TellowKrinkle
Created July 14, 2017 09:35
Show Gist options
  • Save TellowKrinkle/dcc48094bbd8cbc0e620392246990b4b to your computer and use it in GitHub Desktop.
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
#! /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