# 0x0 Implemented Grammar Sketch

This grammar documents the implemented source shape for the current compiler
slice. It is a public reference, not a promise for future syntax.

```ebnf
source        = { form } ;
form          = list | atom ;
list          = "(" , { form } , ")" ;
atom          = integer | string | symbol ;

integer       = [ "-" ] , digit , { digit } ;
string        = '"' , { string-char | escape } , '"' ;
escape        = "\\" , ( "n" | "t" | "r" | '"' | "\\" ) ;
symbol        = symbol-start , { symbol-char } ;

top-level     = module-form | import-form | function-form | doc-form ;
module-form   = "(" , "⊙" , symbol , ")" ;
import-form   = "(" , "↥" , string , [ symbol ] , ")" ;
export-form   = "(" , "↦" , { symbol } , ")" ;
doc-form      = "(" , "doc" , string , ")" ;

function-form = "(" , "ƒ" , symbol ,
                { annotation-form } ,
                parameter-list ,
                { form } ,
                ")" ;

annotation-form = type-annotation | doc-annotation | capability-annotation ;
type-annotation = "(" , "∷" , arrow-type , ")" ;
arrow-type      = "(" , "→" , { type-symbol } , type-symbol , ")" ;
doc-annotation  = "(" , "doc" , string , ")" ;
capability-annotation = "(" , "cap" , capability-symbol , ")" ;

parameter-list = "(" , { symbol } , ")" ;

binding-form   = "(" , "≔" , "(" , { binding } , ")" , { form } , ")" ;
binding        = "(" , symbol , form , ")" ;

if-form        = "(" , "if" , form , form , form , ")" ;
do-form        = "(" , "do" , { form } , ")" ;

capability-symbol = "pure" | "io" | "file" | "network" | "process" ;
type-symbol       = "I64" | "Text" | "Bool" | "Unit" | symbol ;
```

## Notes

- The parser accepts general lists and atoms, then semantic validation restricts
  top-level forms and known special forms.
- `↦` export forms are meaningful in imported modules.
- Imports may use local paths or `pkg:<dependency-name>` paths.
- This grammar does not document old `jmp0x1b/lang` embedded or ADT syntax as
  current 0x0 syntax.
