Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Watching PARSE.

 [1/4] from: brett::codeconscious::com at: 21-Sep-2003 22:50


Librarian comment

See also parse-analysis-view.r  script in the Library

Playing with Parse I was inspired to add a Wait to it then thought "hey why not add a face too!" So here is a little script that allows you to watch Parse step through your input using your parse rules. It uses my scroll-panel style included at the end. You will need to use View 1.2.8+ to run it. You don't really need scroll-panel, but scroll-panel helps if you have text too big for the screen. ; -------------------------------------------------------------------- ; This example just parses a simple string. pdbg-test1: does [ input-string: "dog dog cat dog cat cat cat dog cat dog" parse input-string [ pdbg-begin some [pdbg "dog" | "cat"] pdbg-end ] ] ; -------------------------------------------------------------------- ; For some fun this example injects calls to into REBOL's Parse-xml ; function so we can watch how some xml gets processed. pdbg-test2: does [ insert xml-language/document [pdbg-begin] insert tail xml-language/document [pdbg-end] insert xml-language/element [pdbg] parse-xml read http://www.alistapart.com/index.html ] ; -------------------------------------------------------------------- ; The main script. REBOL [ title: "Simple parse debugger" file: %pdbg.r author: "Brett Handley" date: 21-sep-2003 ] pdbg-begin: [ pdbg-pos: ( ctx-text/unlight-text view/new pdbg-lyo: layout [ origin 0x0 space 0x0 scroll-panel 700x500 [ origin 0x0 space 0x0 pdbg-face: text as-is pdbg-pos ] do [focus pdbg-face] ] ) ] pdbg: [pdbg-pos: (pdbg-update)] pdbg-update: does [ ctx-text/hilight-text pdbg-face pdbg-face/text pdbg-pos show pdbg-face wait 00:00:00.2 ] pdbg-end: [ pdbg ( ctx-text/unlight-text unview pdbg-lyo ) ] ; -------------------------------------------------------------------- ; My scroll-panel style. In compressed form write %scroll-panel.r decompress #{ 789C9D58DB6EDB38107DD7570CD28726291CD906FAB05A640B3717348BA459A4 698185E007C5A26CA2B2E8152959CE62FF7DCF90922CF9D2BD08756B8BE4E1CC 9933C3619F6E3E3EDE53E8119E67695211D0C997ABA7C7FBFBC16F93CF37F727 7664529885CA31F43117C6D0A7288B53B17163D791C1A29F06BF16E9603C1C8E EDCB4F521B956F821A999FD1C5E86248A19DB8B133E9E441C5329122A6B81064 1465624D324B54BE8C8C5419E1CF93D0F2555012CD84B938D9B560DA811F32FC 6808FC4CD4F8779934324AA914B906DEB1F5536FEA79DA6C52ECE42F236D440E C3ED50978B806E27573724E2B9A090AD0A685C8D492489989980DECA17518A74 4A6B69161DC7E3C84401CD72B57A5155403A9531CC09285399F0DA593F130C2B F24C5301A3072520554EA082A28CA24AEA7666517E082829B21985EB298502BB C1DE355DD2DB0A045443BC1C56A3E9B40B3E8BD2599122541A5FB332D2C40EB4 13F46B8B996C3113DFF99AF83606033A1DD379FDD6BE3A9B3683FDDD9C8F2022 360B6D9D7851E0249639DC422034C180885691CCB726A4F13AA0D1FB6AF4BE0B F51065D11C56C320CCCFC4453B96461B559801BF74B65BC9847EEE14335BC834 1EB06E60A47EA5189F92CA1195634A376ADA89103F32B101F960C345611D34B5 DA50D8F5CD1975A53248CAD0B7BB6B966D64E579B18BF792AAD9F73EA0B3D957 49A285F1597270CD4E185643B79D1669528FECEDFB98213D9CA41D1264251054 CB0E2B6C0089413071A3B23D9B3265A826A8EF7F67DC8D3A81B36D2EFA18EC29 1F4A687540EFA816C12E24980E5A5BD572A5B4F063215614AA5CCE65E6FC6E72 037FED21386D583D411BD8958502D981717F15E5223336C8BE064A9A7276D868 F89C3354466921F6ADEA608EAAF7FF0B731FB44D6C0E23C318D4B3CA30053E8B 94C67B4B9C769B09BDE19DD8D714F96E0547A537AC5F03CE612B9E83EB5CD05C 1A74A2BA2BB06B81DAB7949953940DAD4A9CBA5466C00BADD202A99B6DA0A23F 0AE4F311A9E562056192844EF675560F961456B4D94DC4E681DE60AB1F94F40B B97F436BBB0DD5399DE682ABBAB0C129CFA0408CEE0765EA1DFF65E1E0AC2D0D 16F6DD7166BE30174D9A719671DECF2069157302FE8884E37EC2C7D3BE936747 D8E8C7B1FB8BCBF2614ECEFE918D433E72F5409A4A5B4DAD0A9C6BD8070572B0 13F6537D4652FBC8190825216D50AC0F92A0D31668DFC3721C50637B390A9CFD 1C6ABF77F2350FDEBB0ABAC3C439800E4D76A445716CAB165E740BD72EC2A851 D8612CB89E47732B1BEE676259C2A91E0847B395117E1C8A7A53827559263E03 0E2C7BCC914D717FC485F147E2ED80C4CA562B9BFC6E67C74E7F41AF34F44EEB 0781EE2E6641D7F5AE9BEFB6995989DC3665197659C8CCC86CBE0DB25BD43D82 CBBA46A291A84C1EED2ADFBE7499C7D5FF940B574DE01954B64DC1EEA28E5F2E 941685C3C41FDEAE3B05EF5A3D1DAC87B34594A1AD40D7E616F4A95AA87533B3 6FC411A6FF33D16EFB2ED1EDB425F7C49BA61BD32B319B36DD03FFE8B63D4DAB C33B6E83ED5E3600DC52FB15F97BF5A7EEF1B894FFA03C55EEBCF771380369BF BE62CAA69EB2393065DAB40B761BB6E5409F70C4A30E87ED6E687E70A7488448 5DFFDC5DBB9DB656798CD086AEF3C2AE7ECD9F00D93145F95CBBA399BFF56D89 6A09F322F7BDED8B39F0B5AE0F036D9196456A24141E7D17EEFB6EB3B9449904 B0E4FB9601407D1BE8CEB1DD636FF397F43BF8B48DE5771408D7AE38CFEC9B8E 01CDBD862F367F76EF3074FD78F5F5E1E6F3F3E4F9EEF1B3F72F6F77EE56E5AE 77DEE5E5E52352AB9462ED79CF50700FDF76AEB4CA15D7456EF25D7940C58030 E7CC2D5F07D0385FD09D210386F832E0C96C850E31020D2833A96DAC59EDB81D CEEC55F0C2EE7B8B93A480443CEFFC4B7D98AC250A56B4C21993E3BA986E5C61 746714169DDFE28B6EC2DA96A8F54264ED79C487D75295984FDF6C214193C735 04796A13B4C8B9232497EA8C79D7E99379AE331467A234CE9EC2C854EAFD26CA 7AC90857B8D4B944EF15DB42334F0F8FD777B7BFB7C63AD79F20B97906D0986E F92EAC5DECAE27CF13D4CC67CBA3DDAECB9AE59ADFBA3471357B72C5A1C7A249 9AAAB5B6F7CB1D7AE0F98BA0B92C45BDFB4D152D5788EB570DE1BA9D39FE4D67 1FEE1C06361F53825E2A7C48E5B6DA8586FF83814E9E17204D1ED246E73EDF03 0A3947EA85F519E50616B84766AA89E4C956F76FDEBCF1FEF2F0FC0D98FEDF7E E1100000 } ; -------------------------------------------------------------------- Brett. --- Website: http://www.codeconscious.com Rebsite: http://www.codeconscious.com/index.r

 [2/4] from: greggirwin:mindspring at: 21-Sep-2003 10:02


Hi Brett, First, thanks for the paren tip to break out while testing rules! That's an excellent find. BH> So here is a little script that allows you to watch Parse step through your BH> input using your parse rules. Second, *very* cool idea! I'm sure this will give people some ideas about other cool ways to add visualization to parse operations. Thanks for posting those! -- Gregg

 [3/4] from: g:santilli:tiscalinet:it at: 22-Sep-2003 10:42


Hi Brett, On Sunday, September 21, 2003, 2:50:22 PM, you wrote: BH> So here is a little script that allows you to watch Parse step through your BH> input using your parse rules. Very cool! Regards, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amiga Group Italia sez. L'Aquila --- SOON: http://www.rebol.it/

 [4/4] from: antonr:iinet:au at: 24-Sep-2003 11:17


Very cool Brett, could come in handy one day. Anton.