Open ezzatron opened 9 years ago
@jmalloc? Any interest in helping me with this?
I had a quick crack at it, but this doesn't include attributes, extension types, and probably some other stuff:
type = single / composite
single = keyword / symbol / traversable / tuple
keyword = "array" / "bool" / "boolean" / "callable" / "callback"
keyword =/ "double" / "float" / "int" / "integer" / "long" / "mixed"
keyword =/ "null" / "number" / "numeric" / "object" / "real"
keyword =/ "resource" / "scalar" / "stream" / "string"
keyword =/ "stringable"
symbol = ["\"] symbol-atom *("\" symbol-atom)
symbol-atom = (ALPHA / "_" / %x7F-FF) *(ALPHA / DIGIT / "_" / %x7F-FF)
traversable = traversable-primary LWSP "<" LWSP [type LWSP "," LWSP] type LWSP ">"
traversable-primary = "array" / "mixed" / symbol
tuple = "tuple" LWSP "<" LWSP type *(LWSP "," LWSP type) LWSP ">"
composite = single LWSP composite-separator LWSP single *(LWSP composite-separator LWSP single)
composite-separator = "|" / "+"
I'm not familiar with ABNF specifically, but sure (though it might be beneficial to use EBNF or something that's already accepted as input to various parser generators, the we can test the grammar itself against the ref implementation).
I think it would probably be useful to include an ABNF of the Typhax type syntax in the readme.