⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tclparser.tcl

📁 是TCL的另外一个编译(解释)器
💻 TCL
📖 第 1 页 / 共 2 页
字号:
                }
                
                #Get the start end end of the proc
                
                set nstart [$TxtWidget search -regexp $brace_rexp "$nend+1c" end]
                if {[$TxtWidget get $nstart] != "\{"} {
                    set nend "$nend +1lines"
                    if {[$TxtWidget compare $nend >= "end -1c"]} {
                        break
                    }
                    set result [$TxtWidget search -forwards -regexp $rexp $nend $end ]
                    continue
                }
                set nend [GetClosePair "\{" "$nstart"]
                if {$nend == ""} {
                    set nend "$nstart +1lines"
                    if {[$TxtWidget compare $nend >= "end -1c"]} {
                        break
                    }
                    set result [$TxtWidget search -forwards -regexp $rexp $nend $end ]
                    continue
                }
                #Create a node
                set nname "$node\#$name"
                lappend nodeList [list $nname proc "$result linestart"  "$nend +1c"]
                foreach ProcNode [parse $nstart $nend $nname $proc_rexp 1] {
                    lappend nodeList $ProcNode
                }
            }
            
            "method" {
                #Get the name
                set name $arg1
                #Skip the arguments
                set nstart [$TxtWidget search -forward \{ $result "$result lineend"]
                if {$nstart == ""} {
                    set nend "$nend +1lines"
                    if {[$TxtWidget compare $nend >= "end -1c"]} {
                        break
                    }
                    set result [$TxtWidget search -forwards -regexp $rexp $nend $end ]
                    continue
                }
                set nend [GetClosePair "\{" "$nstart"]
                if {$nend == ""} {
                    set nend "$nstart +1lines linestart"
                    if {[$TxtWidget compare $nend >= "end -1c"]} {
                        break
                    }
                    set result [$TxtWidget search -forwards -regexp $rexp $nend $end ]
                    continue
                }
                #Get the start end end of the method
                
                set nstart [$TxtWidget search -regexp $brace_rexp "$nend+1c" end]
                if {[$TxtWidget get $nstart] != "\{"} {
                    #this is a forward declaration!
                    #Create a node
                    set nname "$node\#$name"
                    if {![$Editor::treeWindow exists $nname]} {
                        lappend nodeList [list $nname method "$result linestart"  "$nend +1c"]
                    }
                    set nname "$node\#$name\#declaration"
                    lappend nodeList [list $nname forward "$result linestart"  "$nend +1c"]
                } else  {
                    set nend [GetClosePair "\{" "$nstart"]
                    if {$nend == ""} {
                        set nend "$nstart +1lines"
                        if {[$TxtWidget compare $nend >= "end -1c"]} {
                            break
                        }
                        set result [$TxtWidget search -forwards -regexp $rexp $nend $end ]
                        continue
                    }
                    #Create a node
                    set nname "$node\#$name"
                    lappend nodeList [list $nname method "$result linestart"  "$nend +1c"]
                }
            }
            
            "body" {
                #Get the name
                set name $arg1
                regsub {^::} $name "" name
                regsub -all {::} $name \# name
                
                #Skip the arguments
                set nstart [$TxtWidget search -forward \{ $result "$result lineend"]
                if {$nstart == ""} {
                    set nend "$nend +1lines"
                    if {[$TxtWidget compare $nend >= "end -1c"]} {
                        break
                    }
                    set result [$TxtWidget search -forwards -regexp $rexp $nend $end ]
                    continue
                }
                set nend [GetClosePair "\{" "$nstart"]
                if {$nend == ""} {
                    set nend "$nstart +1lines"
                    if {[$TxtWidget compare $nend >= "end -1c"]} {
                        break
                    }
                    set result [$TxtWidget search -forwards -regexp $rexp $nend $end ]
                    continue
                }
                #Get the start end end of the body
                set nstart [$TxtWidget search -regexp $brace_rexp "$nend+1c" end]
                if {[$TxtWidget get $nstart] != "\{"} {
                    set nend "$nend +1lines"
                    if {[$TxtWidget compare $nend >= "end -1c"]} {
                        break
                    }
                    set result [$TxtWidget search -forwards -regexp $rexp $nend $end ]
                    continue
                }
                set nend [GetClosePair "\{" "$nstart"]
                if {$nend == ""} {
                    set nend "$nstart +1lines"
                    if {[$TxtWidget compare $nend >= "end -1c"]} {
                        break
                    }
                    set result [$TxtWidget search -forwards -regexp $rexp $nend $end ]
                    continue
                }
                
                #Create a node
                switch -- $name {
                    "constructor" {set nname "$node\#constructor\#body"}
                    "destructor" {set nname "$node\#destructor\#body"}
                    default {set nname "$node\#$name\#body"}
                }
                lappend nodeList [list $nname body "$result linestart"  "$nend +1c"]
            }
            
            "configbody" {
                #Get the name
                set name $arg1
                regsub {^::} $name "" name
                regsub -all {::} $name \# name
                #Get the start end end of the configbody
                set nstart [$TxtWidget search -regexp $brace_rexp "$nend+1c" end]
                if {[$TxtWidget get $nstart] != "\{"} {
                    set nend "$nend +1lines"
                    if {[$TxtWidget compare $nend >= "end -1c"]} {
                        break
                    }
                    set result [$TxtWidget search -forwards -regexp $rexp $nend $end ]
                    continue
                }
                set nend [GetClosePair "\{" "$nstart"]
                if {$nend == ""} {
                    set nend "$nstart +1lines"
                    if {[$TxtWidget compare $nend >= "end -1c"]} {
                        break
                    }
                    set result [$TxtWidget search -forwards -regexp $rexp $nend $end ]
                    continue
                }
                
                #Create a node
                set nname "$node\#$name"
                lappend nodeList [list $nname configbody "$result linestart"  "$nend +1c"]
            }
            
            "constructor" {
                
                #Skip the arguments
                set nstart [$TxtWidget search -forward \{ $result "$result lineend"]
                if {$nstart == ""} {
                    set nend "$nend +1lines"
                    if {[$TxtWidget compare $nend >= "end -1c"]} {
                        break
                    }
                    set result [$TxtWidget search -forwards -regexp $rexp $nend $end ]
                    continue
                }
                set nend [GetClosePair "\{" "$nstart"]
                if {$nend == ""} {
                    set nend "$nstart +1lines"
                    if {[$TxtWidget compare $nend >= "end -1c"]} {
                        break
                    }
                    set result [$TxtWidget search -forwards -regexp $rexp $nend $end ]
                    continue
                }
                
                #Get the start end end of the next environmet
                set nstart [$TxtWidget search -regexp $brace_rexp "$nend+1c" end]
                if {[$TxtWidget get $nstart] != "\{"} {
                    set nend "$nend +1lines"
                    if {[$TxtWidget compare $nend >= "end -1c"]} {
                        break
                    }
                    set result [$TxtWidget search -forwards -regexp $rexp $nend $end ]
                    continue
                }
                set nend [GetClosePair "\{" "$nstart"]
                if {$nend == ""} {
                    set nend "$nstart +1lines"
                    if {[$TxtWidget compare $nend >= "end -1c"]} {
                        break
                    }
                    set result [$TxtWidget search -forwards -regexp $rexp $nend $end ]
                    continue
                }
                
                #If there is some inheritance defined, go on to the body
                set rexp1 "[lindex $ancestors 0]::constructor"
                set inhet [$TxtWidget search -forwards -regexp $rexp1 $nstart $nend]
                
                if {$inhet != "" && [expr  (floor($inhet) >= floor($nstart) ) && ( floor($inhet) <= floor($nend) )]} {
                    #Get the start end end of the next environmet
                    set nstart [$TxtWidget search -regexp $brace_rexp "$nend+1c" end]
                    if {[$TxtWidget get $nstart] != "\{"} {
                        set nend "$nend +1lines"
                        if {[$TxtWidget compare $nend >= "end -1c"]} {
                            break
                        }
                        set result [$TxtWidget search -forwards -regexp $rexp $nend $end ]
                        continue
                    }
                    set nend [GetClosePair "\{" "$nstart"]
                    if {$nend == ""} {
                        set nend "$nstart +1lines"
                        if {[$TxtWidget compare $nend >= "end -1c"]} {
                            break
                        }
                        set result [$TxtWidget search -forwards -regexp $rexp $nend $end ]
                        continue
                    }
                }
                
                
                
                #Create a node
                set nname "$node\#constructor"
                lappend nodeList [list $nname constructor "$result linestart"  "$nend +1c"]
            }
            
            "destructor" {
                #Get the start end end of the body
                set nstart [$TxtWidget search -regexp $brace_rexp "$nend+1c" end]
                if {[$TxtWidget get $nstart] != "\{"} {
                    set nend "$nend +1lines"
                    if {[$TxtWidget compare $nend >= "end -1c"]} {
                        break
                    }
                    set result [$TxtWidget search -forwards -regexp $rexp $nend $end ]
                    continue
                }
                set nend [GetClosePair "\{" "$nstart"]
                
                if {$nend == ""} {
                    set nend "$nstart +1lines"
                    if {[$TxtWidget compare $nend >= "end -1c"]} {
                        break
                    }
                    set result [$TxtWidget search -forwards -regexp $rexp $nend $end ]
                    continue
                }
                #Create a node
                set nname "$node\#destructor"
                lappend nodeList [list $nname destructor "$result linestart"  "$nend +1c"]
            }
            
            default {
                #skip line
                if {$nend == ""} {
                    set nend "$nstart +1lines"
                    if {[$TxtWidget compare $nend >= "end -1c"]} {
                        break
                    }
                    set result [$TxtWidget search -forwards -regexp $rexp $nend $end ]
                    continue
                } else  {
                    set nend "$nend +1lines"
                }
            }
        } ;# end of switch
        
        set result [$TxtWidget search -forwards -regexp $rexp $nend $end ]
        
        set nend [$TxtWidget index $nend]
        if {$code != {}} {
            eval $code
        }
    } ;#end of while
    return $nodeList
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -