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

World: r3wp

[Parse] Discussion of PARSE dialect

btiffin
13-Apr-2007
[1701]
If you haven't, take a read through Icon pattern matching...mondo 
powerful.  Off topic...sorry.
Maxim
13-Apr-2007
[1702x2]
here is the solution... complement the valid symbols and match them 
explicitely.

rebol []

symbol: charset [#"a" - #"z" #"A" - #"Z" #"0" #"9" "_-?!*+~"]
invalid: complement symbol
nstr: "...aa.....a.....a.....h." 

end-rule: []

parse/all nstr [
	some [
		symbol | [here: invalid (remove here) ] :here
	]
]
reading? what is that? .... oh yeah... I remember ...  something 
people with time can do ... ;-)
btiffin
13-Apr-2007
[1704x3]
More off topic...I wept a little bit when I heard of Dr. Ralph Griswold 
passing, back in October.  Never met him, much respect.
Final off topic;  Now I'm slowly replacing all my computer heroes...Names 
like Kernighan, Pike, Moore, Griswold, Lovelace... are now Sassenrath, 
DocKimbel, Anton, Cyphre, Graham, Maxim, Ladislav, Henrik, Oldes...et 
al.  Thanks guys.  You are making my world a better place.
Final final...Gregg, Gabriele, Sunanda...I'm missing too many.  :) 
 And the big hook drags me off the stage.
Ladislav
13-Apr-2007
[1707x4]
Max: ...symbol | end skip | ... does not have much sense, since it 
is equivalent to just ...symbol | ...
Max: "it would be nice if the result from the expression could be 
used to determine if the rule is a match or not" - that is of course 
possible as follows:
rule: [(next-rule: unless result-of-expression [[end skip]]) next-rule]
see this:

>> rule: [(next-rule: unless result-of-expression [[end skip]]) next-rule]

== [(next-rule: unless result-of-expression [[end skip]]) next-rule]
>> result-of-expression: false
== false
>> parse "" rule
== false
>> result-of-expression: true
== true
>> parse "" rule
== true
Maxim
13-Apr-2007
[1711x2]
yes... see the supplied fixed parser rules... I had not submitted 
the right one... I saw that after posting it  :-)
ladislav, what you demonstrate is that you can evaluate an expression 
within parse rules... parse itself does not handle the return value 
OF the expression.
Ladislav
13-Apr-2007
[1713x2]
right, but the value of the expression *can be used* to determine 
if a rule is a match
otherwise, I am for addition of a rule which would take the result 
of the paren! expression directly into account without us having 
to resort to this (more complicated) way
Maxim
13-Apr-2007
[1715x2]
that is what I meant... I'd like parse to do it for us .
obviously, using many tricks we can let parse do anything  (including 
become an event parser as I discussed above  ;-)
Ladislav
13-Apr-2007
[1717]
anyway, when you have got the RULE above, you can now always write: 
parse "" [(result-of-expression: compute-something) rule]
Maxim
13-Apr-2007
[1718]
got to go *now*   ;-)   female in the house   ;-)
Ladislav
13-Apr-2007
[1719x2]
if you use a more appropriate rule name like check-result, you have 
got a more readable:
parse "" [(result-of-expression: compute-something) check-result]
btiffin
13-Apr-2007
[1721]
guru question;  Will a utype! definition be allowed to wrap builtins? 
 SNMP MIBs require a fairly heavy weight tuple!  But will a short 
MIB conflict with internal scans of tuple! or do utype! scans take 
some form of precedent?  I've become curious, yet remain dumb enough 
to not know.
Oldes
14-Apr-2007
[1722x5]
Isn't this a bug?
>> parse [a/b] [a/b]
** Script Error: a has no value
** Near: parse [a/b] [a/b]
I don't want the a to be evaluated in the parse rules!
hm... ech.. I'm stupid.. normaly is evaluated as well, so it's not 
a bug.. but is there any way how to parse specific path! ?
I mean:
>> parse [a] ['a]
== true
>> parse [a/b] ['a/b]
== false
Brian: only Carl probably knows that.
ChristianE
14-Apr-2007
[1727]
>> parse [a/b] [(path: 'a/b) path]
== true
>> parse [a/c] [(path: 'a/b) path]
== false
Oldes
14-Apr-2007
[1728]
that works, but it's ugly:(
Gabriele
14-Apr-2007
[1729]
older versions did not evaluate paths. since newer version do, we 
need 'a/b to work. dunno if this is in RAMBO... but it needs to be 
fixed.
Oldes
14-Apr-2007
[1730x4]
Yes I know they were not evaluated before, but I'm not sure if it's 
not a feature, that they are evaluated now.
I just think, that maybe it would be good to have parse [a/b] ['a/b] 
== true as is parse [a] ['a]
But I'm not sure at all.
..because it would not be useful anyway as I would have to write 
a special rule for each refinement.
Gabriele
14-Apr-2007
[1734]
it's not a bug that they are evaluated (in fact it was requested 
in a rambo ticket). it's a bug that - since now they are evaluated 
- lit-paths are not used to match paths.
Anton
14-Apr-2007
[1735]
Maybe if the result of parens were parsed, we could use a paren to 
evaluate a path (and don't use a paren to leave as is).
BrianH
16-Apr-2007
[1736x2]
What's the status on implementing the PARSE suggestions that we hammered 
out months ago?
Many of the requests here would be handled easily by the extensions 
we proposed last year.
Gabriele
16-Apr-2007
[1738x2]
it looks like that 3.0 won't have a new parse, but i don't have any 
details and i'm just guessing.
it's also true that some requests could be implemented rather easily... 
so maybe they can make it in for the first release.
PeterWood
16-Apr-2007
[1740]
Does that imply there won't be a Unicode Charset with which to parse 
unicode strings?
btiffin
16-Apr-2007
[1741x2]
There is going to be a unicode! datatype
sorry.  Didn't finish...hit wrong key...


but I'm not sure what that means for charsets
Henrik
17-Apr-2007
[1743]
Perhaps vector! will play a part in solving the unicode problem
Pekr
17-Apr-2007
[1744]
having Unicode datytype does not mean we have unicode datatype ;-)
Gabriele
17-Apr-2007
[1745]
you can make a bitset with 65000 bits in r2... so why not in r3?
Pekr
17-Apr-2007
[1746x2]
Gabriele - how do you create unicode (mostly 16bit, or varrying) 
charset in R2? :-)
btw - pity R3 does not integrate any parser helpers, which could 
make life easier
Ladislav
17-Apr-2007
[1748]
what do you mean by "does not integrate" and by "parser helpers"?
Pekr
17-Apr-2007
[1749x2]
helpers = suggestions ... historically there were 2 or 3 lists with 
various suggestions, to some of them even Carl said he could consider 
to add them. First one was Robert's site, next one was yours, and 
several times ono various altme channels?
I don't know, as for me, I just wanted to|thru [a | b | c] :-)