def __init__(self): Compiler.__init__(self) self.fragments = { 'separator': fragments.Separator(), 'element': fragments.Element(), 'coefficient': fragments.Coefficient(), 'charge': fragments.Charge(), 'state': fragments.State(), 'counter': fragments.Counter(), 'open group': fragments.OpenCloseGroup(), 'close group': fragments.OpenCloseGroup()} self.token_fragments = {tokened_strings[string]: fragment for string, fragment in self.fragments.items()}
def compile(self, ast): """Compile a `quichem` AST into a string of the compiled tokens. """ return ''.join(Compiler.compile(self, ast))