Example #1
0
 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()}
Example #2
0
    def compile(self, ast):
        """Compile a `quichem` AST into a string of the compiled
        tokens.

        """
        return ''.join(Compiler.compile(self, ast))