Server IP : 103.119.228.120 / Your IP : 18.119.28.213 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 : /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. #/ from antlr4.IntervalSet import IntervalSet from antlr4.Token import Token from antlr4.PredictionContext import PredictionContext, SingletonPredictionContext, PredictionContextFromRuleContext from antlr4.RuleContext import RuleContext from antlr4.atn.ATN import ATN from antlr4.atn.ATNConfig import ATNConfig from antlr4.atn.ATNState import ATNState, RuleStopState from antlr4.atn.Transition import WildcardTransition, NotSetTransition, AbstractPredicateTransition, RuleTransition class LL1Analyzer (object): __slots__ = 'atn' #* Special value added to the lookahead sets to indicate that we hit # a predicate during analysis if {@code seeThruPreds==false}. #/ HIT_PRED = Token.INVALID_TYPE def __init__(self, atn:ATN): self.atn = atn #* # Calculates the SLL(1) expected lookahead set for each outgoing transition # of an {@link ATNState}. The returned array has one element for each # outgoing transition in {@code s}. If the closure from transition # <em>i</em> leads to a semantic predicate before matching a symbol, the # element at index <em>i</em> of the result will be {@code null}. # # @param s the ATN state # @return the expected symbols for each outgoing transition of {@code s}. #/ def getDecisionLookahead(self, s:ATNState): if s is None: return None count = len(s.transitions) look = [] * count for alt in range(0, count): look[alt] = set() lookBusy = set() seeThruPreds = False # fail to get lookahead upon pred self._LOOK(s.transition(alt).target, None, PredictionContext.EMPTY, look[alt], lookBusy, set(), seeThruPreds, False) # Wipe out lookahead for this alternative if we found nothing # or we had a predicate when we !seeThruPreds if len(look[alt])==0 or self.HIT_PRED in look[alt]: look[alt] = None return look #* # Compute set of tokens that can follow {@code s} in the ATN in the # specified {@code ctx}. # # <p>If {@code ctx} is {@code null} and the end of the rule containing # {@code s} is reached, {@link Token#EPSILON} is added to the result set. # If {@code ctx} is not {@code null} and the end of the outermost rule is # reached, {@link Token#EOF} is added to the result set.</p> # # @param s the ATN state # @param stopState the ATN state to stop at. This can be a # {@link BlockEndState} to detect epsilon paths through a closure. # @param ctx the complete parser context, or {@code null} if the context # should be ignored # # @return The set of tokens that can follow {@code s} in the ATN in the # specified {@code ctx}. #/ def LOOK(self, s:ATNState, stopState:ATNState=None, ctx:RuleContext=None): r = IntervalSet() seeThruPreds = True # ignore preds; get all lookahead lookContext = PredictionContextFromRuleContext(s.atn, ctx) if ctx is not None else None self._LOOK(s, stopState, lookContext, r, set(), set(), seeThruPreds, True) return r #* # Compute set of tokens that can follow {@code s} in the ATN in the # specified {@code ctx}. # # <p>If {@code ctx} is {@code null} and {@code stopState} or the end of the # rule containing {@code s} is reached, {@link Token#EPSILON} is added to # the result set. If {@code ctx} is not {@code null} and {@code addEOF} is # {@code true} and {@code stopState} or the end of the outermost rule is # reached, {@link Token#EOF} is added to the result set.</p> # # @param s the ATN state. # @param stopState the ATN state to stop at. This can be a # {@link BlockEndState} to detect epsilon paths through a closure. # @param ctx The outer context, or {@code null} if the outer context should # not be used. # @param look The result lookahead set. # @param lookBusy A set used for preventing epsilon closures in the ATN # from causing a stack overflow. Outside code should pass # {@code new HashSet<ATNConfig>} for this argument. # @param calledRuleStack A set used for preventing left recursion in the # ATN from causing a stack overflow. Outside code should pass # {@code new BitSet()} for this argument. # @param seeThruPreds {@code true} to true semantic predicates as # implicitly {@code true} and "see through them", otherwise {@code false} # to treat semantic predicates as opaque and add {@link #HIT_PRED} to the # result if one is encountered. # @param addEOF Add {@link Token#EOF} to the result if the end of the # outermost context is reached. This parameter has no effect if {@code ctx} # is {@code null}. #/ def _LOOK(self, s:ATNState, stopState:ATNState , ctx:PredictionContext, look:IntervalSet, lookBusy:set, calledRuleStack:set, seeThruPreds:bool, addEOF:bool): c = ATNConfig(s, 0, ctx) if c in lookBusy: return lookBusy.add(c) if s == stopState: if ctx is None: look.addOne(Token.EPSILON) return elif ctx.isEmpty() and addEOF: look.addOne(Token.EOF) return if isinstance(s, RuleStopState ): if ctx is None: look.addOne(Token.EPSILON) return elif ctx.isEmpty() and addEOF: look.addOne(Token.EOF) return if ctx != PredictionContext.EMPTY: removed = s.ruleIndex in calledRuleStack try: calledRuleStack.discard(s.ruleIndex) # run thru all possible stack tops in ctx for i in range(0, len(ctx)): returnState = self.atn.states[ctx.getReturnState(i)] self._LOOK(returnState, stopState, ctx.getParent(i), look, lookBusy, calledRuleStack, seeThruPreds, addEOF) finally: if removed: calledRuleStack.add(s.ruleIndex) return for t in s.transitions: if type(t) == RuleTransition: if t.target.ruleIndex in calledRuleStack: continue newContext = SingletonPredictionContext.create(ctx, t.followState.stateNumber) try: calledRuleStack.add(t.target.ruleIndex) self._LOOK(t.target, stopState, newContext, look, lookBusy, calledRuleStack, seeThruPreds, addEOF) finally: calledRuleStack.remove(t.target.ruleIndex) elif isinstance(t, AbstractPredicateTransition ): if seeThruPreds: self._LOOK(t.target, stopState, ctx, look, lookBusy, calledRuleStack, seeThruPreds, addEOF) else: look.addOne(self.HIT_PRED) elif t.isEpsilon: self._LOOK(t.target, stopState, ctx, look, lookBusy, calledRuleStack, seeThruPreds, addEOF) elif type(t) == WildcardTransition: look.addRange( range(Token.MIN_USER_TOKEN_TYPE, self.atn.maxTokenType + 1) ) else: set_ = t.label if set_ is not None: if isinstance(t, NotSetTransition): set_ = set_.complement(Token.MIN_USER_TOKEN_TYPE, self.atn.maxTokenType) look.addSet(set_)