# Structured Dagger: Grammar

## Tokens:

`<ident> = Valid C++ identifier`
`<int-expr> = Valid C++ integer expression`
`<c++-code> = Valid C++ code`

## Grammar in EBNF Form:

`<sdag> := <class-decl> <sdagentry>+`

`<class-decl> := "class" <ident>`

`<sdagentry> := "sdagentry" <ident> "(" <ident> "*" <ident> ")" <body>`

`<body> := <stmt>`
`| "{" <stmt>+ "}"`

`<stmt> := <overlap-stmt>`
`| <when-stmt>`
`| <atomic-stmt>`
`| <if-stmt>`
`| <while-stmt>`
`| <for-stmt>`
`| <forall-stmt>`

`<overlap-stmt> := "overlap" <body>`

`<atomic-stmt> := "atomic" "{" <c++-code> "}"`

`<if-stmt> := "if" "(" <int-expr> ")" <body> [<else-stmt>]`

`<else-stmt> := "else" <body>`

`<while-stmt> := "while" "(" <int-expr> ")" <body>`

`<for-stmt> := "for" "(" <c++-code> ";" <int-expr> ";" <c++-code> ")" <body>`

`<forall-stmt> := "forall" "[" <ident> "]" "(" <range-stride> ")" <body>`

`<range-stride> := <int-expr> ":" <int-expr> "," <int-expr>`

`<when-stmt> := "when" <entry-list> <body>`

`<entry-list> := <entry>`
`| <entry> [ "," <entry-list> ]`

`<entry> := <ident> [ "[" <int-expr> "]" ] "(" <ident> "*" <ident> ")"`