Server IP : 103.119.228.120 / Your IP : 52.15.217.86 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/local/ssl/lib/mysqlsh/lib/python3.9/site-packages/antlr4/dfa/ |
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. #/ # Map a predicate to a predicted alternative.#/ from io import StringIO from antlr4.atn.ATNConfigSet import ATNConfigSet from antlr4.atn.SemanticContext import SemanticContext class PredPrediction(object): __slots__ = ('alt', 'pred') def __init__(self, pred:SemanticContext, alt:int): self.alt = alt self.pred = pred def __str__(self): return "(" + str(self.pred) + ", " + str(self.alt) + ")" # A DFA state represents a set of possible ATN configurations. # As Aho, Sethi, Ullman p. 117 says "The DFA uses its state # to keep track of all possible states the ATN can be in after # reading each input symbol. That is to say, after reading # input a1a2..an, the DFA is in a state that represents the # subset T of the states of the ATN that are reachable from the # ATN's start state along some path labeled a1a2..an." # In conventional NFA→DFA conversion, therefore, the subset T # would be a bitset representing the set of states the # ATN could be in. We need to track the alt predicted by each # state as well, however. More importantly, we need to maintain # a stack of states, tracking the closure operations as they # jump from rule to rule, emulating rule invocations (method calls). # I have to add a stack to simulate the proper lookahead sequences for # the underlying LL grammar from which the ATN was derived. # # <p>I use a set of ATNConfig objects not simple states. An ATNConfig # is both a state (ala normal conversion) and a RuleContext describing # the chain of rules (if any) followed to arrive at that state.</p> # # <p>A DFA state may have multiple references to a particular state, # but with different ATN contexts (with same or different alts) # meaning that state was reached via a different set of rule invocations.</p> #/ class DFAState(object): __slots__ = ( 'stateNumber', 'configs', 'edges', 'isAcceptState', 'prediction', 'lexerActionExecutor', 'requiresFullContext', 'predicates' ) def __init__(self, stateNumber:int=-1, configs:ATNConfigSet=ATNConfigSet()): self.stateNumber = stateNumber self.configs = configs # {@code edges[symbol]} points to target of symbol. Shift up by 1 so (-1) # {@link Token#EOF} maps to {@code edges[0]}. self.edges = None self.isAcceptState = False # if accept state, what ttype do we match or alt do we predict? # This is set to {@link ATN#INVALID_ALT_NUMBER} when {@link #predicates}{@code !=null} or # {@link #requiresFullContext}. self.prediction = 0 self.lexerActionExecutor = None # Indicates that this state was created during SLL prediction that # discovered a conflict between the configurations in the state. Future # {@link ParserATNSimulator#execATN} invocations immediately jumped doing # full context prediction if this field is true. self.requiresFullContext = False # During SLL parsing, this is a list of predicates associated with the # ATN configurations of the DFA state. When we have predicates, # {@link #requiresFullContext} is {@code false} since full context prediction evaluates predicates # on-the-fly. If this is not null, then {@link #prediction} is # {@link ATN#INVALID_ALT_NUMBER}. # # <p>We only use these for non-{@link #requiresFullContext} but conflicting states. That # means we know from the context (it's $ or we don't dip into outer # context) that it's an ambiguity not a conflict.</p> # # <p>This list is computed by {@link ParserATNSimulator#predicateDFAState}.</p> self.predicates = None # Get the set of all alts mentioned by all ATN configurations in this # DFA state. def getAltSet(self): if self.configs is not None: return set(cfg.alt for cfg in self.configs) or None return None def __hash__(self): return hash(self.configs) # Two {@link DFAState} instances are equal if their ATN configuration sets # are the same. This method is used to see if a state already exists. # # <p>Because the number of alternatives and number of ATN configurations are # finite, there is a finite number of DFA states that can be processed. # This is necessary to show that the algorithm terminates.</p> # # <p>Cannot test the DFA state numbers here because in # {@link ParserATNSimulator#addDFAState} we need to know if any other state # exists that has this exact set of ATN configurations. The # {@link #stateNumber} is irrelevant.</p> def __eq__(self, other): # compare set of ATN configurations in this set with other if self is other: return True elif not isinstance(other, DFAState): return False else: return self.configs==other.configs def __str__(self): with StringIO() as buf: buf.write(str(self.stateNumber)) buf.write(":") buf.write(str(self.configs)) if self.isAcceptState: buf.write("=>") if self.predicates is not None: buf.write(str(self.predicates)) else: buf.write(str(self.prediction)) return buf.getvalue()