示例#1
0
 def parse(self, text):
     input = InputStream(text)
     lexer = GenLtlLexer(input)
     stream = CommonTokenStream(lexer)
     parser = GenLtlParser(stream)
     tree = parser.exp()
     return tree.toStringTree()
示例#2
0
    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]
            )
        }