Server IP : 103.119.228.120 / Your IP : 3.142.171.100 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. # # # Represents the result of matching a {@link ParseTree} against a tree pattern. # from io import StringIO from antlr4.tree.ParseTreePattern import ParseTreePattern from antlr4.tree.Tree import ParseTree class ParseTreeMatch(object): __slots__ = ('tree', 'pattern', 'labels', 'mismatchedNode') # # Constructs a new instance of {@link ParseTreeMatch} from the specified # parse tree and pattern. # # @param tree The parse tree to match against the pattern. # @param pattern The parse tree pattern. # @param labels A mapping from label names to collections of # {@link ParseTree} objects located by the tree pattern matching process. # @param mismatchedNode The first node which failed to match the tree # pattern during the matching process. # # @exception IllegalArgumentException if {@code tree} is {@code null} # @exception IllegalArgumentException if {@code pattern} is {@code null} # @exception IllegalArgumentException if {@code labels} is {@code null} # def __init__(self, tree:ParseTree, pattern:ParseTreePattern, labels:dict, mismatchedNode:ParseTree): if tree is None: raise Exception("tree cannot be null") if pattern is None: raise Exception("pattern cannot be null") if labels is None: raise Exception("labels cannot be null") self.tree = tree self.pattern = pattern self.labels = labels self.mismatchedNode = mismatchedNode # # Get the last node associated with a specific {@code label}. # # <p>For example, for pattern {@code <id:ID>}, {@code get("id")} returns the # node matched for that {@code ID}. If more than one node # matched the specified label, only the last is returned. If there is # no node associated with the label, this returns {@code null}.</p> # # <p>Pattern tags like {@code <ID>} and {@code <expr>} without labels are # considered to be labeled with {@code ID} and {@code expr}, respectively.</p> # # @param label The label to check. # # @return The last {@link ParseTree} to match a tag with the specified # label, or {@code null} if no parse tree matched a tag with the label. # def get(self, label:str): parseTrees = self.labels.get(label, None) if parseTrees is None or len(parseTrees)==0: return None else: return parseTrees[len(parseTrees)-1] # # Return all nodes matching a rule or token tag with the specified label. # # <p>If the {@code label} is the name of a parser rule or token in the # grammar, the resulting list will contain both the parse trees matching # rule or tags explicitly labeled with the label and the complete set of # parse trees matching the labeled and unlabeled tags in the pattern for # the parser rule or token. For example, if {@code label} is {@code "foo"}, # the result will contain <em>all</em> of the following.</p> # # <ul> # <li>Parse tree nodes matching tags of the form {@code <foo:anyRuleName>} and # {@code <foo:AnyTokenName>}.</li> # <li>Parse tree nodes matching tags of the form {@code <anyLabel:foo>}.</li> # <li>Parse tree nodes matching tags of the form {@code <foo>}.</li> # </ul> # # @param label The label. # # @return A collection of all {@link ParseTree} nodes matching tags with # the specified {@code label}. If no nodes matched the label, an empty list # is returned. # def getAll(self, label:str): nodes = self.labels.get(label, None) if nodes is None: return list() else: return nodes # # Gets a value indicating whether the match operation succeeded. # # @return {@code true} if the match operation succeeded; otherwise, # {@code false}. # def succeeded(self): return self.mismatchedNode is None # # {@inheritDoc} # def __str__(self): with StringIO() as buf: buf.write("Match ") buf.write("succeeded" if self.succeeded() else "failed") buf.write("; found ") buf.write(str(len(self.labels))) buf.write(" labels") return buf.getvalue()