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
[124x2]
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
Ladislav
17-Feb-2012
[134]
>> system/version
== 2.100.111.3.1
Steeve
17-Feb-2012
[135x2]
Humm... a bit old, well with the last version you're true
but, it remains a problem when followed by a tag
Ladislav
17-Feb-2012
[137x3]
A112 (not released) is reported to have other improvements related 
to get-words and set-words
remains a problem when followed by a tag
 - indeed, needs adjustment then
A question for Brian: do you think the case:


load "a<a>" ; == [a <a>] shall be mentioned in CC? (and, eventually, 
where?, a new ticket or an old one?)
Steeve
17-Feb-2012
[140]
Question:
Why #"/" is in termination-char ?

(termination-char: union whitespace charset "()[]^"{}/^@;" )
Ladislav
17-Feb-2012
[141]
That is because #"/" is a separator in paths
Steeve
17-Feb-2012
[142]
well it's a problem for the other datatypes which use [termination]
Ladislav
17-Feb-2012
[143]
example?
Steeve
17-Feb-2012
[144x2]
example: word-syntax
with the current ruke a word can be terlinated with #"/'
*rule
Ladislav
17-Feb-2012
[146]
yes, but that is not a problem
Steeve
17-Feb-2012
[147]
*terminated/followed
Ladislav
17-Feb-2012
[148]
(is it?)
Maxim
17-Feb-2012
[149]
>> hh/
** Syntax Error: Invalid path -- hh/
** Near: (line 1) hh/
Ladislav
17-Feb-2012
[150]
Yes, but that is not a problem for the word, it is an invalid path
Steeve
17-Feb-2012
[151]
[aaaa/] is not a word! it's a path!
Maxim
17-Feb-2012
[152]
I was just wondering if that is what Steeve meant
Steeve
17-Feb-2012
[153]
yep
Maxim
17-Feb-2012
[154]
Steve are you aware of the R3 parse AND operator?  maybe that is 
throwing you off?
Ladislav
17-Feb-2012
[155x2]
yes, load "aaaa/" reports an "invalid path". However, the word is 
valid.
>> p: load "aaaa/1"
== aaaa/1

>> type? first p
== word!
Steeve
17-Feb-2012
[157]
but I think it should be detected inside the path-syntax not in the 
word-syntax or not ?
Ladislav
17-Feb-2012
[158]
Actually, inside the path-syntax you need to detect the word...
Maxim
17-Feb-2012
[159x2]
the AND is a look ahead.  it doesn't advance the input, so whatever 
is matched by    [ AND termination ] only tries to find a delimiter.
signaling the end of the word, without consuming the "/"
Steeve
17-Feb-2012
[161]
I know that already Max ;-)
Maxim
17-Feb-2012
[162]
ok, just wanted to be sure :-)
Steeve
17-Feb-2012
[163]
Al least it's a problem with [termination] used in tuple-syntax and 
decimal-syntax.
Don't say i'm wrong here again :-)
Ladislav
17-Feb-2012
[164]
I do not know an example where it would be wrong
Steeve
17-Feb-2012
[165]
[1.2.3/] how can that be valid ?
Maxim
17-Feb-2012
[166]
ah, yes... you are struggling with the AND here   :-)   the termination 
is not part of the tuple... but it does mark it  :-)
Steeve
17-Feb-2012
[167]
with the current rules it would be checjed like [1.2.3 /]
Ladislav
17-Feb-2012
[168]
that is not a valid path, but this one is:

>> type? second load "a/1.2.3/b"
== tuple!
Steeve
17-Feb-2012
[169]
That's right it makes the tupple valid which is wrong
Ladislav
17-Feb-2012
[170]
The tuple *is* valid, what is invalid is just the path in your example
Maxim
17-Feb-2012
[171]
no, it makes the PATH invalid.
Steeve
17-Feb-2012
[172x2]
what !!!!!!
I can't believe it
[1.2.3/b] = [1.2.3  /b]