World: r3wp
[Parse] Discussion of PARSE dialect
older newer | first last |
Ladislav 1-Nov-2005 [640] | which might do what you wanted for if (clause) | break |
Graham 1-Nov-2005 [641] | I think 'or should be an alternative to | ( off topic ) |
BrianH 1-Nov-2005 [642] | Should the keyword be named TEST? I chose IF because it was less likely to be used for variables in existing code, and it corresponds to the equivalent concept in the different semantic model. Plus, that's how they say it in other predicated parsers. |
Graham 1-Nov-2005 [643x2] | conditionally |
saw that in one forth book. | |
BrianH 1-Nov-2005 [645] | If there are no other comments or suggestions, I'll submit it as worded above. |
Volker 1-Nov-2005 [646] | I am ok with that. after thinking about prolog&icon withthe if too. |
Graham 1-Nov-2005 [647] | Go. |
Ladislav 1-Nov-2005 [648] | yes |
BrianH 1-Nov-2005 [649x3] | I didn't do a really useful example, just one to demonstrate the current way of faking the behavior. Example: [if (test) | ...] Fix: [(unless test [dummy: [end skip]]) dummy | ...] |
On a (slightly) different note, has anyone tried to implement incremental parsing with parse? Last time I tried something like continuations, but there must be a better way... | |
For instance, can you put a wait in a parse paren? | |
Volker 1-Nov-2005 [652x2] | Interesting idea. I guess that would work. but not with async. |
for small things i would just reparse the whole thing. | |
BrianH 1-Nov-2005 [654] | See, this is why I wanted that if clause. It's so easy to mess up the workaround. Fix: [(dummy: unless test [[end skip]]) dummy | ...] |
Volker 1-Nov-2005 [655] | what i would like is in incremental parse as base for multitasking. |
BrianH 1-Nov-2005 [656x2] | I was thinking about parsing data larger than available memory, or coming over a slow link. |
Something like do/next for parse. | |
Volker 1-Nov-2005 [658x2] | Or beeing interactive, where the next things depend on what you reply. |
but i know no good way with parse only. | |
BrianH 1-Nov-2005 [660x4] | f: open/direct file a: copy/part f 4096 parse a [some [rule1 | rule2 | b: if (if a: copy/part f 4096 [b: join b a]) :b]] |
With the IF workaround applied, if you can. | |
Well, I submitted the entry when you all said it was OK (I forgot to mention). Now we get to see how it all turns out. I like RAMBO much more than feedback - more public. | |
Later all! | |
Graham 1-Nov-2005 [664] | Keep us informed on the outcome :) |
Gabriele 1-Nov-2005 [665] | btw, my compile-rules.r implements IF (i don't recall if exactly as noted above, but i think so, or very close). i had a rep with this and other things too. |
Ladislav 1-Nov-2005 [666] | http://www.compkarori.com/vanilla/display/TO, THRU And NOT PARSE Rules implements IF too, but using IF [...] instead of IF (...) , which is the only difference as far as I can tell |
BrianH 1-Nov-2005 [667] | Gabriele, I recall that it didn't work the same, but have no way of checking that right now because I couldn't find your compile-rules.r on rebol.org and you didn't provide a link just now. |
Gabriele 1-Nov-2005 [668x4] | it's different, as i made it as: |
| 'if set val1 paren! ; NEW: apply rule only if condition is true element | 'either set val1 paren! ; NEW: choose rule based on condition element element | |
i think there are pros and cons to both approachs. | |
i admit i haven't used if and either much though, what i used a lot was DO. | |
BrianH 1-Nov-2005 [672] | I prefer the continue-if-true version. I particularly like that there is a workaround now that the backtrack-through-paren bug has been fixed since I first suggested an IF clause. |
Ladislav 1-Nov-2005 [673] | BrianH: see the above link, it is an IF as you proposed, except that it uses a block instead of paren!, because that was simpler to implement, but it doesn't matter much, can be transformed |
Graham 4-Nov-2005 [674x2] | How do get parse out ^? |
>> caret: charset [ #"\^" ] ** Syntax Error: Missing " at caret: charset [ #"\^" ] ** Where: halt-view ** Near: caret: charset #"a" | |
Volker 4-Nov-2005 [676] | ^^ |
Graham 4-Nov-2005 [677x2] | oh :( |
I thought \ was the escape char. | |
Volker 4-Nov-2005 [679] | I like it. easier to include javascript in strings, no need to escape its escapes. |
Graham 4-Nov-2005 [680] | What do you like? |
Volker 4-Nov-2005 [681] | that rebol uses a different escape-char. |
Graham 4-Nov-2005 [682x4] | ok |
>> caret: charset [ #"^^" ] == make bitset! #{ 0000000000000000000000400000000000000000000000000000000000000000 } | |
>> obx: {OBX|1|ST|Hb^ Hb:^L||135|g/L|120 - 155|N|||F^/} == "OBX|1|ST|Hb Hb:^L||135|g/L|120 - 155|N|||F^/" | |
>> parse obx [ "OBX" "|" digits "|" "ST" "|" thru caret to end ] ** Script Error: Invalid argument: make bitset! #{ 0000000000000000000000400000000000000000000000000000000000000000 } ** Where: halt-view ** Near: parse obx ["OBX" "|" digits "|" "ST" "|" thru caret to end] >> | |
BrianH 4-Nov-2005 [686] | Is that with the caret as an escape char, or as a value? |
Volker 4-Nov-2005 [687x2] | that is thru with a charset. any caret |
no, grrr, lack of smarter thru is annoying. | |
BrianH 4-Nov-2005 [689] | Because it looks like the carets in your data are registering as escape characters. That ^H is registering as a backspace character, not the sequence "^H". |
older newer | first last |