REBOL3 tracker
  0.9.12 beta
Ticket #0002238 User: anonymous

Project:

Previous Next
rss
TypeWish Statusreviewed Date5-Aug-2015 05:18
Versionr3 master CategoryParse Submitted byfork
PlatformAll Severityminor Prioritynormal

Summary Have PAREN! parse rules catch EXIT, and if EXIT/WITH use result as rule
Description It seems it would be nice if there were a way for a PAREN! to exit back to the parse, as well as to be able to return a computed rule to use for the next processing step.

RETURN needs to return out of the function that's using the PARSE (and when definitionally scoped, it will be even more important that it do that and-only-that). EXIT is in flux for having other meanings, and one potential meaning is to be the *non-definitional* form of RETURN. So EXIT would mean exit out of whatever the most recent meaningful scope is (as defined by "thing that pays attention to exits", which is a bit vague. But so are loops w.r.t. BREAK and CONTINUE.)

So why not let EXIT do both? If it has an argument then that argument would be used as a rule:

>> parse "aaaaa" [(exit/with [some "a"])]
== true

Without an argument it would return UNSET!, which would just be skipped as a rule (as unsets are already).

This would mean that exit could do any control that the parse dialect itself could do, including exiting the parse or BREAKing the current rule. Under the current keywords and handling, you could thus say:

>> parse "aaaaa" [(exit/with [return (1020)])]
== 1020

(Though I'm not sure I think RETURN is the right word or that syntax with parens is right.)
Example code

			

Assigned ton/a Fixed in- Last Update5-Jan-2016 23:44


Comments
(0004679)
Ladislav
5-Jan-2016 06:00

I would say that PARSE is actually a kind of cycle, meaning that it is possible to simulate any cycle using PARSE. Therefore, I would understand a request to let BREAK work in PARSE as in other kinds of cycle as more logical than this.

Date User Field Action Change
5-Jan-2016 23:44 ladislav Status Modified submitted => reviewed
5-Jan-2016 06:00 ladislav Comment : 0004679 Added -
11-Aug-2015 15:00 Fork Summary Modified Have PAREN! parse rules catch BREAK and CONTINUE and use result as rule => Have PAREN! parse rules catch EXIT, and if EXIT/WITH use result as rule
11-Aug-2015 15:00 Fork Description Modified -
5-Aug-2015 06:28 Fork Summary Modified Have PAREN! parse rules catch BREAK and re-evaluate BREAK/WITH (a.k.a. /return) => Have PAREN! parse rules catch BREAK and CONTINUE and use result as rule
5-Aug-2015 06:28 Fork Description Modified -
5-Aug-2015 06:16 Fork Summary Modified Inside a paren parse rule, use result of EXIT/WITH as a rule => Have PAREN! parse rules catch BREAK and re-evaluate BREAK/WITH (a.k.a. /return)
5-Aug-2015 06:16 Fork Description Modified -
5-Aug-2015 05:21 Fork Description Modified -
5-Aug-2015 05:18 Fork Ticket Added -