From: Eric S. Raymond Date: Tue, 17 Feb 2004 21:31:25 +0000 (+0000) Subject: Now we compile the payroll example. X-Git-Tag: 1.0~98 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=2c43426f8e33ee4000fe071342a40e55a1dc304a;p=mad.git Now we compile the payroll example. --- diff --git a/mad b/mad index 06f753d..eccd0fc 100755 --- a/mad +++ b/mad @@ -72,9 +72,11 @@ def t_NAME(t): return t def t_DOUBLENUM(t): - r'\d+\.\d*' + r'(\d+\.\d*|\.\d+)' if t.value[-1] == '.': t.value += "0" + if t.value[0] == '.': + t.value = "0" + t.value return t def t_BOOLNUM(t): @@ -532,6 +534,15 @@ def analyze(): if statement[0] == 'end_function' and i < len(deck)-1 and deck[i+1][3][0] != 'extern': deck.insert(i+1, (file, line, None, ('entry', 'main.', ()))) hasmain = True + # Sanity check -- all labels in through statements must hit targwts + labels = filter(lambda x: x, map(lambda x: x[2], deck)) + for (file, line, label, statement) in deck: + if statement[0] == 'for': + target = statement[1] + if not target in labels: + croak((file,line,label,statement),"no such label as "+`target`) + sys.exit(1) + # On to actual analysis try: # Mine the code for compile-time directives for (file, line, label, statement) in deck: