World: r4wp
[Rebol School] REBOL School
older newer | first last |
MaxV 18-Sep-2012 [993x2] | Please put some example, you are a bit vague |
Read this http://rebol2.blogspot.it/2012/05/text-extraction-with-parse.html ;-) | |
Maxim 18-Sep-2012 [995x3] | does this help? -------------------------- a: {123 abcd bla blca bla 534 hged bla blca bla 947 ahg psogie rpgioseg seo[rgieh rpgiu} digits: charset "0123456789" letters: charset [#"A" - #"Z" #"a" - #"z"] space: charset " " data: complement charset "^/" ctx: copy [ ] parse/all a [ some [ copy id some digits space copy var 3 4 letters space copy line-data some data ; we have a match for all data, add it in our container ( append ctx copy reduce [ to-set-word rejoin [var "-" id] line-data] ) "^/" ] ] ctx: context ctx probe ctx |
obviously, this depends on the input data being pristine... if there are chances that the input isn't, then a bit more code would allow you to safely skip invalid lines. | |
I added a bit of processing to show how to use parse in order to actually do things beyond just match patterns. note that the paren is at the end, once we have all data we want to match. An error people often do is to start processing too soon. | |
MagnussonC 18-Sep-2012 [998] | Thank you both! Now I have something to work with. Didn't realize you could do parse complex like that. |
Maxim 18-Sep-2012 [999] | believe me... this is very simple parsin ;-) |
Gabriele 19-Sep-2012 [1000] | Max... "copy reduce" ? :-) |
MagnussonC 19-Sep-2012 [1001] | Haven't had time to try the above yet. It would be interesting to see more complex examples of parsing. No need to write it here, only if you can redirect me to any existing code online. The examples I have found seems simple, but maybe there are things implicated in those examples that I don't grasp ... |
Maxim 19-Sep-2012 [1002] | gab... oh yeah... copy isn't needed there.... it just evolved that way :-) |
Gregg 19-Sep-2012 [1003] | Magnusson, have you looked at the REBOL manual that explains the parse grammar? |
Ladislav 19-Sep-2012 [1004] | See also http://en.wikibooks.org/wiki/REBOL_Programming/Language_Features/Parse/Parse_expressions |
MagnussonC 20-Sep-2012 [1005] | Gregg, yes. Ladislav, I'll check that also. The example Maxim gave was more what I was looking for, I think. Haven't had time to test it yet. Thanks for the help.. |
NickD 23-Sep-2012 [1006] | There has to be something Rebol is doing beyond a simple language api to get level of security purported by Carl. What kind of pipes does it use? |
Kaj 23-Sep-2012 [1007x2] | What kind of pipes do you have in mind? |
There's nothing much special in REBOL regarding security | |
NickD 23-Sep-2012 [1009] | My misunderstanding then. I do not even know what 'pipes' are. I am posing the question on behalf of another. The question started based on the understanding from a conversation with Carl concerning the security benefits of AltMe and the once pending contract with the CIA. |
Kaj 23-Sep-2012 [1010x5] | Pipes usually refer to network connections. The encryption that is usually employed there (SSL) is missing from many REBOL versions |
Pipes can also refer to local connections between processes, but that's originally a Unix technology | |
AltME is secure for partly different reasons. We are told it employs encryption over the network, but we can't check that, because it's closed source | |
When AltME was introduces a decade ago, many communication systems were unencrypted, so it was good then. Like Lotus Notes at the time | |
It's also more secure because you run your own server, instead of handing your data to a provider. That's fundamental, as long as you keep the data safe on all AltME clients. Which is hard, because it's not encrypted on disk | |
NickD 23-Sep-2012 [1015] | Ah. Ok. Thanks so much |
MarcS 3-Oct-2012 [1016x2] | does anyone have time to sanity check / comment on the style of the following script: http://0branch.com/highlight/snippets/rfunc.r? |
(i left in a couple of examples to demonstrate usage) | |
Henrik 3-Oct-2012 [1018] | it's certainly quite clean looking. did not analyse the code yet. |
MarcS 3-Oct-2012 [1019] | as the title suggests, it's a fudge |
Ladislav 3-Oct-2012 [1020] | One immediate note: the RFUNC function as it is written actually modifies its SPEC and CODE arguments (that may be OK, but should be mentioned) |
MarcS 3-Oct-2012 [1021x2] | spec isn't modified |
re: body, is "Function body to be augmented w/ recursion context" not clear? [if not, will add clarification] | |
Ladislav 3-Oct-2012 [1023x2] | Actually, the SPEC block *is* modified, but in a way that may not matter often |
It might be better, though, to not modify it at all. | |
MarcS 3-Oct-2012 [1025] | what are you referring to? |
Ladislav 3-Oct-2012 [1026] | the USE function modifies its argument. |
MarcS 3-Oct-2012 [1027x2] | are you referring to shadowed bindings? |
like, rfunc [ _recur_ ] [ _recur_ ] won't do what i expect? | |
Ladislav 3-Oct-2012 [1029x2] | it would do what you expect, but: spec: [...] body: [....] rfunc [spec] [body] would cause some modifications that may be unwanted. |
sorry, I meant rfunc spec body | |
MarcS 3-Oct-2012 [1031] | hmm, i haven't considered that case |
Ladislav 3-Oct-2012 [1032] | However, the USE function still (in R2) does not contain any warning it is modifying its BODY argument... |
MarcS 3-Oct-2012 [1033] | i just thought i was setting up a new lexical scope |
Ladislav 3-Oct-2012 [1034] | You are OK, most probably, but not due to the fact that USE is not modifying, rather due to the fact that it most frequently does not matter. |
MarcS 3-Oct-2012 [1035] | i'm afraid i'm not clear on what's being mutated |
Ladislav 3-Oct-2012 [1036x2] | THat is a complicated issue, but the principle is easy. USE modifies it BODY and should be treated as modifying. However, you can easily define a non-modifying version: USE words copy/deep body |
...and, in most cases the difference does not matter (but still, I prefer to be warned) | |
MarcS 3-Oct-2012 [1038x5] | aha, thanks |
i just looked at the r2 and r3 docs, i see the issue now | |
so: conceptually, it shouldn't matter as you're supposed to be recursing rfuncs with 'recur' | |
but semantically it would be better to address this | |
updated: http://0branch.com/highlight/snippets/rfunc2.r | |
older newer | first last |