Server IP : 103.119.228.120 / Your IP : 3.145.56.150 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/ |
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. # # A parser simulator that mimics what ANTLR's generated # parser code does. A ParserATNSimulator is used to make # predictions via adaptivePredict but this class moves a pointer through the # ATN to simulate parsing. ParserATNSimulator just # makes us efficient rather than having to backtrack, for example. # # This properly creates parse trees even for left recursive rules. # # We rely on the left recursive rule invocation and special predicate # transitions to make left recursive rules work. # # See TestParserInterpreter for examples. # from antlr4.dfa.DFA import DFA from antlr4.BufferedTokenStream import TokenStream from antlr4.Lexer import Lexer from antlr4.Parser import Parser from antlr4.ParserRuleContext import InterpreterRuleContext, ParserRuleContext from antlr4.Token import Token from antlr4.atn.ATN import ATN from antlr4.atn.ATNState import StarLoopEntryState, ATNState, LoopEndState from antlr4.atn.ParserATNSimulator import ParserATNSimulator from antlr4.PredictionContext import PredictionContextCache from antlr4.atn.Transition import Transition from antlr4.error.Errors import RecognitionException, UnsupportedOperationException, FailedPredicateException class ParserInterpreter(Parser): __slots__ = ( 'grammarFileName', 'atn', 'tokenNames', 'ruleNames', 'decisionToDFA', 'sharedContextCache', '_parentContextStack', 'pushRecursionContextStates' ) def __init__(self, grammarFileName:str, tokenNames:list, ruleNames:list, atn:ATN, input:TokenStream): super().__init__(input) self.grammarFileName = grammarFileName self.atn = atn self.tokenNames = tokenNames self.ruleNames = ruleNames self.decisionToDFA = [ DFA(state) for state in atn.decisionToState ] self.sharedContextCache = PredictionContextCache() self._parentContextStack = list() # identify the ATN states where pushNewRecursionContext must be called self.pushRecursionContextStates = set() for state in atn.states: if not isinstance(state, StarLoopEntryState): continue if state.isPrecedenceDecision: self.pushRecursionContextStates.add(state.stateNumber) # get atn simulator that knows how to do predictions self._interp = ParserATNSimulator(self, atn, self.decisionToDFA, self.sharedContextCache) # Begin parsing at startRuleIndex# def parse(self, startRuleIndex:int): startRuleStartState = self.atn.ruleToStartState[startRuleIndex] rootContext = InterpreterRuleContext(None, ATNState.INVALID_STATE_NUMBER, startRuleIndex) if startRuleStartState.isPrecedenceRule: self.enterRecursionRule(rootContext, startRuleStartState.stateNumber, startRuleIndex, 0) else: self.enterRule(rootContext, startRuleStartState.stateNumber, startRuleIndex) while True: p = self.getATNState() if p.stateType==ATNState.RULE_STOP : # pop; return from rule if len(self._ctx)==0: if startRuleStartState.isPrecedenceRule: result = self._ctx parentContext = self._parentContextStack.pop() self.unrollRecursionContexts(parentContext.a) return result else: self.exitRule() return rootContext self.visitRuleStopState(p) else: try: self.visitState(p) except RecognitionException as e: self.state = self.atn.ruleToStopState[p.ruleIndex].stateNumber self._ctx.exception = e self._errHandler.reportError(self, e) self._errHandler.recover(self, e) def enterRecursionRule(self, localctx:ParserRuleContext, state:int, ruleIndex:int, precedence:int): self._parentContextStack.append((self._ctx, localctx.invokingState)) super().enterRecursionRule(localctx, state, ruleIndex, precedence) def getATNState(self): return self.atn.states[self.state] def visitState(self, p:ATNState): edge = 0 if len(p.transitions) > 1: self._errHandler.sync(self) edge = self._interp.adaptivePredict(self._input, p.decision, self._ctx) else: edge = 1 transition = p.transitions[edge - 1] tt = transition.serializationType if tt==Transition.EPSILON: if self.pushRecursionContextStates[p.stateNumber] and not isinstance(transition.target, LoopEndState): t = self._parentContextStack[-1] ctx = InterpreterRuleContext(t[0], t[1], self._ctx.ruleIndex) self.pushNewRecursionContext(ctx, self.atn.ruleToStartState[p.ruleIndex].stateNumber, self._ctx.ruleIndex) elif tt==Transition.ATOM: self.match(transition.label) elif tt in [ Transition.RANGE, Transition.SET, Transition.NOT_SET]: if not transition.matches(self._input.LA(1), Token.MIN_USER_TOKEN_TYPE, Lexer.MAX_CHAR_VALUE): self._errHandler.recoverInline(self) self.matchWildcard() elif tt==Transition.WILDCARD: self.matchWildcard() elif tt==Transition.RULE: ruleStartState = transition.target ruleIndex = ruleStartState.ruleIndex ctx = InterpreterRuleContext(self._ctx, p.stateNumber, ruleIndex) if ruleStartState.isPrecedenceRule: self.enterRecursionRule(ctx, ruleStartState.stateNumber, ruleIndex, transition.precedence) else: self.enterRule(ctx, transition.target.stateNumber, ruleIndex) elif tt==Transition.PREDICATE: if not self.sempred(self._ctx, transition.ruleIndex, transition.predIndex): raise FailedPredicateException(self) elif tt==Transition.ACTION: self.action(self._ctx, transition.ruleIndex, transition.actionIndex) elif tt==Transition.PRECEDENCE: if not self.precpred(self._ctx, transition.precedence): msg = "precpred(_ctx, " + str(transition.precedence) + ")" raise FailedPredicateException(self, msg) else: raise UnsupportedOperationException("Unrecognized ATN transition type.") self.state = transition.target.stateNumber def visitRuleStopState(self, p:ATNState): ruleStartState = self.atn.ruleToStartState[p.ruleIndex] if ruleStartState.isPrecedenceRule: parentContext = self._parentContextStack.pop() self.unrollRecursionContexts(parentContext.a) self.state = parentContext[1] else: self.exitRule() ruleTransition = self.atn.states[self.state].transitions[0] self.state = ruleTransition.followState.stateNumber