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

"a REBOL dialect is usually limited...

 [1/7] from: rebol-list2::seznam::cz at: 6-Nov-2002 0:41


Hello Gregg (and rebol-list), I'm reading the IOS conference now and because this my reply will be posted much more later, I'm using email not to lost the context.... on 5.11. you wrote: --- RE: "a REBOL dialect is usually limited to REBOL words and block structure", I disagree. You can use any words you want in your dialect, and I wouldn't call a block structure "limited" but, rather, "ready for processing". :-) This is my view, which may not be yours. --- I have to disagree, because as I'm working probably on one of the most complex (public?) dialects -> Rebol/Flash with something like Rebol-ActionScript compiler, I've found myself limited in the use of the 'load function - because I realy don't want to write string based parser. One example: in ActionScript (ECMAScript) you can write: myFunc(arg, someObject.someOtherFunction(random(100))) To compile such a complicated code is not easy and the separator would be very useful. But in Rebol I cannot use the comma in my dialect file, because loading such a code throws an "Invalid word" error:
>>load {,}
** Syntax Error: Invalid word -- , ** Near: (line 1) , The same problem is with emulating "left shift" function (<<)
>> load {<<}
** Syntax Error: Invalid tag -- << ** Near: (line 1) <<
>> load {>>}
== >> So as Allen wrote in the IOS conference, I would loved to work with something like load/save where no error will be thrown and rebol will convert it into strings, words or even an unknown! type. So I may work with them in the parser. Somone may say I may use another preprocessing using load/next to catch these errors but I think that this is not the best solution (and I'm sure that something like load/save wouldn't be so difficult to implement) Cheers Oldes

 [2/7] from: g:santilli:tiscalinet:it at: 8-Nov-2002 21:25


Hi RebOldes, On Wednesday, November 6, 2002, 12:41:47 AM, you wrote: R> myFunc(arg, someObject.someOtherFunction(random(100))) Couldn't you write it as: myFunc (arg someObject/someOtherFunction (random (100))) or, even being more aggressive on the syntax. If you need to keep the original syntax, a string parser is the best way IMHO; you can't expect REBOL to be able to parse into REBOL values any syntax if you aren't willing to provide the parser yourself. Regards, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amigan -- AGI L'Aquila -- REB: http://web.tiscali.it/rebol/index.r

 [3/7] from: carl:cybercraft at: 9-Nov-2002 13:25


On 06-Nov-02, RebOldes wrote:
> Hello Gregg (and rebol-list), > I'm reading the IOS conference now and because this my reply will be
<<quoted lines omitted: 15>>
> the 'load function - because I realy don't want to write string > based parser.
I've hit this problem, and it has a downside and an upside. The downside as you quickly find out is that blocks are faster to parse but can't contain everything you like, whereas strings can contain everything but are slower. My solution was to have a two-parse system. I'd first parse the string into a block of words (or numbers or whatever datatypes are most appropriate) and then the main parser would do the real processing. The upside of this is that in the first parse you can not only do a simple conversion of the string to a block, (ie: from a , b to [a comma b]), but also convert it to a format more suited to parsing in REBOL. For instance, the dialect may be slow to parse if you attempt to parse it by following its native form, whereas if you converted it to RPN in the first parse, it might run many times faster during the second parse. -- Carl Read

 [4/7] from: rebol-list2::seznam::cz at: 12-Nov-2002 16:44

discrimination of comma (was: Re: "a REBOL dialect is usually limited...


Hello rebol-list, I think that Rebol is discriminating the comma becasue we can have a dot as word! but not the comma as word!
>> type? load {.}
== word!
>> type? load {,}
** Syntax Error: Invalid word -- , ** Near: (line 1) , Somone can argue, that it's because of the decimal! datatype in Rebol (the only use of comma at this moment)
>> type? load {1,2}
== decimal!
>> type? load {,2}
== decimal!
>> load {.2}
== 0.2 And you can even write:
>> to-block {1,}
== [1] But this I would consider as a reason to throw the invalid decimal error because who writes decimals in such a way? What if I have some input where I want user to write a decimal walue 1.2 and I want to work with it:
>> to-block {1,2}
== [1] but the user make a mistake and press space:
>> to-block {1, 2}
== [1 2] The application don't know that it's bad value and in better way it uses the first one. So on one side we have error friendly decimals but not comma as a word! And I ask you, why? Oldes

 [5/7] from: rebol-list2:seznam:cz at: 12-Nov-2002 16:26

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


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

 [6/7] from: greggirwin::mindspring::com at: 12-Nov-2002 11:36

Re: discrimination of comma (was: Re: "a REBOL dialect is usually limite


R> So on one side we have error friendly decimals but not comma as a R> word! And I ask you, why? It's just the way REBOL's lexical analyzer works. The dot (.) is a valid word all by itself, but the comma is not. I'm sure there's a good reason, but I don't know what it is.
>> .: 4
== 4
>> .
== 4
>> ,: 4
** Syntax Error: Invalid word -- ,: ** Near: (line 1) ,: 4 -- Gregg

 [7/7] from: g:santilli:tiscalinet:it at: 12-Nov-2002 20:49

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


Hi RebOldes, On Tuesday, November 12, 2002, 4:26:40 PM, you wrote: R> As you can see, the string parsing is not faster and that's only R> simple example. I never said it would be faster. Indeed, I would completely abandon that syntax, and use a value based grammar, so that a block parser can be used. R> Try to make string based parser with corect handler of R> blocks and strings and all these things. That's the easy part. :-) R> String parsing is good for example for parsing web-pages where you R> need only small part of large page (so you don't want to load/markup R> the page) but for large dialect projects is the block parsing much R> more better. Again, I agree, but you can't expect LOAD to be able to convert into REBOL values any kind of syntax "magically"; also, you cannot expect to be able to do value base parsing if your grammar is not value based. R> I think that the second way is more simple to implement. Hmm, I think that it would be much simpler to design a value based language. :-) Or, use string parsing with a simple rule that only converts you language into REBOL values, and then use block parsing for the real parsing. Regards, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amigan -- AGI L'Aquila -- REB: http://web.tiscali.it/rebol/index.r

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted