r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[Parse] Discussion of PARSE dialect

Pekr
30-Sep-2009
[4111x2]
not end means, that the rule is matched as true, if not at end ...
it is kind of check
Henrik
30-Sep-2009
[4113]
does skip mean, skip 1 element?
Pekr
30-Sep-2009
[4114x3]
if not at end, insert [.]
yes, skip is skip 1 by default ...
not skip 1, but 1 skip ....
Henrik
30-Sep-2009
[4117x2]
ah, forgot that the block is only of max. three values
BTW, why are we saying END instead of TAIL ?
Steeve
30-Sep-2009
[4119]
parse block [
	skip   ;** skip the first value

 not end   ;** check if the block have a second value (if not, then 
 stop)

 insert [ _ ] skip   ;** insert what is inside [ ] before the second 
 vlue , skip what it has been inserted, and skip one more time to 
 pass the second value.
	not end  ;** check if there is a third value (if not, then stop)
	insert [ . ]  ;** insert [.] before the third value 
]
Henrik
30-Sep-2009
[4120x2]
I think I get it now, thanks.
I wonder if we can test against a larger parse project now, such 
as postscript.r?
Steeve
30-Sep-2009
[4122]
i widely using it now, i rewrite an assembler/desassembler for Z80
BrianH
30-Sep-2009
[4123x2]
STAY is only useful for rules with effect: modifiers, and rules containing 
productions. Sometimes you need to do stuff where necessary and not 
care whether they were necessary later.
We do have IF (renamed CHECK).
Steeve
30-Sep-2009
[4125]
It's theorical, i wonder if it's of any real use because we can do 
what you mean without STAY.
BrianH
30-Sep-2009
[4126x2]
END is a keyword. This is PARSE, not DO.
I am of the opinion that STAY is of (very) limited but significant 
use, but that AND is of critical, everyday use, as much as NOT.
Steeve
30-Sep-2009
[4128x3]
i want see the code where you demonstrate that STAY saves something.
i'm not convinced :-)
i agree for AND urgency
BrianH
30-Sep-2009
[4131]
STAY is of use when combined with CHANGE or INSERT, when you want 
the parse position to be set to the position before the insert not 
after, and when the modification is optional, or otherwise doesn't 
need to be specially checked.
Maxim
30-Sep-2009
[4132x2]
I posted on the blog about REMOVE.  much prefer matching a rule.
since we can easily do [11 skip]  to simulate an index.
BrianH
30-Sep-2009
[4134x2]
STAY is a more efficient shortcut for OPT AND.
Maxim, Steeve, I also prefer REMOVE 1 (my original proposal from 
November) and CHANGE 1. REMOVE 2 is too fiddly to satisfy the bug-reduction 
purpose of the CHANGE and REMOVE proposals.
Maxim
30-Sep-2009
[4136]
I think carl also prefers it, especially since he wrote as a pre 
rule, so it needs no explicit blocks on simple rues.   :-)
Steeve
30-Sep-2009
[4137]
Maxim, Did you miss the more recent note where Carl announces that 
your preference has been implemented in a84 ?
BrianH
30-Sep-2009
[4138]
About that bug: CureCode it. I'm serious, post it ASAP.
Steeve
30-Sep-2009
[4139]
Which bug ?
BrianH
30-Sep-2009
[4140]
remove copy
Maxim
30-Sep-2009
[4141]
yep... I read it just after posting  :-)
Steeve
30-Sep-2009
[4142]
Brian, you said: 

STAY is of use when combined with CHANGE or INSERT, when you want 
the parse position to be set to the position before the insert not 
after, and when the modification is optional, or otherwise doesn't 
need to be specially checked.

you mean something like:

parse [...][ STAY rule remove something]

but it's the same thing that:
parse [...] [remove something]

i don't see your point, give an example please.
BrianH
30-Sep-2009
[4143x2]
PARSE bugs, particularly new ones, are all urgent priority. This 
is what we're working on now.
REMOVE doesn't advance, so STAY isn't needed. That's why I didn't 
mention REMOVE.
Maxim
30-Sep-2009
[4145]
steeve, remove is the odd case cause it returns the original position 
anyways, insert moves cursor past insert
BrianH
30-Sep-2009
[4146]
CHANGE or INSERT, or rules containing productions.
Maxim
30-Sep-2009
[4147]
I would stay A LOT with remark  , stay  its just a shorthand for 
  

 pos: [rule] :pos 

 but its handy  :-)
BrianH
30-Sep-2009
[4148]
No, that's AND. STAY is pos: opt [rule] :pos
Steeve
30-Sep-2009
[4149x2]
Brian, try it with INSERT if you want, it's the same useless thing.

>> parse a: "123" [STAY "456" insert "0"] a
== "0123"

Exactly the same thing that:

>> parse a: "123" [insert "0"] a
== "0123"
STAY has no use
BrianH
30-Sep-2009
[4151]
You are still putting the matching rule as the stay argument, not 
the modifying rule.
Steeve
30-Sep-2009
[4152x3]
hmmm....
i give it a try
oh I see...

>> parse "123" [insert "0" ??]
end!: "123"
== false

>> parse "123" [stay insert "0" ??]
end!: "0123"
== false
BrianH
30-Sep-2009
[4155]
Right now, since we don't have CHANGE, the opt aspect of STAY doesn't 
matter with INSERT. To have use you have to use it with rulees with 
productions in them.
Steeve
30-Sep-2009
[4156]
i see a little better now
BrianH
30-Sep-2009
[4157x2]
STAY is equivalent to OPT AND or AND OPT.
Just like AND is the (much less annoying) equivalent of NOT NOT, 
in theory.
Steeve
30-Sep-2009
[4159]
Brian, i posted the bug, you can rewrite it now :-)
BrianH
30-Sep-2009
[4160]
Cool, thanks :)