World: r3wp
[Parse] Discussion of PARSE dialect
older newer | first last |
Ladislav 2-Dec-2010 [5414] | (and doing the same thing, at least in principle) |
BrianH 2-Dec-2010 [5415x3] | Yes, and a good point it was too. |
Steeve, I'm sure that the reason it was so easy for me to come up with workarounds off the top of my head on a weak-brain day was because I had seen them before when you pointed them out and didn't remember it directly. In any case, I'm sure your stuff was great. | |
The ticket was for documentation purposes, as well as a request. It was to summarize the conversation from before. | |
Oldes 2-Dec-2010 [5418x2] | Steeve, Ladislav... sorry, but your version is not working. The main SOME rule finds only one match and than stops. Maybe I should give you a simple test string so you could test it first. |
hm.. it works on simple test, don't know why it stops for my real data. | |
Ladislav 2-Dec-2010 [5420] | that is interesting, (my version differs from Steeve's), but should be as similar to your version as possible |
Oldes 2-Dec-2010 [5421x2] | My simplified test is: parse test: {[{1}{2}][{3}{4}][]} [ some [ thru {[} ; copy the DOC copy doc to {]} ; remember the DOC-END doc-end: ; switch to DOC parsing :doc (print "start") any [ thru "{" copy n to "}" (probe n) ] ; switch to original input (print "end") :doc-end ] ] that's working as expected. |
I understand the principe, but as I say, on real file it stops. | |
Ladislav 2-Dec-2010 [5423x3] | may be a Parse bug, e.g. |
so, it is worth testing | |
What does "stops" mean, BTW? | |
Oldes 2-Dec-2010 [5426] | you can test real data as well:) print "loading data" data: read/string http://www.imagemagick.org/api/magick-image.php ask "parsing version 1" parse/all data [ some [ thru {<h2><a} thru ">" copy name to {<} doc-start: to {^/ </div>} doc-end: :doc-start [ thru {<pre class="code">} copy code to {</pre} ( probe name probe code ) any [ thru {<h5>} here: if (lesser? index? here index? doc-end) copy arg to {<} thru {<ol><p>} copy arg-desc to {</p></ol>} (printf [" * " 10 " - "] reduce [arg arg-desc]) ] ] :doc-end ] ] ask "parsing version 2" parse/all data [ some [ thru {<h2><a} thru ">" copy name to {<} ; copy the DOC copy doc to {^/ </div>} ; remember the DOC-END doc-end: ; switch to DOC parsing :doc thru {<pre class="code">} copy code to {</pre} ( probe name probe code ) any [ thru {<h5>} copy arg to {<} thru {<ol><p>} copy arg-desc to {</p></ol>} (printf [" * " 10 " - "] reduce [arg arg-desc]) ] ; switch to original input :doc-end ] ] |
Ladislav 2-Dec-2010 [5427x2] | aha, it needs to be written this way: parse/all data [ some [ thru {<h2><a} thru ">" copy name to {<} ; copy the DOC copy doc to {^/ </div>} ; remember the DOC-END doc-end: ; switch to DOC parsing ; we need OPT to be able switch back :doc opt [ thru {<pre class="code">} copy code to {</pre} ( probe name probe code ) any [ thru {<h5>} copy arg to {<} thru {<ol><p>} copy arg-desc to {</p></ol>} (printf [" * " 10 " - "] reduce [arg arg-desc]) ] ] ; switch to original input :doc-end ] ] |
since OPT was needed, it is provable, that the "inner parse" fails sometimes, which does not look desirable, and may provoke your attention, Oldes | |
Oldes 2-Dec-2010 [5429x2] | I've got it.. there is missing <pre> in the third doc so that's why Steeve's version fails. |
(I wonder what they use to document the ImageMagick project.. it does not look like fully automated documentation. There are also some typos in the spec names.) | |
Steeve 14-Jan-2011 [5431] | I'm working on an incremental lexer able to perform line-by-line analysis of any plain text documents. the idea is to allow editing without having to reparse all the document. The syntactical rules will be regular parse rules easy to understand and to modify, to facilitate the creation of different model of document. Of course, the first target is a rebol parser, but the make-doc format is also in my short range. If anyone already have deep thoughts about the subject, please share your opinions. I will come with a proto soon enough. |
BrianH 14-Jan-2011 [5432x2] | Will the REBOL parser be using the R3 incremental parser, TRANSCODE ? |
Btw, if you are using PARSE for incremental parsing, watch out for this: http://issue.cc/r3/1787 | |
shadwolf 14-Jan-2011 [5434] | what is the equivalent in R3 of disarm ? |
BrianH 14-Jan-2011 [5435x2] | Nothing, it's unnecessary in R3. |
You have to DO an error explicitly to trigger it. Otherwise, you can just reference it directly as if it were an object. | |
shadwolf 14-Jan-2011 [5437] | value: disarm :value how i translate that ? |
Steeve 14-Jan-2011 [5438] | you don't need to, just use the /error refinemeent with transcode. >> transcode/next/error and you get an error object if any |
Sunanda 14-Jan-2011 [5439] | [!REBOL3 Parse group now exists for specific R3 Parse discussions] |
Steeve 14-Jan-2011 [5440] | ok thx |
shadwolf 14-Jan-2011 [5441x3] | steeve it's in the colorize function code of area tc ... |
either error? :value [ value: disarm :value | |
how do I adapt that ? | |
BrianH 14-Jan-2011 [5444] | value: disarm :value Just get rid of the line. |
shadwolf 14-Jan-2011 [5445x2] | ok ... |
and this how i use transcode in it ? instead of load/next here ? >> error? set/any [value end] try [load/next start] | |
Steeve 14-Jan-2011 [5447] | Shad, I will do it if you wait a little |
shadwolf 14-Jan-2011 [5448x2] | I can do it now either way i need to understand the way R3 handle things |
since the disarm is gone this like don't work anymore either value/arg2/1 | |
BrianH 14-Jan-2011 [5450] | It depends on the circumstances. Once an error is triggered it can't be referred to again until it is caught by TRY, which disarms it. |
Oldes 15-Jan-2011 [5451x2] | You don't need disarm in R3: >> if error? set/any 'err try [1 / 0][ probe err true] make error! [ code: 400 type: 'Math id: 'zero-divide arg1: none arg2: none arg3: none near: [/ 0] where: [/ try] ] == true |
Do we need the set/any or is enough just: if error? err: try [1 / 0][ probe err true] | |
TomBon 15-Feb-2011 [5453x3] | how to copy a parsed stream into a object instead a string var? this fails parse page [thru <tag1> copy obj-buffer/result to <tag2>] |
** Script Error: Invalid argument: obj-buffer/result | |
ok, looks like this is working. parse page [thru <tag1> copy a to <tag2> (obj-buffer/result : copy a)] | |
Pekr 22-Feb-2011 [5456] | Common parse patterns request - http://www.rebol.com/article/0508.html |
james_nak 22-Feb-2011 [5457] | Thanks Pekr for drawing that to my attention. |
Gregg 26-Feb-2011 [5458] | If it's a patterns page, it shouldn't be R3 specific. If patterns require different implementations in R2 and R3, those can be filled in, or stubbed out with a note as to why it is either not needed or not worth the effort in one version or the other. |
BrianH 26-Feb-2011 [5459x3] | Every pattern should have an R2 and R3 version, with explanations. |
Also, every new R3 operation should have an R2 equivalent in the pattern list. The parse proposals page can be mined for examples. | |
IIRC there's only one new R3 op that doesn't have an R2 equivalent, but it might not be implemented yet. Let me check. | |
Gregg 26-Feb-2011 [5462] | I just didn't want to remove the R3-only comments without some discussion, in case there was a reason for them being there. |
BrianH 26-Feb-2011 [5463] | Yup, agreed. Just checked, LIMIT, the one proposal with no R2 equivalent hasn't been implemented yet. |
older newer | first last |