LN5WH3QMSBXQERUVDDIH3Q6PB2W4V42FBSYTSFENTTG6TFRQYYBAC
3VI66VFUQO446PIYLJOHF4XDI6XSFJ7DDF3VMHGBUKZ2JO63LFCQC
OIHG72BUOXN34ADCCDYTCNB3QDCLDWB7EA2XXLIXY254VVITRWZAC
QKINOUCX22BZWA3VONV4J3KKR63EOVNJAGUUNXKGRHGHLPD7R77QC
IJGLKQESD33Y7UIM7U67M5MFJ4U2RZ5SS5PRBJJBKD2LCW7EJ35AC
DEBUG :: true
when DEBUG {
when ODIN_DEBUG {
execute :: proc(vm: ^VM) -> int {
execute :: proc(vm: ^VM) -> f64 {
// Leave out divide for now, because it could be float which is not implemented yet
push_back(vm.stack, vm_div(&x, &y))
return pop_back(vm.stack).value.(int)
return pop_back(vm.stack).value.(f64)
op1: int = x.value.(int) op2: int = y.value.(int)
op1: int = x.value.(int)
op2: int = y.value.(int)
op1 := x.value.(f64) op2 := y.value.(f64)
op1 := x.value.(f64)
op2 := y.value.(f64)
vm_divide :: #force_inline proc(x: ^syn.TOKEN, y: ^syn.TOKEN) -> syn.TOKEN { op1: int = x.value.(int) op2: int = y.value.(int)
vm_divide :: #force_inline proc(x: ^syn.TOKEN, y: ^syn.TOKEN) -> syn.TOKEN {
vm_div :: #force_inline proc(x: ^syn.TOKEN, y: ^syn.TOKEN) -> syn.TOKEN { op1 := x.value.(f64) op2 := y.value.(f64)
vm_div :: #force_inline proc(x: ^syn.TOKEN, y: ^syn.TOKEN) -> syn.TOKEN {
int,
f64,
shunting_yard :: proc(tokens: [dynamic]syn.TOKEN) -> [dynamic]syn.TOKEN {
shunting_yard :: proc(tokens: []syn.TOKEN) -> []syn.TOKEN {
return ast
return ast[:]
} if char_count < 1 { break
}
if char_count < 1 {
break
import "core:os"
lex :: proc(src: string) -> [dynamic]syn.TOKEN {
lex :: proc(src: string) -> []syn.TOKEN {
} num, ok := strconv.parse_f64(strings.concatenate(num_runes[:])) if !ok { fmt.println("Could not parse f64") os.exit(1)
num, ok := strconv.parse_f64(strings.concatenate(num_runes[:]))
if !ok {
fmt.println("Could not parse f64")
os.exit(1)
append( &ast, syn.TOKEN{syn.TOKEN_TYPE.NUMBER, strconv.atoi(strings.concatenate(num_runes[:]))}, )
append(
&ast,
syn.TOKEN{syn.TOKEN_TYPE.NUMBER, strconv.atoi(strings.concatenate(num_runes[:]))},
)
append(&ast, syn.TOKEN{syn.TOKEN_TYPE.NUMBER, num})