RebDev Mobile   [New]   [Top]   [Users]
Path: Top / R3 / Parse /

P
6277

Re #6261: Right, typo. -N skip (not skip -N).

Such a change would take some serious testing too... because -N can be applied to many actions. For example, what if someone types -2 "a" ?

It may be possible to restrict it, but it means each action must check for the possibility... another IF.

Carl
1254d

P
6261

Re #6231: As far as I know, the current syntax is 2 skip. Doesn't that mean, that the syntax for negative skips should be -2 skip?ladislav
1254d

P
6256

FYI I put a BNF to Parse grammar converter on rebol.org yesterday.

its the very first R3 specific script to be uploaded in history :-)

http://www.rebol.org/view-script.r?script=bnf-compiler.r

maxim
1254d

P
6255

Re #6231: as it turns out, having negative skip would simplify some uses of change.

I'm currently building a C compiler using R3 and it just so happens that I need a negative skip right now in the pre-processor!

funny that you posted this idea today.

maxim
1254d

P
6244

Re #6231: as the R3 parse improvements are mostly improvements of R2 parse patterns I'd allow skip -2.

its just a simpler way of doing:

[ here: (skip here -2) :here ]

and would make reverse parsing dead easy... skip backwards until a (forward) pattern is found.

maxim
1255d

P
6243

Re #6231: Allowing negative skips means more flexibility, but will people use it to do manual backtracking and make themselves miserable? I would keep the door open for it, but I don't think it will hinder adoption if it's not there day one.Gregg
1255d

P
6241

Coming from a non-technical person who is aware of PARSE but has not used it, it makes sense to me to allow negavie values to traverse a series in reverse. I like it, but I'll defer to others who have used PARSE more extensively.patrickp61
1255d

P
6231

PARSE does not have REVERSE, but what if we allow SKIP with negative values for going BACK in the input stream?

For example: [to ":" skip -2 "ab"]

Right now, skip negative is an error.

Carl
1255d

P
5837

Steeve found out, that the word 'limit is probably reserved for the future release. In such a case, we might need better error message imo:

>> test: ["123"] parse "123" [test] == true

>> limit: ["123"] parse "123" [limit] ** Script error: PARSE - invalid rule or usage of rule: end! ** Where: parse ** Near: parse "123" [limit]

pekr
1304d

P
5674

Re #5660: For anyone who clicked on the whitespace interpreter and got an empty page, that's a server problem not an attempt at a joke. Until that gets fixed by the admins, here's another copy stored elsewhere:

http://freebol.org/media/shared/whitespace.r

fork
1320d

P
5660

Ok a lark, I wrote a parser that is *also* a virtual machine for a language called whitespace:

http://hostilefork.com/shared/rebol/whitespace.r

Haven't tested it much, it was written rather quickly. Because, well, c'mon. It's a joke.

Yet at the same time, I think putting a bit of effort into this could be useful. It tells a story about how to implement a CS 201 assignment in a new, different way. You've got an uphill battle because you have to tell the story of "Why Rebol, not Haskell?" But I think it's a story that can be told.

Here's the output on the sample input, for anyone not feeling like running it:

http://hostilefork.com/shared/rebol/whitespace-output.txt

What I'd really like to do is have the result of the parse be a nice clean dialect. I'm thinking about that. But using the parse dialect as the VM is a good demo.

fork
1321d

H
5409

ask-groupCarl
1311d

P
5408

Re #5406: Ok, making a new thread here for chat about issues.Carl
1342d

P
5407

Re #5405: I went through those back in November - all of them were covered or explicitly rejected. I had made several of the proposals on those pages, so I was extra-careful to go over them thouroughly. The new proposals page even has a safe model for Gabriele's DO proposal - the semantiics of the old proposal weren't very specific, but the idea was great :)

Nonetheless, I'll check again in case they've made new suggestions this year.

BrianH
1342d

P
5406

Re #5404: Here is fine, or in thaat other place if you want to chat about it.BrianH
1342d

P
5405

Also, can someone confirm that Ladislav's and Gabriele's suggestions are included in the doc. (Google: rebol parse enhancements -- to find them) Thanks.Carl
1342d

P
5404

I need to startup some discussions on these PARSE changes. Where would you like that to happen?Carl
1342d

P
5403

Ok, good. Yes, I think some of these are essential, and those are the ones I want to get implemented soon.

And, actually, I should comment... I had to do some work on a parsing script recently, but R3 PARSE needs some of these changes before it's works well enough.

Also, features like TO multiple can *save* a large amount of coding time (and thought), even though they will be quite CPU intensive.

Carl
1342d

P
5399

Another priority for parsing would be to implement the virtual complement flag for bitsets suggested by Carl in response to bug#1085, and don't forget Carl's proposed FIND/not option (bug#824).BrianH
1342d

P
5397

Re #5393: We can rewrite PARSE later if necessary (after the release). I have an idea about how to do port parsing in R3 that might work, when the time for the rewrite arrives.BrianH
1342d

P
5396

Re #5392: Just updated the priorities of the Parse Proposals, based on which would have the greatest impact on usability and expressive power. See here: http://www.rebol.net/wiki/Parse_Project#Priorities I skipped ones that would be a bad idea to implement. The first 6 lines should be easy to implement - I'm not sure about the rest.BrianH
1342d

P
5394

Re #5392: http://www.rebol.net/wiki/Parse_Projectpekr
1342d

P
5393

I probably should also mention that it is unlikely that there is time to totally rewrite PARSE. It's not a simple function. However, many of the requested enhancements are not that difficult.Carl
1342d

P
5392

I'd like to gather all parse enhancements into a single list that can be prioritized (and draw a line where we must stop for 3.0.0 release).

I remember BrianH posted a list... but I've blanked out about where it is. I also know of Gabriele's and Ladislav's requests from before. I also have my personal favorites that I need.

Carl
1342d

P
4901

Re #4892: Rather than having PARSE do all this internally, and invisibly, I think there would be a lot more value in providing a parse-csv (or some more general) mezzanine. If it implemented the ABNF rules that Brian pointed out, that would make it a great example. When people have data that doesn't quite work with the built-in version, then have have an example to hack.Gregg
1411d

P
4898

Re #4894: Submitted as bug#1080, which describes the behavior but doesn't (yet) include code examples (I may add them after lunch).BrianH
1412d

P
4896

Re #4892: For a change to simple PARSE for better CSV support: bug#1079.

As for more complex CSV, the DECODE and ENCODE approach could work, but you would need DECODE-CSV and ENCODE-CSV wrapper funcs so we can specify which CSV variant we want to encode or decode, since there is no flag in the data format itself that says which variant is being used.

An alternative would be to add a /with opts option to ENCODE and DECODE that would let you pass along an object-spec-style block of options to the encoder or decoder. Not all en/decoders would need such options, but having the ability would let more complex en/decoders be implemented.

I prefer the second option, but that depends on feasibility. I'm not sure which is more difficult: Passing options to en/decoders, or having multiple codecs that map to the same file type loaded at the same time. The latter may work if only one of the choices registers a file extension for LOAD, but have others loaded and used explicitly.

BrianH
1412d

P
4894

Re #4876: BrianH: that's a good approach, and I think it can be implemented quickly.Carl
1412d

P
4893

Re #4891: Right. Let's be sure to keep these issues separate, and let's get it cleaned up and working how we all want.Carl
1412d

P
4892

Re #4890: This is easy: for "simple" CSV, write a few lines of exactly what you want it to do (and what result you want to get). We'll make it work that way.

For complicated CSV, we'll need a decoder, and then just use DECODE 'csv data. In fact, someone can write an encoder too: ENCODE 'csv block-of-data. That way we keep it consistent with how R3 decodes and encodes things.

Carl
1412d

P
4891

Re #4875: OK, I do agree with some kind of simple mode, as I often work with CSV, but it has nothing in common with how parse without /all treats spaces, no? So let's fix this mode ...pekr
1412d

P
4890

Re #4875: Yes it would made it CSV compatible.DideC
1412d

P
4876

Re #4873: What about an /ignore stuff option? You could provide a char, string or bitset as the stuff, and PARSE would pretend that stuff wasn't there, maybe unless it is explicitly referenced in a parse rule. Then PARSE/spaces would be PARSE/ignore data rule whitespace. More general.BrianH
1413d

P
4875

Re #4874: Simple parse is smart enough to handle most quoted data according to http://tools.ietf.org/html/rfc4180 - the only thing missing is the "" escaping. If we add that then we should be good. Just follow the standard: "" inside any quoted data should be translated to ". Example (from bug#1042): According to R3: >> parse {"hello""world^/",a} "," == ["hello" "world^/" "a"] >> length? parse {"hello""world^/",a} "," == 3

According to http://tools.ietf.org/html/rfc4180 : >> parse {"hello""world^/",a} "," == [{hello"world^/} "a"] >> length? parse {"hello""world^/",a} "," == 2

It's a quick fix, and should allow more data to be gotten with simple parse.

BrianH
1413d

P
4874

Re #4873: Before naming the refinement, if we do indeed make /all the default, can we get a description of *exactly* what it's *supposed* to do? i.e. what is the intent of the simple model? The fact that it is smarter than "just split at every space", but not quite smart enough to handle all quoted delimited data makes it a little unclear.Gregg
1413d

P
4873

Re #4855: Yes it will break R2 code. But there is not much R3 'parse code today, so it's time to do it. I think that /all must be the default, so maybe a /SPACES (or a better name) must be added to have the current 'parse behaviour.DideC
1413d

P
4855

Re #4843: Pekr, that is ok too. Let me know what other's think about it. The problem may be that it does break code that would otherwise work.Carl
1414d

P
4843

I am not sure it is good decision to distinguish between block parse rules, and simple string (delimiter) parse rules. I propose to scrap /all parse refinement altogether and to always treat parse the same way, using /all internally. What do you think?pekr
1415d

P
3355

Also, BrianH has created an extensive list, which will be the guiding "doc" for changes (but it is not finalized, so be sure your favorites are listed.)Carl
1506d

P
3354

Thanks Gregg. It's not intentional to change anything subtle in PARSE, so you may be seeing some bugs still. However, there will be numerous extensions to PARSE, starting with ones that add a lot of value for small amount of effort.Carl
1506d

P
3346

Re #3344: Different quantity behavior parsing string versus block:

>> parse/all series [count [copy xxx size skip (print mold xxx)]] [1] [2] [3] == false

>> series: "123" == "123"

>> parse/all series [count [copy xxx size skip (print mold xxx)]] "1" "2" "3" == true

>> count == 5

>> size == 1

Gregg
1507d

P
3345

Re #3344: Is this another change? If you COPY while parsing a paren! you get a block! as the result, not a paren!.

>> parse first [(1 2 3 4 5 6)] [some [copy p 2 skip (print mold p)]] [1 2] [3 4] [5 6] == true

Gregg
1507d

P
3344

Re #3342: I see that bug #690 addresses the charset issue.Gregg
1507d

P
3342

Re #3341: Same for block! values it seems.Gregg
1507d

P
3341

In some earlier releases of R3, PARSE supported 'to and 'thru bitset! values, but doesn't seem to anymore. Is that a bug or has the feature been removed? SPLIT uses it.Gregg
1507d

P
3276

Re #385: PARSE should be as much as possible about facilitating the creation of dialects since I see dialects as being a fundamental part that makes up the fabric of REBOL.blazs
1509d

P
2528

Edited http://www.rebol.net/wiki/Parse_Project to reflect the public R3 alpha release. Discussions of the Parse Project should be here now. Hi Peta!BrianH
1538d

P
385

Note: Once R3 goes public, the official discussions area of the Parse Project will be here. The wiki will be adjusted accordingly. One of the first orders of business will be to clean down the proposals. All mention of the theory of PARSE will need to be moved to the PARSE documentation. We need to come to decisions about which proposals are the most important (I have my opinions). The goals of this process are to: - Make the proposals clear, simple and precise. - Figure out which proposals will give us the most benefit. - Figure out which proposals are practical to implement (likely by Carl). - Document the semantics and theory of PARSE *on a separate page*. With effort, discipline and luck I think we can do all of these things :)BrianH
1583d
22-May-2013/13:35:56 REBOL.com .net