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

World: r3wp

[REBOL Syntax] Discussions about REBOL syntax

BrianH
16-Feb-2012
[84x2]
http://issue.cc/r3/1477- Special-case / words not recognized in 
lit-word!,  get-word! or set-word! form

http://issue.cc/r3/1478- Special-case arrow-based words not recognized 
in set-word! or refinement! form

Those seem to be the last two unimplemented syntax fixes in R3, at 
least that I can find/remember.
However, it looks like R3's issue! syntax isn't final: http://issue.cc/r3/1657
- Define the valid lexical forms for ISSUE! datatype
Ladislav
16-Feb-2012
[86x2]
http://issue.cc/r3/1477- however, the slash-words can have neither 
the refinement-syntax nor the path-syntax; because of that they remain 
"problematic" anyway
how about the + and - words? Is there a ticket for the refinement 
syntax?
BrianH
16-Feb-2012
[88]
Yeah, an implemented one.
Andreas
16-Feb-2012
[89]
You mean http://issue.cc/r3/1856I assume?
BrianH
16-Feb-2012
[90]
Yup. I guess it's built for an unreleased version. I was wondering 
why it's not marked as tested.
Andreas
16-Feb-2012
[91x2]
Pity that A112 never came to be up until today, then.
(Same for http://issue.cc/r3/1855.But in that case, at least ////x 
still loads in R3 :)
Steeve
16-Feb-2012
[93]
Attempt for word datatype
 

c-word: complement union charset "()[]^"{}/;<>,\#$%:@'^@" whitespace
word-syntax: [
	  [#"." | not #"'"] c-word any [c-word | digit]
	  | #"."
]
Ladislav
16-Feb-2012
[94]
hmm, it looks that #"^@" "works" as "END LOAD"
Steeve
16-Feb-2012
[95x5]
??? I don't get it
Oh, I see. you mean that "^@" is a problem wherever it is placed 
in a script
It's not specific to the word! syntax
At first I thought it should be better in whitespace
better placed
Ladislav
16-Feb-2012
[100x2]
Check END-LOAD
Why did you put #"'" into the c-word definition?
Steeve
16-Feb-2012
[102x8]
I forgot to add #"'" in the charset.

c-word: complement union charset "()[]^"{}/;<>,\#$%:@^@" whitespace
Good, you saw it
you're fast
I also forgot to add the special cases for + and -
c-word: complement union charset "()[]^"{}/;<>,\#$%:@^@" whitespace
word-syntax: [
	  [#"." | #"+" | #"-" | not #"'"] c-word any [c-word | digit]
	  | #"." | #"+" | #"-"
]
Thanks to your notes
Well it's more complex than that.
+' and -' are invalid
Maybe
word-syntax: [
	[#"." | #"+" not #"'"| #"-" not #"'"| not #"'"] 
		c-word any [c-word | digit]
	| #"." | #"+" | #"-"
]
Ladislav
16-Feb-2012
[110]
lots of exceptions, indeed
Steeve
16-Feb-2012
[111]
Should that be enforced with [termination] also ?
Ladislav
16-Feb-2012
[112x2]
Well, this way it would accept some unacceptable strings, like "." 
in ".1" e.g.
However, the TERMINATION can be added to the whole word syntax combined 
from the partial syntax cases
Steeve
16-Feb-2012
[114x2]
Well there are some annoyng  cases when values are stuck together 
but valids.
>> [a< 1]
== [a < 1]
termination can't be used to the whole
Ladislav
16-Feb-2012
[116]
yes, needs some care
Steeve
16-Feb-2012
[117]
I need a pause :-)
Ladislav
16-Feb-2012
[118x2]
however, your example looks to be R2-specific
good night
Steeve
16-Feb-2012
[120x2]
gn
last attempt for tonight

word-syntax: [
	[#"." | #"+" not #"'" | #"-" not #"'" | not #"'" and c-word] 
	[
		c-word any [c-word | digit]
		| termination
	]
]

Too obfuscated maybe
Feel free to go on anyone
BrianH
16-Feb-2012
[122x4]
Word syntax (for R3), in a comment here: http://issue.cc/r3/1302
It doesn't handle the other word types yet, so it needs work. Some 
of the syntax bug tickets came from that.
When it comes to things like word syntax, the errors raised for bad 
syntax and the particular cases where they are raised need to be 
part of the rules.
In a full syntax description, some of those charsets would be named 
differently of course.
Steeve
17-Feb-2012
[126x3]
You raise a good question Brian. Should the rules emit their own 
errors ? 

I guess the intent is to keep them light for now. If an error occurs, 
the parsing just stop.

Another guess is that alternative rules (eg. inside value-syntax) 
should be kept order independent when possible (with the drawback 
that they are slightly more convoluted than necessary).
last but not least


word-char: complement union charset "()[]^"{}/;<>,\#$%:@^@" whitespace
word-ext: [
	word-char any [word-char | digit]
	[and [#"<" | #">"] | termination]
]
word-syntax: [
	not sign not #"." not #"'" word-ext 
	| #"." [and [#"<" | #">"] | termination]
	| #"." word-ext
	| sign termination
	| sign not #"'" word-ext
	| more-less-word
]
grumpffff, still missing the cases with prefix [+.] and [-.]

word-syntax: [
	not sign not #"." not #"'" word-ext 
	| #"." [and [#"<" | #">"] | termination]
	| #"." word-ext
	| sign termination
	| sign not #"'" opt #"." word-ext      ; <--- there
	| more-less-word
]
Ladislav
17-Feb-2012
[129]
I committed a slightly different variant (but based on your findings 
as well). Could you (or other volunteers) check it, please?
Steeve
17-Feb-2012
[130]
Remaining problems with [termination] in word-syntax.
When a word is stuck with a less-word or a tag (R2 and R3)
a<
 == [a <] valid
a<=
 == [a <=] valid
a<>
 == [a <>] valid
a<<
 == [a <<] valid
a<tag>
 == [a <tag>] valid

a>=
 invalid
a>
 invalid
a>>
 invalid

IMO, t's enough to check if the following char is #"<" only

word-syntax: [
	slash-word termination
	| more-less-word termination
	| opt sign [#"." | not #"'"] not digit any word-char
		[termination | and #"<"]
]
Ladislav
17-Feb-2012
[131]
a<
 == [a <] - this does not work in R3
Steeve
17-Feb-2012
[132x2]
???? it's working there
>> system/version
== 2.100.95.3.1