Parse static pattern rules. The data part isn't hooked up yet.
authorBenjamin Smedberg <benjamin@smedbergs.us>
Thu, 05 Feb 2009 20:06:21 -0500
changeset 45 996c5791e40cfff1b9956a1fce651788d3437946
parent 44 65ec57ff7d90d5e9a774a3bfc58d5cff48fab51d
child 46 2b81cff1aa0a0670f0a890b1e0b4b8e330571843
push id26
push userbsmedberg@mozilla.com
push dateFri, 06 Feb 2009 01:06:26 +0000
Parse static pattern rules. The data part isn't hooked up yet.
pymake/parser.py
--- a/pymake/parser.py
+++ b/pymake/parser.py
@@ -352,18 +352,45 @@ def parsestream(fd, filename, makefile):
                     vname = e.resolve(makefile.variables, None)
                     value = parsetoend(d, stoppedat + (d[stoppedat] == '=' and 1 or 2), True)
                     if ispattern:
                         for target in targets:
                             setvariable(makefile.getpatternvariables(target), vname, d[stoppedat] == '=', value)
                     else:
                         for target in targets:
                             setvariable(makefile.gettarget(target.gettarget()).variables, vname, d[stoppedat] == '=', value)
+                elif d[stoppedat] == '|':
+                    raise NotImplementedError('order-only prerequisites not implemented')
+                elif d[stoppedat] == ';':
+                    raise NotImplementedError('rule after command not implemented')
                 else:
-                    raise NotImplementedError()
+                    assert d[stoppedat] == ':'
+
+                    # static pattern rule
+                    if ispattern:
+                        raise SyntaxError("static pattern rules must have static targets")
+
+                    patstr = e.resolve(makefile.variables, None)
+                    patterns = data.splitwords(patstr)
+                    if len(patterns) != 1:
+                        raise SyntaxError("A static pattern rule may have only one pattern", d.getloc(stoppedat))
+
+                    pattern = data.Pattern(patterns[0])
+
+                    e, stoppedat = parsemakesyntax(d, stoppedat, ';')
+                    prereqs = map(data.Pattern, data.splitwords(e.resolve(makefile.variables, None)))
+                    currule = data.PatternRule([pattern], prereqs, doublecolon)
+                    for t in targets:
+                        makefile.gettarget(t.gettarget()).addrule(currule)
+
+                    makefile.foundtarget(targets[0].gettarget())
+
+                    if stoppedat != -1:
+                        assert d[stoppedat] == ';'
+                        raise NotImplementedError('rule after command not implemented')
 
 PARSESTATE_TOPLEVEL = 0    # at the top level
 PARSESTATE_FUNCTION = 1    # expanding a function call. data is function
 
 # For the following three, data is a tuple of Expansions: (varname, substfrom, substto)
 PARSESTATE_VARNAME = 2     # expanding a variable expansion.
 PARSESTATE_SUBSTFROM = 3   # expanding a variable expansion substitution "from" value
 PARSESTATE_SUBSTTO = 4     # expanding a variable expansion substitution "to" value