From 56f4bc6107fc3fe5486c8396badb0ca839a5860b Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 13 Feb 2004 22:09:04 +0000 Subject: [PATCH] This version compiles the GCD code. --- mad | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/mad b/mad index 708194e..06de6e2 100755 --- a/mad +++ b/mad @@ -3,7 +3,7 @@ reserved = ('BOOLEAN', 'CONDITIONAL', 'CONTINUE', 'DATA', 'DIMENSION', 'END', 'ENTRY', 'EXECUTE', 'EXTERNAL', 'FOR', 'FUNCTION', 'INTEGER', 'INTERNAL', 'IS', 'MODE', 'NORMAL', - 'OF', 'PAUSE', 'PRINT_FORMAT', 'PROGRAM', 'READ_FORMAT', + 'OF', 'OR', 'PAUSE', 'PRINT_FORMAT', 'PROGRAM', 'READ_FORMAT', 'RESTORE', 'RETURN', 'SAVE', 'SET_LIST_TO', 'THROUGH', 'TO', 'TRANSFER', 'VALUES', 'VECTOR', 'WHENEVER', # COMMENT is a pseudo-keyword generated early in compilation. @@ -14,7 +14,7 @@ tokens = reserved + ( 'NAME','INTNUM', 'DOUBLENUM', 'BOOLNUM', 'STRING', 'FUNCALL', 'LPAREN','RPAREN', 'PLUS','MINUS','TIMES','DIVIDE','EQUALS', - 'NOT', 'OR', 'AND', 'THEN', 'EQV', + 'NOT', 'AND', 'THEN', 'EQV', # See above for OR 'EQ', 'NE', 'LT', 'LE', 'GT', 'GE', 'ABS', 'POW', ) @@ -827,7 +827,10 @@ def print_C_statement(statement): elif statement[0] == 'continue': return "/* continue */;" elif statement[0] in ('end_program', 'end_function', 'end_conditional'): - return "} /* %s */" % statement[0] + rep = "}" + if mad_debug: + rep += " /* %s */" % statement[0] + return rep elif statement[0] == 'entry': currentfunc = statement[1] types = typedict[currentfunc] @@ -891,7 +894,7 @@ def print_C_statement(statement): rep += "((%s [%d]){%s})[%s];" % (statement[3][0][0][:-3], count, ", ".join(map(lambda x: `x[1]`, statement[3])), dummy) return rep elif statement[0] == 'or': - return 'else if (' + print_C_expr(statement[2]) + ') {' + return '} else if (' + print_C_expr(statement[1]) + ') {' elif statement[0] == 'otherwise': return 'else {' elif statement[0] == 'pause': -- 2.43.0