# C0 語言的語法

``````BASE_LIST = BASE*
BASE = IF | FOR | WHILE | STMT ; | CLASS | METHOD | (PATH? (=> VAR_LIST)?)? BLOCK
IF = if (EXP) BASE (else BASE)?
FOR = for ( STMT ; EXP ; STMT) BASE
WHILE = while (EXP) BASE
STMT = (return|yield|throw) ITEM | PATH = (EXP | BLOCK)
CLASS = class Id is Id BLOCK
BLOCK = { (VAR_LIST) BASE_LIST }
EXP =  ( EXP Op2 EXP ) | ITEM (Op2 ITEM)?
ITEM = Int | Float | String | Id Op1? | PATH
PATH = Id(EXP_LIST?)? (. Id(EXP_LIST?)? )*
EXP_LIST = EXP (, EXP)*
VAR_LIST = VAR (, VAR)*
VAR = Id (= EXP)?

Id = [A-Za-z_][0-9A-Za-z_]*
Int = [0-9]+
Float = [0-9]+.[0-9]+
String = ".*"
Op2 = [+-/*%&|^><=|'<<'|'>>']
Op1 = (++ | --)```
```

# C0 語言的語意

f(b, o, o, …)

``````class C is P {
def method(o, o, ...) {
PATH(o, o, ...) {
}
.... {
}
}
}

block C => o c(b) { ... }     ; b.closure = C ; C.default = P
; if C has no Parent then C.default = global;
block F => o c.f(b, o, o, ...)  { ... }           ; b.closure = F ; F.default = C
block CALL => o call(b, o, o,...) { ... }         ; b.closure = CALL; CALL.default = F
block B = o call(b, o, ....) { ... }              ; b.closure = CALL; CALL.default = F```
```