Grammar or Lexical Specification
Opened this issue · 2 comments
I had a look through the docs but didnt see anything specific about what constructions are permitted within what other constructions. Could this be documented?
ie: The Go specification writes everything like this:
FunctionType = "func" Signature .
Signature = Parameters [ Result ] .
Result = Parameters | Type .
Parameters = "(" [ ParameterList [ "," ] ] ")" .
ParameterList = ParameterDecl { "," ParameterDecl } .
ParameterDecl = [ IdentifierList ] [ "..." ] Type .
This is super helpful when trying to see what building blocks fit together.
In particular, I would like to understand whether type declarations / namespaces can be used within functions or even within expressions. It would also be an easy reference to see what features are available and what their syntax is (ie: ternary).
I feel a grammar like the above is a nice neat way to express whats allowed.
Yeah/Nah or Nah/Yeah?
I agree it would be nice to document that, I've added the docs label so we can track. If you're interested in having a look at this yourself, feel free to add a .md file (e.g. grammar.md) for this in the docs/ directory and send me a PR.
Note that things are still a little bit in flux, for example, the compiler does not support nested namespaces at the moment, but it will in the future.
Note: for consistency, for the grammar production rules names we should use the names as defined in: https://github.com/nickmqb/muon/blob/master/compiler/ast.mu