-
Notifications
You must be signed in to change notification settings - Fork 2
/
vmcc_i.cfg
77 lines (61 loc) · 3.48 KB
/
vmcc_i.cfg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
set _ver_vmcc 1
// example use:
// cc x = 3 + y
// cc x = y = z = 5
set _cc_func nop
alias __cc_dofunc "$_cc_func ${* asis}"
alias cc "mov eax 0; _cc_assign ${* asis} _ _"
///////////////////////////////////////////////////////////////////////
// Actual interpreter code
alias _cc_assign "mov _cc_func \"$2\"; toggle _cc_func _cc_addop = _cc_assign1; __cc_dofunc ${* asis}"
alias _cc_assign1 "_cc_assign ${3- asis}; _cc_assign2 $1"
alias _cc_assign2 "menu_cmd rpn /$1 $eax def"
alias _cc_return "set _cc_func \"${* asis}\""
alias _cc_opend "menu_cmd rpn /eax eax $2 $1 def"
alias _cc_ifterm "set _cc_func $1; toggle _cc_func $3 ( $2; __cc_dofunc ${4- asis}"
// '(' term ')' <code> so we have to pop off the ')' and only return <code>
alias _cc_term "_cc_assign ${2- asis}; _cc_term1"
alias _cc_term1 "_cc_term2 ${_cc_func asis}"
alias _cc_term2 "set _cc_func \"${2- asis}\""
// addsub:
// can be: + 3 * -> checks *
// + 3 _ -> checks _
// + ( 3 -> checks 3
// can be: (a _ _) or (a +/- <code>)
alias _cc_addop "_cc_ifterm $1 _cc_addopA _cc_addopB ${* asis}"
alias _cc_addopA "_cc_term ${* asis}; _cc_addopA1"
alias _cc_addopA1 "_cc_addop1 ${_cc_func asis}"
alias _cc_addopB "menu_cmd rpn /eax $1 def; _cc_addop1 ${2- asis}"
// eax stores the first value, now we can have (_ _) or (<code>)
alias _cc_addop1 "mov _cc_func \"$1\"; toggle _cc_func _cc_mulop1 + _cc_addsub - _cc_addsub; __cc_dofunc ${* asis}"
alias _cc_addopr "mov _cc_func \"$1\"; toggle _cc_func _cc_error _ _cc_opend + _cc_addsub - _cc_addsub; __cc_dofunc ${* asis}"
// check next operator precedence
alias _cc_addsub "mov _cc_func \"$3\"; toggle _cc_func _cc_addsubend _ _cc_opend + _cc_addsub1 - _cc_addsub1; __cc_dofunc ${* asis}"
// next operator is on same precedence level, operator is in S1
alias _cc_addsub1 "menu_cmd rpn /eax eax $2 $1 def; _cc_addop1 ${3- asis}"
alias _cc_addsubend "push $eax; _cc_ifterm $2 _cc_term _cc_mulop ${2- asis}; _cc_addsubend1 $1"
alias _cc_addsubend1 "pop ebx; menu_cmd rpn /eax ebx eax $1 def; _cc_addsubend2"
alias _cc_addsubend2 "_cc_addop1 ${_cc_func asis}"
// can be: (a _ _) or (a +/- <code>)
alias _cc_mulop "_cc_ifterm $1 _cc_mulopA _cc_mulopB ${* asis}"
alias _cc_mulopA "_cc_term ${* asis}; _cc_mulopA1"
alias _cc_mulopA1 "_cc_mulop1 ${_cc_func asis}"
alias _cc_mulopB "menu_cmd rpn /eax $1 def; _cc_mulop1 ${2- asis}"
// eax stores the first value, now we can have (_ _) or (<code>)
alias _cc_mulop1 "mov _cc_func \"$1\"; toggle _cc_func _cc_NEXTop1 * _cc_muldiv / _cc_muldiv; __cc_dofunc ${* asis}"
alias _cc_mulopr "mov _cc_func \"$1\"; toggle _cc_func _cc_addop1 * _cc_muldiv / _cc_muldiv; __cc_dofunc ${* asis}"
// check next operator precedence
alias _cc_muldiv "mov _cc_func \"$3\"; toggle _cc_func _cc_muldivend _ _cc_opend * _cc_muldiv1 / _cc_muldiv1; __cc_dofunc ${* asis}"
// next operator is on same precedence level, operator is in S1
alias _cc_muldiv1 "menu_cmd rpn /eax eax $2 $1 def; _cc_mulop1 ${3- asis}"
alias _cc_muldivend "push $eax; _cc_ifterm $2 _cc_term _cc_NEXTop ${2- asis}; _cc_muldivend1 $1"
alias _cc_muldivend1 "pop ebx; menu_cmd rpn /eax ebx eax $1 def; _cc_muldivend2"
alias _cc_muldivend2 "_cc_addop1 ${_cc_func asis}"
alias _cc_NEXTop "menu_cmd rpn /eax $1 def; _cc_NEXTop1 ${2- asis}"
alias _cc_NEXTop1 "set _cc_func \"${* asis}\""
//echo "^2Entering compilation mode."
// exec blubvm/vmcc_c.cfg
alias vmcc_comp "exec blubvm/vmcc_c.cfg"
alias vmcc_int "exec blubvm/vmcc_i.cfg"
cmp ebx 1010
jnz "echo \"^2You can switch to compilation mode using ^3vmcc_comp\""