From: Eric S. Raymond Date: Fri, 6 Feb 2004 05:44:38 +0000 (+0000) Subject: Rely on continuation punches being present. X-Git-Tag: 1.0~146 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=c691630db98ee2fc187c63e652857e832b50c24a;p=mad.git Rely on continuation punches being present. --- diff --git a/mad b/mad index fd08792..506fd6f 100755 --- a/mad +++ b/mad @@ -787,13 +787,16 @@ if __name__ == '__main__': fp = open(file) source = fp.read() fp.close() - # Grotty hack to remove continuation digits - source = re.sub("\n [0-9] ", "\n ", source) # A grotty hack to transform remarks source = re.sub(r'\tR\n', '\tCOMMENT\n', source) source = re.sub(r'\tR (.*)', '\tCOMMENT $\\1$', source) - # Equally grotty hack to add end-of-statement delimiters - source = re.sub('\n([A-Z]|\t)', ' ;\n\\1', source).rstrip() + ' ;\n' + # Equally grotty hack to add end-of-statement delimiters. + # Put them after every newline, then remove if they're followed + # by whitespace and a continuation digit + source = source.replace("\n", " ;\n") + source = re.sub(';\n(\s*)[0-9]+', '\n\\1', source) + sys.stdout.write(source) + sys.exit(1) # Parse yacc.parse(source, debug=mad_debug)