Module: ImgToScript::Languages::MK90Basic::Translators::Mixin
- Included in:
- Translator
- Defined in:
- lib/img_to_script/languages/mk90_basic/translators/mixin.rb
Overview
Shared by both MK90 BAIC v.1.0 & v.2.0.
Instance Method Summary collapse
- #_abs_func(token) ⇒ Object
- #_clear_screen(token) ⇒ Object
- #_data_read(token) ⇒ Object
- #_data_store(token) ⇒ Object
- #_draw_chunk_by_hex_value(token) ⇒ Object
- #_draw_line_by_abs_coords(token) ⇒ Object
- #_draw_pixel_by_abs_coords(token) ⇒ Object
- #_go_to(token) ⇒ Object
- #_if_condition(token) ⇒ Object
- #_loop_begin(token) ⇒ Object
- #_loop_end(token) ⇒ Object
- #_math_add(token) ⇒ Object
- #_math_greater_than(token) ⇒ Object
- #_math_mult(token) ⇒ Object
- #_math_sub(token) ⇒ Object
- #_parentheses(token) ⇒ Object
- #_program_end(token) ⇒ Object
- #_read_key_value(token) ⇒ Object
- #_remark(token) ⇒ Object
- #_sign_func(token) ⇒ Object
- #_wait(token) ⇒ Object
Instance Method Details
#_abs_func(token) ⇒ Object
13 14 15 |
# File 'lib/img_to_script/languages/mk90_basic/translators/mixin.rb', line 13 def _abs_func(token) _function(token, "ABS") end |
#_clear_screen(token) ⇒ Object
17 18 19 |
# File 'lib/img_to_script/languages/mk90_basic/translators/mixin.rb', line 17 def _clear_screen(token) _single_keyword(token, "CLS") end |
#_data_read(token) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/img_to_script/languages/mk90_basic/translators/mixin.rb', line 39 def _data_read(token) MK90BasicToken.new( keyword: "READ", args: _translate_arguments(token.var_list), separator: ",", require_nl: token.require_nl, sliceable: false ) end |
#_data_store(token) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/img_to_script/languages/mk90_basic/translators/mixin.rb', line 29 def _data_store(token) MK90BasicToken.new( keyword: "DATA", args: token.data, separator: ",", require_nl: token.require_nl, sliceable: true ) end |
#_draw_chunk_by_hex_value(token) ⇒ Object
77 78 79 80 81 82 83 84 85 |
# File 'lib/img_to_script/languages/mk90_basic/translators/mixin.rb', line 77 def _draw_chunk_by_hex_value(token) MK90BasicToken.new( keyword: "DRAWM", args: token.hex_values, separator: "", require_nl: token.require_nl, sliceable: true ) end |
#_draw_line_by_abs_coords(token) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/img_to_script/languages/mk90_basic/translators/mixin.rb', line 49 def _draw_line_by_abs_coords(token) MK90BasicToken.new( keyword: "DRAWD", args: _translate_arguments([ token.x0, token.y0, token.x1, token.y1 ]), separator: ",", require_nl: token.require_nl, sliceable: false ) end |
#_draw_pixel_by_abs_coords(token) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/img_to_script/languages/mk90_basic/translators/mixin.rb', line 64 def _draw_pixel_by_abs_coords(token) MK90BasicToken.new( keyword: "DRAWH", args: _translate_arguments([ token.x, token.y ]), separator: ",", require_nl: token.require_nl, sliceable: false ) end |
#_go_to(token) ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/img_to_script/languages/mk90_basic/translators/mixin.rb', line 103 def _go_to(token) MK90BasicToken.new( keyword: "GOTO", args: _translate_arguments([ token.line ]), separator: "", require_nl: token.require_nl, sliceable: false ) end |
#_if_condition(token) ⇒ Object
153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/img_to_script/languages/mk90_basic/translators/mixin.rb', line 153 def _if_condition(token) MK90BasicToken.new( keyword: "IF", args: _translate_arguments([ token.expression, "THEN", token.consequent ]), separator: "", require_nl: token.require_nl, sliceable: false ) end |
#_loop_begin(token) ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/img_to_script/languages/mk90_basic/translators/mixin.rb', line 115 def _loop_begin(token) MK90BasicToken.new( keyword: "FOR", args: _translate_arguments([ token.var_name, "=", token.start_value, "TO", token.end_value ]), separator: "", require_nl: token.require_nl, sliceable: false ) end |
#_loop_end(token) ⇒ Object
139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/img_to_script/languages/mk90_basic/translators/mixin.rb', line 139 def _loop_end(token) MK90BasicToken.new( keyword: "NEXT", args: _translate_arguments( [ token.var_name ] ), separator: "", require_nl: token.require_nl, sliceable: false ) end |
#_math_add(token) ⇒ Object
87 88 89 |
# File 'lib/img_to_script/languages/mk90_basic/translators/mixin.rb', line 87 def _math_add(token) _math_operation(token, "+") end |
#_math_greater_than(token) ⇒ Object
91 92 93 |
# File 'lib/img_to_script/languages/mk90_basic/translators/mixin.rb', line 91 def _math_greater_than(token) _math_operation(token, ">") end |
#_math_mult(token) ⇒ Object
99 100 101 |
# File 'lib/img_to_script/languages/mk90_basic/translators/mixin.rb', line 99 def _math_mult(token) _math_operation(token, "*") end |
#_math_sub(token) ⇒ Object
95 96 97 |
# File 'lib/img_to_script/languages/mk90_basic/translators/mixin.rb', line 95 def _math_sub(token) _math_operation(token, "-") end |
#_parentheses(token) ⇒ Object
135 136 137 |
# File 'lib/img_to_script/languages/mk90_basic/translators/mixin.rb', line 135 def _parentheses(token) _function(token, "") end |
#_program_end(token) ⇒ Object
21 22 23 |
# File 'lib/img_to_script/languages/mk90_basic/translators/mixin.rb', line 21 def _program_end(token) _single_keyword(token, "END") end |
#_read_key_value(token) ⇒ Object
25 26 27 |
# File 'lib/img_to_script/languages/mk90_basic/translators/mixin.rb', line 25 def _read_key_value(token) _single_keyword(token, "INC") end |
#_remark(token) ⇒ Object
179 180 181 182 183 184 185 186 187 188 189 |
# File 'lib/img_to_script/languages/mk90_basic/translators/mixin.rb', line 179 def _remark(token) MK90BasicToken.new( keyword: "REM", args: [ token.text ], separator: "", require_nl: token.require_nl, sliceable: false ) end |
#_sign_func(token) ⇒ Object
131 132 133 |
# File 'lib/img_to_script/languages/mk90_basic/translators/mixin.rb', line 131 def _sign_func(token) _function(token, "SGN") end |
#_wait(token) ⇒ Object
167 168 169 170 171 172 173 174 175 176 177 |
# File 'lib/img_to_script/languages/mk90_basic/translators/mixin.rb', line 167 def _wait(token) MK90BasicToken.new( keyword: "WAIT", args: _translate_arguments([ token.time ]), separator: "", require_nl: token.require_nl, sliceable: false ) end |