Files
cval/README.md

950 B

C-val Compiler

Lexical Spec

  • LBRACK [
  • RBRACK ]
  • LCURLY {
  • RCURLY }
  • LPAREN (
  • RPAREN )
  • ID [any]
  • SEMI ;
  • COMMA ,
  • ARROW ->
  • STAR *
  • ANDREF &
  • DOLLAR $
  • COMMENT #
  • NUM [0-9]*(.[0-9]+)?
  • RETURN return
  • IF if
  • ELSE else
  • 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