Server IP : 103.119.228.120 / Your IP : 3.142.212.153 Web Server : Apache System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64 User : nobody ( 99) PHP Version : 5.6.40 Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice,proc_terminate,proc_get_status,proc_close,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,dl,symlink,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/lib/mysqlsh/lib/python3.9/site-packages/antlr4/tree/ |
Upload File : |
# Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. # Use of this file is governed by the BSD 3-clause license that # can be found in the LICENSE.txt file in the project root. #/ # The basic notion of a tree has a parent, a payload, and a list of children. # It is the most abstract interface for all the trees used by ANTLR. #/ from antlr4.Token import Token INVALID_INTERVAL = (-1, -2) class Tree(object): pass class SyntaxTree(Tree): pass class ParseTree(SyntaxTree): pass class RuleNode(ParseTree): pass class TerminalNode(ParseTree): pass class ErrorNode(TerminalNode): pass class ParseTreeVisitor(object): def visit(self, tree): return tree.accept(self) def visitChildren(self, node): result = self.defaultResult() n = node.getChildCount() for i in range(n): if not self.shouldVisitNextChild(node, result): return result c = node.getChild(i) childResult = c.accept(self) result = self.aggregateResult(result, childResult) return result def visitTerminal(self, node): return self.defaultResult() def visitErrorNode(self, node): return self.defaultResult() def defaultResult(self): return None def aggregateResult(self, aggregate, nextResult): return nextResult def shouldVisitNextChild(self, node, currentResult): return True ParserRuleContext = None class ParseTreeListener(object): def visitTerminal(self, node:TerminalNode): pass def visitErrorNode(self, node:ErrorNode): pass def enterEveryRule(self, ctx:ParserRuleContext): pass def exitEveryRule(self, ctx:ParserRuleContext): pass del ParserRuleContext class TerminalNodeImpl(TerminalNode): __slots__ = ('parentCtx', 'symbol') def __init__(self, symbol:Token): self.parentCtx = None self.symbol = symbol def __setattr__(self, key, value): super().__setattr__(key, value) def getChild(self, i:int): return None def getSymbol(self): return self.symbol def getParent(self): return self.parentCtx def getPayload(self): return self.symbol def getSourceInterval(self): if self.symbol is None: return INVALID_INTERVAL tokenIndex = self.symbol.tokenIndex return (tokenIndex, tokenIndex) def getChildCount(self): return 0 def accept(self, visitor:ParseTreeVisitor): return visitor.visitTerminal(self) def getText(self): return self.symbol.text def __str__(self): if self.symbol.type == Token.EOF: return "<EOF>" else: return self.symbol.text # Represents a token that was consumed during resynchronization # rather than during a valid match operation. For example, # we will create this kind of a node during single token insertion # and deletion as well as during "consume until error recovery set" # upon no viable alternative exceptions. class ErrorNodeImpl(TerminalNodeImpl,ErrorNode): def __init__(self, token:Token): super().__init__(token) def accept(self, visitor:ParseTreeVisitor): return visitor.visitErrorNode(self) class ParseTreeWalker(object): DEFAULT = None def walk(self, listener:ParseTreeListener, t:ParseTree): """ Performs a walk on the given parse tree starting at the root and going down recursively with depth-first search. On each node, {@link ParseTreeWalker#enterRule} is called before recursively walking down into child nodes, then {@link ParseTreeWalker#exitRule} is called after the recursive call to wind up. @param listener The listener used by the walker to process grammar rules @param t The parse tree to be walked on """ if isinstance(t, ErrorNode): listener.visitErrorNode(t) return elif isinstance(t, TerminalNode): listener.visitTerminal(t) return self.enterRule(listener, t) for child in t.getChildren(): self.walk(listener, child) self.exitRule(listener, t) # # The discovery of a rule node, involves sending two events: the generic # {@link ParseTreeListener#enterEveryRule} and a # {@link RuleContext}-specific event. First we trigger the generic and then # the rule specific. We to them in reverse order upon finishing the node. # def enterRule(self, listener:ParseTreeListener, r:RuleNode): """ Enters a grammar rule by first triggering the generic event {@link ParseTreeListener#enterEveryRule} then by triggering the event specific to the given parse tree node @param listener The listener responding to the trigger events @param r The grammar rule containing the rule context """ ctx = r.getRuleContext() listener.enterEveryRule(ctx) ctx.enterRule(listener) def exitRule(self, listener:ParseTreeListener, r:RuleNode): """ Exits a grammar rule by first triggering the event specific to the given parse tree node then by triggering the generic event {@link ParseTreeListener#exitEveryRule} @param listener The listener responding to the trigger events @param r The grammar rule containing the rule context """ ctx = r.getRuleContext() ctx.exitRule(listener) listener.exitEveryRule(ctx) ParseTreeWalker.DEFAULT = ParseTreeWalker()