def parse(self, text): input = InputStream(text) lexer = GenLtlLexer(input) stream = CommonTokenStream(lexer) parser = GenLtlParser(stream) tree = parser.exp() return tree.toStringTree()
def to_dict(self, formula): self.propositions = [] self.obj = {} self.results = {} input = InputStream(formula) lexer = GenLtlLexer(input) stream = CommonTokenStream(lexer) parser = GenLtlParser(stream) tree = parser.exp() walker = ParseTreeWalker() walker.walk(self, tree) return { 'formula': self.obj, 'propositions': dict( [(self.get_prop_index(p), p) for p in self.propositions] ) }