Files
cval/README.md
2025-11-15 08:01:34 +09:00

49 lines
935 B
Markdown

# C-val Compiler
## Lexical Spec
* LBRACK `[`
* RBRACK `]`
* LCURLY `{`
* RCURLY `}`
* LPAREN `(`
* RPAREN `)`
* ID `[any character without whitespace]+`
* SEMI `;`
* COMMA `,`
* ARROW `->`
* STAR `*`
* ANDREF `&`
* DOLLAR `$`
* COMMENT `//`
* NUM `[0-9]*`
* VAL
* STRING `"{any}"`
## Syntax Spec
```
program := defn*
defn := VAL type ID ;
| VAL type ID expr ;
type := ID | [] | [type] | [ type* ARROW type? ]
expr := atom atom*
atom := ID
| NUM
| STR
| lambda
| compound
| reference
| dereference
stmt := defn
| expr ; // expr statement
| return expr ; // return statement
| $ ID expr ; // assignment statement
| if expr compound ; // if statement
| if expr compound else compound ; // if-else statement
```