On Apr 24, 2012, at 1:26 PM, Sven Van Caekenberghe wrote:
OK, just to get started, let try to write a spec for SimpleLiteralArray, this is based on JSON (and my own STON, not ready for public consumption). It will soon become clear that this is slightly harder than expected, IMO a writer is needed as well.
S y n t a x
value primitive-value list nil primitive-value number true false symbol string classname
In a literal array a class name is just a symbol #(Foo) first #Foo
list #() #( elements ) elements value value , elements string '' ' chars ' chars char char chars char any-printable-ASCII-character- except-"-or-\ \" \\ \/ \b \f \n \r \t \u four-hex-digits
why do we need that?
symbol # chars-limited # ' chars ' chars-limited char-limited char-limited chars-limited char-limited a-z A-Z 0-9 - _ . / classname uppercase-alpha-char alphanumeric-char
there is not need for classname as element classname is just a pair that the interpretation should handle if necessary
number int int frac int exp int frac exp int digit digit1-9 digits - digit - digit1-9 digits frac . digits exp e digits digits digit digit digits e e e+ e- E E+ E-
Questions remain:
- is the escaping OK ?
I do not know but in literal array there is no escaping. Now if you want to put a cr into a string you probably need that
- what about symbols without a leading # ?
#(foo) -> #(#foo) #(true nil false 1 'n') -> #(true nil false 1 'n')
- what should be allowed in unquoted symbols ? I did not get the question
- what should be allowed for classnames ? Nothing
- what about namespaces ? Nothing no need I do not think that they are in literal arrays. (may be in VW but I did not check)
- do we allow infinite precision integers ? Yes
- maybe the toplevel should always be an array ?
I would say so else this is not a literalArray but a literal.
Now: shoot!
Sven
-- Sven Van Caekenberghe http://stfx.eu Smalltalk is the Red Pill