Lines Matching refs:self

36     def __init__(self, stream, state=None, dbg=None, *args, **kwargs):  argument
41 super(DebugParser, self).__init__(stream, state, *args, **kwargs)
44 self._dbg = None
46 self.setDebugListener(dbg)
49 def setDebugListener(self, dbg): argument
54 if hasattr(self.input, 'dbg'):
55 self.input.dbg = dbg
57 self._dbg = dbg
59 def getDebugListener(self): argument
60 return self._dbg
65 def beginResync(self): argument
66 self._dbg.beginResync()
69 def endResync(self): argument
70 self._dbg.endResync()
73 def beginBacktrack(self, level): argument
74 self._dbg.beginBacktrack(level)
77 def endBacktrack(self, level, successful): argument
78 self._dbg.endBacktrack(level,successful)
81 def reportError(self, exc): argument
82 Parser.reportError(self, exc)
85 self._dbg.recognitionException(exc)
89 def __init__(self, input, dbg=None): argument
90 self.input = input
91 self.initialStreamState = True
93 self.lastMarker = None
95 self._dbg = None
96 self.setDebugListener(dbg)
100 self.input.LT(1)
103 def getDebugListener(self): argument
104 return self._dbg
106 def setDebugListener(self, dbg): argument
107 self._dbg = dbg
112 def consume(self): argument
113 if self.initialStreamState:
114 self.consumeInitialHiddenTokens()
116 a = self.input.index()
117 t = self.input.LT(1)
118 self.input.consume()
119 b = self.input.index()
120 self._dbg.consumeToken(t)
125 self._dbg.consumeHiddenToken(self.input.get(idx));
128 def consumeInitialHiddenTokens(self): argument
131 firstOnChannelTokenIndex = self.input.index()
133 self._dbg.consumeHiddenToken(self.input.get(idx))
135 self.initialStreamState = False
138 def LT(self, i): argument
139 if self.initialStreamState:
140 self.consumeInitialHiddenTokens()
142 t = self.input.LT(i)
143 self._dbg.LT(i, t)
147 def LA(self, i): argument
148 if self.initialStreamState:
149 self.consumeInitialHiddenTokens()
151 t = self.input.LT(i)
152 self._dbg.LT(i, t)
156 def get(self, i): argument
157 return self.input.get(i)
160 def index(self): argument
161 return self.input.index()
164 def mark(self): argument
165 self.lastMarker = self.input.mark()
166 self._dbg.mark(self.lastMarker)
167 return self.lastMarker
170 def rewind(self, marker=None): argument
171 self._dbg.rewind(marker)
172 self.input.rewind(marker)
175 def release(self, marker): argument
179 def seek(self, index): argument
182 self.input.seek(index)
185 def size(self): argument
186 return self.input.size()
189 def getTokenSource(self): argument
190 return self.input.getTokenSource()
193 def getSourceName(self): argument
194 return self.getTokenSource().getSourceName()
197 def toString(self, start=None, stop=None): argument
198 return self.input.toString(start, stop)
215 def __init__(self, dbg, adaptor): argument
216 self.dbg = dbg
217 self.adaptor = adaptor
220 def createWithPayload(self, payload): argument
223 return self.createFromType(payload.getType(), payload.getText())
225 node = self.adaptor.createWithPayload(payload)
226 self.dbg.createNode(node, payload)
229 def createFromToken(self, tokenType, fromToken, text=None): argument
230 node = self.adaptor.createFromToken(tokenType, fromToken, text)
231 self.dbg.createNode(node)
234 def createFromType(self, tokenType, text): argument
235 node = self.adaptor.createFromType(tokenType, text)
236 self.dbg.createNode(node)
240 def errorNode(self, input, start, stop, exc): argument
248 def dupTree(self, tree): argument
249 t = self.adaptor.dupTree(tree)
253 self.simulateTreeConstruction(t)
257 def simulateTreeConstruction(self, t): argument
259 self.dbg.createNode(t)
260 for i in range(self.adaptor.getChildCount(t)):
261 child = self.adaptor.getChild(t, i)
262 self.simulateTreeConstruction(child)
263 self.dbg.addChild(t, child)
266 def dupNode(self, treeNode): argument
267 d = self.adaptor.dupNode(treeNode)
268 self.dbg.createNode(d)
272 def nil(self): argument
273 node = self.adaptor.nil()
274 self.dbg.nilNode(node)
278 def isNil(self, tree): argument
279 return self.adaptor.isNil(tree)
282 def addChild(self, t, child): argument
284 n = self.createWithPayload(child)
285 self.addChild(t, n)
291 self.adaptor.addChild(t, child)
292 self.dbg.addChild(t, child)
294 def becomeRoot(self, newRoot, oldRoot): argument
296 n = self.createWithPayload(newRoot)
297 self.adaptor.becomeRoot(n, oldRoot)
299 n = self.adaptor.becomeRoot(newRoot, oldRoot)
301 self.dbg.becomeRoot(newRoot, oldRoot)
305 def rulePostProcessing(self, root): argument
306 return self.adaptor.rulePostProcessing(root)
309 def getType(self, t): argument
310 return self.adaptor.getType(t)
313 def setType(self, t, type): argument
314 self.adaptor.setType(t, type)
317 def getText(self, t): argument
318 return self.adaptor.getText(t)
321 def setText(self, t, text): argument
322 self.adaptor.setText(t, text)
325 def getToken(self, t): argument
326 return self.adaptor.getToken(t)
329 def setTokenBoundaries(self, t, startToken, stopToken): argument
330 self.adaptor.setTokenBoundaries(t, startToken, stopToken)
332 self.dbg.setTokenBoundaries(
337 def getTokenStartIndex(self, t): argument
338 return self.adaptor.getTokenStartIndex(t)
341 def getTokenStopIndex(self, t): argument
342 return self.adaptor.getTokenStopIndex(t)
345 def getChild(self, t, i): argument
346 return self.adaptor.getChild(t, i)
349 def setChild(self, t, i, child): argument
350 self.adaptor.setChild(t, i, child)
353 def deleteChild(self, t, i): argument
354 return self.adaptor.deleteChild(t, i)
357 def getChildCount(self, t): argument
358 return self.adaptor.getChildCount(t)
361 def getUniqueID(self, node): argument
362 return self.adaptor.getUniqueID(node)
365 def getParent(self, t): argument
366 return self.adaptor.getParent(t)
369 def getChildIndex(self, t): argument
370 return self.adaptor.getChildIndex(t)
373 def setParent(self, t, parent): argument
374 self.adaptor.setParent(t, parent)
377 def setChildIndex(self, t, index): argument
378 self.adaptor.setChildIndex(t, index)
381 def replaceChildren(self, parent, startChildIndex, stopChildIndex, t): argument
382 self.adaptor.replaceChildren(parent, startChildIndex, stopChildIndex, t)
387 def getDebugListener(self): argument
390 def setDebugListener(self, dbg): argument
391 self.dbg = dbg
394 def getTreeAdaptor(self): argument
395 return self.adaptor
413 def enterRule(self, grammarFileName, ruleName): argument
424 def enterAlt(self, alt): argument
431 def exitRule(self, grammarFileName, ruleName): argument
442 def enterSubRule(self, decisionNumber): argument
447 def exitSubRule(self, decisionNumber): argument
451 def enterDecision(self, decisionNumber, couldBacktrack): argument
461 def exitDecision(self, decisionNumber): argument
465 def consumeToken(self, t): argument
472 def consumeHiddenToken(self, t): argument
480 def LT(self, i, t): argument
491 def mark(self, marker): argument
498 def rewind(self, marker=None): argument
507 def beginBacktrack(self, level): argument
511 def endBacktrack(self, level, successful): argument
515 def location(self, line, pos): argument
527 def recognitionException(self, e): argument
587 def beginResync(self): argument
595 def endResync(self): argument
607 def semanticPredicate(self, result, predicate): argument
612 def commence(self): argument
623 def terminate(self): argument
634 def consumeNode(self, t): argument
646 def LT(self, i, t): argument
657 def nilNode(self, t): argument
670 def errorNode(self, t): argument
677 def createNode(self, node, token=None): argument
687 def becomeRoot(self, newRoot, oldRoot): argument
707 def addChild(self, root, child): argument
718 def setTokenBoundaries(self, t, tokenStartIndex, tokenStopIndex): argument
747 def __init__(self, adaptor=None): argument
748 super(TraceDebugEventListener, self).__init__()
752 self.adaptor = adaptor
754 def record(self, event): argument
757 def enterRule(self, grammarFileName, ruleName): argument
758 self.record("enterRule "+ruleName)
760 def exitRule(self, grammarFileName, ruleName): argument
761 self.record("exitRule "+ruleName)
763 def enterSubRule(self, decisionNumber): argument
764 self.record("enterSubRule")
766 def exitSubRule(self, decisionNumber): argument
767 self.record("exitSubRule")
769 def location(self, line, pos): argument
770 self.record("location %s:%s" % (line, pos))
774 def consumeNode(self, t): argument
775 self.record("consumeNode %s %s %s" % (
776 self.adaptor.getUniqueID(t),
777 self.adaptor.getText(t),
778 self.adaptor.getType(t)))
780 def LT(self, i, t): argument
781 self.record("LT %s %s %s %s" % (
783 self.adaptor.getUniqueID(t),
784 self.adaptor.getText(t),
785 self.adaptor.getType(t)))
789 def nilNode(self, t): argument
790 self.record("nilNode %s" % self.adaptor.getUniqueID(t))
792 def createNode(self, t, token=None): argument
794 self.record("create %s: %s, %s" % (
795 self.adaptor.getUniqueID(t),
796 self.adaptor.getText(t),
797 self.adaptor.getType(t)))
800 self.record("create %s: %s" % (
801 self.adaptor.getUniqueID(t),
804 def becomeRoot(self, newRoot, oldRoot): argument
805 self.record("becomeRoot %s, %s" % (
806 self.adaptor.getUniqueID(newRoot),
807 self.adaptor.getUniqueID(oldRoot)))
809 def addChild(self, root, child): argument
810 self.record("addChild %s, %s" % (
811 self.adaptor.getUniqueID(root),
812 self.adaptor.getUniqueID(child)))
814 def setTokenBoundaries(self, t, tokenStartIndex, tokenStopIndex): argument
815 self.record("setTokenBoundaries %s, %s, %s" % (
816 self.adaptor.getUniqueID(t),
823 def __init__(self, adaptor=None): argument
824 super(RecordDebugEventListener, self).__init__(adaptor)
826 self.events = []
828 def record(self, event): argument
829 self.events.append(event)
842 def __init__(self, recognizer, adaptor=None, port=None, argument
844 super(DebugEventSocketProxy, self).__init__()
846 self.grammarFileName = recognizer.getGrammarFileName()
851 self.adaptor = adaptor
853 self.port = port or self.DEFAULT_DEBUGGER_PORT
855 self.debug = debug
857 self.socket = None
858 self.connection = None
859 self.input = None
860 self.output = None
863 def log(self, msg): argument
864 if self.debug is not None:
865 self.debug.write(msg + '\n')
868 def handshake(self): argument
869 if self.socket is None:
871 self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
872 self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
873 self.socket.bind(('', self.port))
874 self.socket.listen(1)
875 self.log("Waiting for incoming connection on port %d" % self.port)
878 self.connection, addr = self.socket.accept()
879 self.log("Accepted connection from %s:%d" % addr)
881 self.connection.setblocking(1)
882 self.connection.setsockopt(socket.SOL_TCP, socket.TCP_NODELAY, 1)
885 self.output = self.connection.makefile('w', 0)
886 self.input = self.connection.makefile('r', 0)
888 self.write("ANTLR %s" % self.PROTOCOL_VERSION)
889 self.write("grammar \"%s" % self.grammarFileName)
890 self.ack()
893 def write(self, msg): argument
894 self.log("> %s" % msg)
895 self.output.write("%s\n" % msg)
896 self.output.flush()
899 def ack(self): argument
900 t = self.input.readline()
901 self.log("< %s" % t.rstrip())
904 def transmit(self, event): argument
905 self.write(event);
906 self.ack();
909 def commence(self): argument
914 def terminate(self): argument
915 self.transmit("terminate")
916 self.output.close()
917 self.input.close()
918 self.connection.close()
919 self.socket.close()
922 def enterRule(self, grammarFileName, ruleName): argument
923 self.transmit("enterRule\t%s\t%s" % (grammarFileName, ruleName))
926 def enterAlt(self, alt): argument
927 self.transmit("enterAlt\t%d" % alt)
930 def exitRule(self, grammarFileName, ruleName): argument
931 self.transmit("exitRule\t%s\t%s" % (grammarFileName, ruleName))
934 def enterSubRule(self, decisionNumber): argument
935 self.transmit("enterSubRule\t%d" % decisionNumber)
938 def exitSubRule(self, decisionNumber): argument
939 self.transmit("exitSubRule\t%d" % decisionNumber)
942 def enterDecision(self, decisionNumber, couldBacktrack): argument
943 self.transmit(
947 def exitDecision(self, decisionNumber): argument
948 self.transmit("exitDecision\t%d" % decisionNumber)
951 def consumeToken(self, t): argument
952 self.transmit("consumeToken\t%s" % self.serializeToken(t))
955 def consumeHiddenToken(self, t): argument
956 self.transmit("consumeHiddenToken\t%s" % self.serializeToken(t))
959 def LT(self, i, o): argument
961 return self.LT_tree(i, o)
962 return self.LT_token(i, o)
965 def LT_token(self, i, t): argument
967 self.transmit("LT\t%d\t%s" % (i, self.serializeToken(t)))
970 def mark(self, i): argument
971 self.transmit("mark\t%d" % i)
974 def rewind(self, i=None): argument
976 self.transmit("rewind\t%d" % i)
978 self.transmit("rewind")
981 def beginBacktrack(self, level): argument
982 self.transmit("beginBacktrack\t%d" % level)
985 def endBacktrack(self, level, successful): argument
986 self.transmit("endBacktrack\t%d\t%s" % (
990 def location(self, line, pos): argument
991 self.transmit("location\t%d\t%d" % (line, pos))
994 def recognitionException(self, exc): argument
995 self.transmit('\t'.join([
1003 def beginResync(self): argument
1004 self.transmit("beginResync")
1007 def endResync(self): argument
1008 self.transmit("endResync")
1011 def semanticPredicate(self, result, predicate): argument
1012 self.transmit('\t'.join([
1015 self.escapeNewlines(predicate)]))
1019 def consumeNode(self, t): argument
1027 def LT_tree(self, i, t): argument
1039 def serializeNode(self, buf, t): argument
1067 def nilNode(self, t): argument
1068 self.transmit("nilNode\t%d" % self.adaptor.getUniqueID(t))
1071 def errorNode(self, t): argument
1072 self.transmit("errorNode\t%d\t%d\t\"%s" % (
1073 self.adaptor.getUniqueID(t),
1075 self.escapeNewlines(t.toString())))
1079 def createNode(self, node, token=None): argument
1081 self.transmit("createNode\t%d\t%d" % (
1082 self.adaptor.getUniqueID(node),
1086 self.transmit("createNodeFromTokenElements\t%d\t%d\t\"%s" % (
1087 self.adaptor.getUniqueID(node),
1088 self.adaptor.getType(node),
1089 self.adaptor.getText(node)))
1092 def becomeRoot(self, newRoot, oldRoot): argument
1093 self.transmit("becomeRoot\t%d\t%d" % (
1094 self.adaptor.getUniqueID(newRoot),
1095 self.adaptor.getUniqueID(oldRoot)))
1098 def addChild(self, root, child): argument
1099 self.transmit("addChild\t%d\t%d" % (
1100 self.adaptor.getUniqueID(root),
1101 self.adaptor.getUniqueID(child)))
1104 def setTokenBoundaries(self, t, tokenStartIndex, tokenStopIndex): argument
1105 self.transmit("setTokenBoundaries\t%d\t%d\t%d" % (
1106 self.adaptor.getUniqueID(t),
1113 def setTreeAdaptor(self, adaptor): argument
1114 self.adaptor = adaptor
1116 def getTreeAdaptor(self): argument
1117 return self.adaptor
1120 def serializeToken(self, t): argument
1126 '\"' + self.escapeNewlines(t.getText())]
1130 def escapeNewlines(self, txt): argument