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

World: r3wp

[Parse] Discussion of PARSE dialect

[unknown: 5]
30-Jun-2008
[2609]
Something like that?
Brock
30-Jun-2008
[2610]
he was looking for the number and the string though.
amacleod
30-Jun-2008
[2611x2]
No

I have a text document with section numbers in front:

2. Hello
2.1 Hello Again
2.1.1 Hello already
3. Goodbye

I want the section number inclued in hte copy
It need not be included in hte same copy just as long as I can record 
it.
[unknown: 5]
30-Jun-2008
[2613]
So you just want each line then really?
amacleod
30-Jun-2008
[2614x2]
Well it gets a little more complicated.
some parts of the docment will be multilined.
I thought it would be a simple thing that I was missing. I may need 
to re-think the formatting of the document.
[unknown: 5]
30-Jun-2008
[2616x2]
So even if something is multiline you would still want each line 
of the multiline correct?
Or do you mean a multiline might looks something like this:

2.1 Hello
       Goodbye

Where the second line doesn't have the preceeding number?
amacleod
30-Jun-2008
[2618]
Yes and formating may need to be retained
[unknown: 5]
30-Jun-2008
[2619]
Ahhh yes that gets a bit more complicated.
amacleod
30-Jun-2008
[2620]
Paul, while you are there...
I was considering using Tretbase for this project
[unknown: 5]
30-Jun-2008
[2621]
Excellent choise ;-)
amacleod
30-Jun-2008
[2622]
Let me briefly explain where I'm going to see if you think its workable 
or perhaps a there is a better solution
[unknown: 5]
30-Jun-2008
[2623]
k
amacleod
30-Jun-2008
[2624x5]
I trying to put a set of Fire department related materials online.
THey are now in pdf
I'm converting them to text and reformatting them to parse
I want to hold each section in a seperate database record
So I can index for keywords and search and read only thse sections 
I need.
Photos and diagrams will also be stored.
[unknown: 5]
30-Jun-2008
[2629x4]
Well, TRETBASE 1.0 is the only finished product right now.  So the 
only available TRETBASE app is 1.0 which is really not a multi-user 
solution.
It might work for you if you not in need of multi-user (simultaenous 
access)
The next version of TRETBASE which is in work is multi-user and supports 
indexing.
But not finished.
amacleod
30-Jun-2008
[2633]
I'm using mysql for the online component but I need a local storage 
method too for offline use
[unknown: 5]
30-Jun-2008
[2634]
It might work for that.  Can also do the images conversion for you 
in REBOL format which is nice.
amacleod
30-Jun-2008
[2635x2]
That was one of the things that had me thinking of using it.
What I would need is a simple method to sync them
[unknown: 5]
30-Jun-2008
[2637]
Best thing to do is try it out as it really takes very little time 
to setup and try and you will know probably if it is suitable for 
you in about 10 minutes.
amacleod
18-Jul-2008
[2638]
Is there a difference between a "space" and a "tab"? Can you parse 
for tab and not sapce?
Graham
18-Jul-2008
[2639x2]
I would think you would have to parse/all .. and a space is #" " 
and a tab is #"^-"
or you can use charsets
amacleod
18-Jul-2008
[2641]
Parse/all...works
thanks
Henrik
18-Jul-2008
[2642x2]
amacleod, small tip:
help char!
amacleod
18-Jul-2008
[2644]
thanks
btiffin
21-Aug-2008
[2645]
A long time ago, I offered to try a lecture.  Don't feel worthy. 
 So I thought I'd throw out a few (mis)understandings and have them 
corrected to build up a level of comfort that I wouldn't be leading 
a group of high potential rebols down a garden path.


So; one of the critical mistakes in PARSE can be remembered as  "so 
many", or a butchery of some [ any [ , so many.

some asks for a truth among alternatives and any say's "yep, got 
zero of the thing I was looking for", but doesn't consume anything. 
 SOME says, great and then asks for a truth.  ANY say "yep, got zero 
of the thing I was looking for", and still doesn't move, ready to 
answer yes to every question SOME can ask.  An infinite PARSE loop.


Aside: to protect against infinite loops always start a fresh PARSE 
block with [()   the "immediate block" of the paren! will allow for 
a keyboard escape, and not the more drastic Ctrl-C.


So, I'd like to ask the audience; what other PARSE command sequences 
can cause infinite loops?


end?  and is it only  "end", "to end" but "thru end" will alleviate 
that one?  end end end end being true?

>> parse "" [some [() end end end]]
(escape)
>> parse "" [some [() thru end end end]]
== false
>> parse "" [some [() to end end end]]
(escape)
>> 


Ok, but thru end is false.  Is there an idiom to avoid looping on 
end, but still being true on the first hit?

Other trip ups?
Oldes
21-Aug-2008
[2646x3]
>> parse "" [any [()]]
(escape)
it's one of the most simple ways how to halt rebol if you don't include 
the parens.
These condition are already fixed in R3
Louis
20-Sep-2008
[2649]
x: "12---dflksdf+++fhkw---sd+++sad"


How can I remove everything to "---" thru "+++" to end up with "12fhkwsad"
Anton
20-Sep-2008
[2650x2]
parse x [any [to "---" here: thru "+++" there: (remove/part here 
there) :here]]
Notice, after the remove that I have reset the parse index to the 
beginning of the removed part, ready to continue parsing the rest 
of the data.
Louis
20-Sep-2008
[2652]
Anton, thanks. I'll try that now. Sorry to take so long to respond---I've 
been eating.
Anton
20-Sep-2008
[2653]
No problem, Louis. You're welcome.
Louis
20-Sep-2008
[2654]
Works great! Many, many thanks.
Henrik
28-Sep-2008
[2655x3]
parse [a] ['a] ;== true

parse ['a] reduce [to-lit-word 'a] ; == false (why?)
forget it. I was confused for a second, but is there a way to parse 
that 'a correctly? The same goes for get-word! and set-word!.
I should clarify: I would like to parse a specific get-word!, lit-word! 
or set-word! as opposed to parsing on the type and then checking 
the value in some kind of action afterwards:


parse ['a 'b 'c] ['a 'b 'c] ;== true (I know this is the wrong parser 
block, but it's something to that effect I would like to see)
Anton
28-Sep-2008
[2658]
If I remember correctly, this was a problem of parse (and may still 
be)...