Here is what I'm thinking for the grammar of the Fan serialization syntax:
doc := usings | obj
obj := complex | simple | literal
literal := bool | int | float | str | duration | uri | list | map | type // same as Fan source
simple := type "(" str ")"
complex := type "{" fields "}"
fields := field (eos field)*
eos := ";" | newline
field := id "=" obj
type := // same as Fan
The using declarations work just like Fan to allow non-qualified type names. Both /* and // comments are supported.
Here is an example:
using user
fand::App
{
user = user::UserService
{
enabled = true
users = // list
[
user::User { name = "brian"; bday = sys::Time "1972-6-7" }
User { name = "andy"; bday = Time("1980-10-22") }
]
}
web = web::WebService
{
port = 80
}
env = [ "a":"alpha", "b":"beta" ] // map
}
Semantically "type { f1 = obj1; f2 = obj2 } maps directly to:
x := type.make
x->f1 = obj1
x->f2 = obj2
And "type(str)" maps directly to:
x := type.parse (str)
Open Issues:
Simples will be denoted by a mixin? Annotation?
Complex fields are denoted by keyword? Annotation?
How deep do complex's serialize? Notation of "extent"
How are non-tree relationships/references serialized?
Should facets be part of syntax?
What is API look like? Is this just new methods on InStream and OutStream?
Can this syntax be used directly in Fan source code?
brian Wed 15 Aug 2007
Here is what I'm thinking for the grammar of the Fan serialization syntax:
The using declarations work just like Fan to allow non-qualified type names. Both /* and // comments are supported.
Here is an example:
Semantically "type { f1 = obj1; f2 = obj2 } maps directly to:
And "type(str)" maps directly to:
Open Issues: