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

[REBOL] Re: "a REBOL dialect is usually limited...

From: rebol-list2:seznam:cz at: 12-Nov-2002 16:26

Hello Gabriele, Friday, November 8, 2002, 9:25:42 PM, you wrote: GS> Hi RebOldes, GS> On Wednesday, November 6, 2002, 12:41:47 AM, you wrote: R>> myFunc(arg, someObject.someOtherFunction(random(100))) GS> Couldn't you write it as: GS> myFunc (arg someObject/someOtherFunction (random (100))) No, because the interpreter has no hint that someOtherFunction is function so this would be parsed only as property of someObject and the (random (100)) as third parameter of myFunc :-( The commas are usefull helpers for interpreter that tells that the myFunc has only 2 arguments and so it know that the someOtherFunction is the function in the someObject with argument random(100) I'm still not sutisfied with my Actions interpreter in my Rebol/Flash dialect, but it's quite complicated thing and I don't want to spend so much time on it, although sometimes I think I will make it again (to make it better). But I'm not so good in the recursive parsing (and to tell the true, without your help, I'm not sure if the actions-parser would be here at all) GS> or, even being more aggressive on the syntax. GS> If you need to keep the original syntax, a string parser is the GS> best way IMHO; you can't expect REBOL to be able to parse into GS> REBOL values any syntax if you aren't willing to provide the GS> parser yourself. For string x block parsing I did this test: ;--cut-- test: {aaa "bbb" 111 ddd} ;string based parsing: t: now/time/precise digit: charset [#"0" - #"9"] alpha: charset [#"A" - #"Z" #"a" - #"z"] alphanum: union alpha digit spa: charset [#" " #"^-" #"^/"] string: [#"^"" any alphanum #"^""] word: [some alphanum] probe parse/all test [any [word | some digit | string | some spa]] loop 100000 [ parse/all test [any [word | some digit | string | some spa]] ] print now/time/precise - t ;block based parsing: t: now/time/precise probe parse/all load test [any [word! | integer! | string!]] loop 100000 [ parse/all load test [any [word! | integer! | string!]] ] print now/time/precise - t ;--cut-- with these result: true 0:00:00.991 true 0:00:00.821 As you can see, the string parsing is not faster and that's only simple example. Try to make string based parser with corect handler of blocks and strings and all these things. String parsing is good for example for parsing web-pages where you need only small part of large page (so you don't want to load/markup the page) but for large dialect projects is the block parsing much more better. The possible solutions: 1. to have access to rules which are used in loading (so we can make our own datatypes! 2. to have load/safe or load/all which will not throw error as invalid tag etc. but will convert these words into something which we can parse using for example string parsing (maybe something like unknown! datatype?) I think that the second way is more simple to implement. Cheers, Oldes