def p_fulltreatment_4(p): "fulltreatment : LINEY LINEY treatment AND treatment" # special case for barrypily: check=lookup(p[1]+p[2]) try: test=issubclass(check,treatment.Treatment) except: test=False if test: p[0]=check(0,p[3],p[5]) else: p[0]=lookup(p[1])(0,lookup(p[2])(0,p[3],p[5]),lookup(p[2])(0,p[5],p[3])) fillin(p[0])
def p_fulltreatment_4(p): "fulltreatment : LINEY LINEY treatment AND treatment" # special case for barrypily: check = lookup(p[1] + p[2]) try: test = issubclass(check, treatment.Treatment) except: test = False if test: p[0] = check(0, p[3], p[5]) else: p[0] = lookup(p[1])(0, lookup(p[2])(0, p[3], p[5]), lookup(p[2])(0, p[5], p[3])) fillin(p[0])
def p_basecharge(p): """basecharge : ORDINARY | PALL | CHARGE | BORDURE | CHIEF | BASE""" p[0] = lookup(p[1])
def p_mullet(p): """mullet : MULLET | MULLET OF amount WORD""" n=5 try: n=p[3] except IndexError: pass p[0]=lookup(p[1])(n)
def p_mullet(p): """mullet : MULLET | MULLET OF amount WORD""" n = 5 try: n = p[3] except IndexError: pass p[0] = lookup(p[1])(n)
def p_division_1_0(p): """division : QUARTERLY PARTYPER ORDINARY LINETYPE""" # For handling "quarterly per pale indented" # ORDINARY had better be "pale" or "fess" lines = {'linetype': 'plain', 'linetypefess': 'plain'} if p[3] == "pale": key = 'linetype' else: key = 'linetypefess' lines[key] = p[4] p[0] = functools.partial(lookup(p[1]), **lines)
def p_optplacement(p): """optplacement : IN optdir CHIEF | IN optdir BASE | empty""" if not p[1]: p[0] = None else: if not p[2]: side = "" else: side = p[2] p[0] = lookup("in " + side + p[3])()
def p_treatment_9(p): """treatment : COLOR SEMY OF almostfullcharge | COLOR SEMYDELIS opttreatment | COLOR SEMY OF GROUPS OF grpcharge | COLOR BEZANTY""" # The second is actually syntactically like ALTERED if len(p) == 5: p[0] = treatment.Semy(treatment.Treatment(p[1]), p[4]) elif len(p) == 4: f = lookup(p[2])() f.tincture = p[3] p[0] = treatment.Semy(treatment.Treatment(p[1]), f) elif len(p) == 7: gp = blazon.BigRect() gp.tincture = treatment.Treatment("proper") gp.addCharge(copy.deepcopy(p[6])) p[0] = treatment.Semy(treatment.Treatment(p[1]), gp) else: # len(p)==3 p[0] = treatment.Semy(treatment.Treatment(p[1]), lookup(p[2])()) if len(p) == 4 and not f.tincture: Globals.extracolorless.append(f)
def p_treatment_9(p): """treatment : COLOR SEMY OF charge | COLOR SEMYDELIS opttreatment | COLOR SEMY OF GROUPS OF group | COLOR BEZANTY""" # The second is actually syntactically like ALTERED if len(p)==5: p[0]=treatment.Semy(treatment.Treatment(p[1]),p[4]) elif len(p)==4: f=lookup(p[2])() f.tincture=p[3] p[0]=treatment.Semy(treatment.Treatment(p[1]),f) elif len(p)==7: gp=blazon.BigRect() gp.tincture=treatment.Treatment("proper") gp.addCharge(copy.deepcopy(p[6])) p[0]=treatment.Semy(treatment.Treatment(p[1]),gp) else: # len(p)==3 p[0]=treatment.Semy(treatment.Treatment(p[1]),lookup(p[2])()) fillin(p[0]) if len(p)==4 and not f.tincture: Globals.extracolorless.append(f)
def p_optarrange(p): """optarrange : IN ORDINARY optinverted | IN PALL optinverted | IN BORDURE | IN ANNULO | empty""" if not p[1]: p[0] = None else: if len(p) > 3: act = p[3] else: act = None p[0] = lookup("in " + p[2])(action=act)
def p_mullet(p): """mullet : MULLET | MULLET OF amount WORD""" if p[1].startswith('mullet'): n = 5 elif p[1] == 'label': n = 3 else: n = 3 # ???? try: n = p[3] except IndexError: pass p[0] = functools.partial(lookup(p[1]), n)
def p_lineyness_2(p): "lineyness : LINEY LINEY optamt" # LINEY LINEY can't have linetype. check = lookup(p[1] + p[2]) if callable(check) and issubclass(check, treatment.Treatment): p[0] = functools.partial(check, 0) else: c1, c2 = p[1], p[2] def rv(x, y, *args, **kwargs): return lookup(c1)(0, lookup(c2)(0, x, y, *args, **kwargs), lookup(c2)(0, y, x, *args, **kwargs)) p[0] = rv
def p_bordure(p): """bordure : empty | WITHIN A BORDURE optlinetype opttreatment | WITHIN A BORDURE optlinetype opttreatment CHARGED WITH charges""" if len(p) <= 2: p[0] = None else: p[0] = lookup(p[3])() if not (p[5]): Globals.colorless.append(p[0]) else: p[0].tincture = p[5] if len(p) >= 9 and p[8]: p[0].extendCharges(p[8]) p[0].lineType = p[4]
def p_bordure(p): """bordure : empty | WITHIN A BORDURE optlinetype opttreatment | WITHIN A BORDURE optlinetype opttreatment CHARGED WITH charges""" if len(p)<=2: p[0]=None else: p[0]=lookup(p[3])() if not(p[5]): Globals.colorless.append(p[0]) else: p[0].tincture=p[5] if len(p)>=9 and p[8]: p[0].extendCharges(p[8]) p[0].lineType=p[4]
def p_division_1(p): "division : PARTYPER ORDINARY mods optlinetype" z = functools.partial(lookup("per " + p[2]), linetype=p[4]) if p[3]: m = p[3] def rv(*ar, **kw): v = z(*ar, **kw) for i in m: # sys.stderr.write("%s\n"%i) v.modify(i) return v p[0] = rv else: p[0] = z
def p_optarrange(p): """optarrange : IN optdir ORDINARY optinverted | IN optdir PALL optinverted | IN optdir CHIEF | IN optdir BORDURE | IN optdir ANNULO | empty""" if not p[1]: p[0] = None else: if not p[2]: side = "" else: side = p[2] if len(p) > 4: # WRONG!!! act = p[4] else: act = None p[0] = lookup("in " + side + p[3])(action=act)
def p_optarrange(p): """optarrange : IN optdir ORDINARY optinverted | IN optdir PALL optinverted | IN optdir CHIEF | IN optdir BORDURE | IN optdir ANNULO | empty""" if not p[1]: p[0]=None else: if not p[2]: side="" else: side=p[2] if len(p)>4: # WRONG!!! act=p[4] else: act=None p[0]=lookup("in "+side+p[3])(action=act)
def p_treatment_5(p): "treatment : FURRY treatment AND treatment" p[0] = lookup(p[1])(p[2], p[4]) fillin(p[0])
def p_treatment_4(p): """treatment : FUR | COUNTERCHARGED""" p[0] = lookup(p[1])() fillin(p[0])
def p_lineyness_1(p): "lineyness : LINEY optlinetype optamt" p[0] = functools.partial(lookup(p[1]), p[3], linetype=p[2])
def p_fulltreatment_3(p): "fulltreatment : LINEY optlinetype optamt treatment AND treatment" p[0] = lookup(p[1])(p[3], p[4], p[6], linetype=p[2]) fillin(p[0])
def p_treatment_5(p): "treatment : FURRY treatment AND treatment" p[0]=lookup(p[1])(p[2],p[4]) fillin(p[0])
def p_multitreatment_5(p): "treatment : FURRY treatment AND treatment" p[0] = lookup(p[1])(p[2], p[4])
def p_ordinary(p): """ordinary : ORDINARY | PALL | CHARGE | CHIEF """ p[0] = lookup(p[1])()
def p_multitreatment_6(p): "treatment : COLOR ALTERED treatment" # "treatment : treatment ALTERED treatment" p[0] = lookup(p[2])(p[1], p[3])
def p_fulltreatment_2(p): "fulltreatment : PARTYPER ORDINARY optinverted optlinetype fulltreatment AND fulltreatment" p[0] = lookup("per " + p[2])(p[5], p[7], linetype=p[4]) for f in p[3]: f(p[0]) fillin(p[0])
def rv(x, y, *args, **kwargs): return lookup(c1)(0, lookup(c2)(0, x, y, *args, **kwargs), lookup(c2)(0, y, x, *args, **kwargs))
def p_ordinary(p): """ordinary : ORDINARY | PALL | CHARGE | CHIEF """ p[0]=lookup(p[1])()
def p_division_2(p): "division : QUARTERLY optinverted optlinetype" p[0] = functools.partial(lookup(p[1]), linetype=p[4])
def p_treatment_7(p): "treatment : QUARTERLY fulltreatment AND fulltreatment" p[0]=lookup(p[1])(p[2],p[4]) fillin(p[0])
def p_treatment_6(p): "treatment : treatment ALTERED treatment" p[0]=lookup(p[2])(p[1],p[3]) fillin(p[0])
def p_treatment_6(p): "treatment : treatment ALTERED treatment" p[0] = lookup(p[2])(p[1], p[3]) fillin(p[0])
def p_treatment_7(p): "treatment : QUARTERLY fulltreatment AND fulltreatment" p[0] = lookup(p[1])(p[2], p[4]) fillin(p[0])
def p_fulltreatment_2(p): "fulltreatment : PARTYPER ORDINARY optinverted optlinetype fulltreatment AND fulltreatment" p[0]=lookup("per "+p[2])(p[5],p[7],linetype=p[4]) for f in p[3]: f(p[0]) fillin(p[0])
def p_multitreatment_2_1(p): "multitreatment : PARTYPER PALL optinverted optlinetype multitreatment multitreatment AND multitreatment" p[0] = lookup("per " + p[2])(p[5], p[6], p[8], linetype=p[4]) for f in p[3]: f(p[0])
def p_fulltreatment_2_1(p): "fulltreatment : PARTYPER PALL optinverted optlinetype fulltreatment fulltreatment AND fulltreatment" p[0]=lookup("per "+p[2])(p[5],p[6],p[8],linetype=p[4]) for f in p[3]: f(p[0]) fillin(p[0])
def p_fulltreatment_3(p): "fulltreatment : LINEY optlinetype optamt treatment AND treatment" p[0]=lookup(p[1])(p[3],p[4],p[6],linetype=p[2]) fillin(p[0])
def p_treatment_4(p): """treatment : FUR | COUNTERCHARGED""" p[0]=lookup(p[1])() fillin(p[0])
def p_fulltreatment_2_1(p): "fulltreatment : PARTYPER PALL optinverted optlinetype fulltreatment fulltreatment AND fulltreatment" p[0] = lookup("per " + p[2])(p[5], p[6], p[8], linetype=p[4]) for f in p[3]: f(p[0]) fillin(p[0])
def p_multitreatment_7(p): "treatment : QUARTERLY multitreatment AND multitreatment" p[0] = lookup(p[1])(p[2], p[4])