'''[http://www.snobol4.org/%|%SNOBOL]''', or '''S'''tri'''N'''g Oriented and sym'''BO'''lic '''L'''anguage, is a [programming language] emphasizing [string processing%|%text processing] and [pattern matching]. ** See Also ** [TkS*LIDE]: an [IDE] for SNOBOL4 writtin in [Tk] ** Documentation ** [http://www.snobol4.org/csnobol4/1.5/doc/snobol4tcl.html%|%SNOBOL4TCL]: Tcl/Tk interface of CSNOBALL4 [Ralph Griswold]: created both SNOBOL and [Icon Programming Language%|%Icon] ** Description ** Having actually tried to learn this language, I'm astounded by its pattern matching facilities. Makes [grep] look primitive. COMIT was a predecessor of SNOBOL. ** Discussion ** [BMA]: Being a slow starter with Tcl, where would I start trying to 1. write a snobol interpreter in Tcl, or 2. write snobol pattern matching tools in Tcl? ---- [LV]: Well, the quick approach would be to scavenge one of the free snobol interpreter source trees for their code, write or wrap the code with Tcl binding, and invoke it directly. The tougher approach would be to study the language, determine what features from the language you want, decide upon the Tcl API you want to use to achieve similar functionality, then write that functionality, write a test suite, and get it all running. ---- [escargo] 2003-12-30: I will just note that the successor to Snobol, [Icon Programming Language%|%Icon], also has a page on this wiki. Its pattern matching is different than Snobol's, but also very powerful. It is ''not'' based on regular expressions, but does pattern matching with other facilities. [LES]: If it ain't regular expressions, it ain't no good. [Larry]: Les's ideas are no better than his grammar. The only advantage of regular expressions over Snobol pattern matching and Icon string scanning is that regular expressions are very terse. Perhaps because of their terseness, they quickly become unreadable as they become more complex. Pattern matching and string scanning are far more powerful, are quicker to write, and are far easier to debug. One writer said that if you have a problem and you solve it with a regular expression, you end up with two problems. If you need to do anything complex with strings, your best bet is Icon string scanning. ---- Perhaps someone could put up some examples of the power of snobol, demonstrating the power being described specifically. Then if someone wants to wander by and contribute regular expression equivalents, the reader will more easily be able to take sides in the debate. ** [Tcl/Tk] Interface ** ====== -INCLUDE 'stcl.sno' INTERP = STCL_CREATEINTERP() TCL_VERSION = STCL_GETVAR(INTERP, "tcl_version") OUTPUT = IDENT(TCL_VERSION) "Could not get tcl_version" :S(END) OUTPUT = "Tcl Version: " TCL_VERSION * check Tcl version NUM = SPAN('0123456789') VPAT = NUM '.' NUM TCL_VERSION VPAT . VER :S(CHECKV) OUTPUT = "could not parse tcl_version" :(END) CHECKV LT(VER, 8.4) :S(CHECKTK) * Tcl 8.4 and later can dynamicly load Tk! STCL_EVAL(INTERP, "package require Tk") :F(END) * Check for Tk CHECKTK TK_VERSION = STCL_GETVAR(INTERP, "tk_version") :F(NOTK) DIFFER(TK_VERSION) :S(HAVETK) NOTK OUTPUT = "Could not find tk_version" :(END) HAVETK OUTPUT = "Tk version: " TK_VERSION SEP = ';' STCL_EVAL(INTERP, + 'button .hello -text "Hello, world" -command {set foo 1}' SEP + "pack .hello" SEP + 'button .other -text "Other Choice" -command {set foo 2}' SEP + "pack .other" SEP + "global foo" SEP + "vwait foo") OUTPUT = STCL_GETVAR(INTERP, "foo") END ====== <> Language