def _lift_assembly_decl(location, *args): if len(args) == 2: id, assembly_defn = args else: id = None assembly_defn = args[0] return Assembly(id, composition=assembly_defn.composition, configuration=assembly_defn.configuration, location=location)
def _lift_assembly_defn(location, *args): compositions = [x for x in args if isinstance(x, Composition)] assert len(compositions) == 1 composition = compositions[0] configurations = [x for x in args if isinstance(x, Configuration)] assert len(configurations) <= 1 configuration = configurations[0] if len(configurations) == 1 else None return Assembly(composition=composition, configuration=configuration, location=location)
def p_assembly_defn(t): '''assembly_defn : composition_sing configuration_sing | composition_sing | configuration_sing composition_sing''' if len(t) == 2: assert isinstance(t[1], Composition) or isinstance(t[1], Reference) t[0] = Assembly(composition=t[1]) else: assert len(t) == 3 if isinstance(t[1], Composition) or \ (isinstance(t[1], Reference) and t[1].symbol_type == Composition): assert isinstance(t[2], Configuration) or isinstance(t[2], Reference) t[0] = Assembly(composition=t[1], \ configuration=t[2]) else: assert isinstance(t[1], Configuration) or isinstance(t[1], Reference) assert isinstance(t[2], Composition) or isinstance(t[2], Reference) t[0] = Assembly(composition=t[2], \ configuration=t[1]) t[0].filename = t.lexer.filename t[0].lineno = t.lexer.lineno
def p_assembly_defn(t): '''assembly_defn : composition_sing configuration_sing | composition_sing | configuration_sing composition_sing''' if len(t) == 2: assert isinstance(t[1], Composition) or isinstance(t[1], Reference) t[0] = Assembly(composition=t[1]) else: assert len(t) == 3 if isinstance(t[1], Composition) or \ (isinstance(t[1], Reference) and t[1].symbol_type == Composition): assert isinstance(t[2], Configuration) or isinstance( t[2], Reference) t[0] = Assembly(composition=t[1], \ configuration=t[2]) else: assert isinstance(t[1], Configuration) or isinstance( t[1], Reference) assert isinstance(t[2], Composition) or isinstance(t[2], Reference) t[0] = Assembly(composition=t[2], \ configuration=t[1]) t[0].filename = t.lexer.filename t[0].lineno = t.lexer.lineno