<s> import sys <EOL> import antlr3 <EOL> from antlr3 . tree import CommonTreeAdaptor <EOL> from antlr3 . tree import CommonTree <EOL> from antlr3 . tree import Tree <EOL> from antlr3 . tree import CommonTreeNodeStream <EOL> from antlr3 . tree import * <EOL> from MonitorLexer import MonitorLexer <EOL> from MonitorParser import MonitorParser <EOL> from BuildFSM import BuildFSM <EOL> from abc import ABCMeta , abstractmethod <EOL> class BaseParser : <EOL> __metaclass__ = ABCMeta <EOL> @ abstractmethod <EOL> def parse ( self , filename ) : <EOL> pass <EOL> class ANTLRScribbleParser ( BaseParser ) : <EOL> def parse ( self , filename ) : <EOL> input = antlr3 . FileStream ( filename ) <EOL> lexer = MonitorLexer ( input ) <EOL> tokens = antlr3 . CommonTokenStream ( lexer ) <EOL> parser = MonitorParser ( tokens ) <EOL> adaptor = CommonTreeAdaptor ( ) <EOL> parser . setTreeAdaptor ( adaptor ) <EOL> res = parser . description ( ) <EOL> return res <EOL> def walk ( self , parsedResult ) : <EOL> ast = parsedResult . tree ; <EOL> nodes = CommonTreeNodeStream ( ast ) ; <EOL> fsmBuilder = BuildFSM ( nodes ) ; <EOL> fsmBuilder . description ( ) <EOL> return fsmBuilder <EOL> def main ( args ) : <EOL> pass <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> sys . exit ( main ( sys . argv ) ) </s>
