I have written multiple parser rules in the following format
somerule returns [Clause c]: ... ;
and now I would like to write a python class called Parser
that will return the Clause
object when its method parse
is called. I have started with
class Parser:
def __init__(self, path):
self.lexer = TemporalLogicLexer(FileStream(path))
self.stream = CommonTokenStream(self.lexer)
self.parser = TemporalLogicParser(self.stream)
def parse(self):
# What should I do here? This method should return the parsed Clause object
Can anyone point me in the right direction on how to finish the code?
Nevermind - I have already found the answer:
def parse(self):
return self.parser.somerule().c
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.