smalruby-editor 0.1.6-x86-mingw32 → 0.1.7-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of smalruby-editor might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/app/assets/javascripts/blocks/hardware.js.coffee.erb +40 -3
- data/app/assets/stylesheets/toolbox.css.scss.erb +1 -6
- data/app/controllers/source_codes_controller.rb +5 -1
- data/app/models/concerns/ruby_to_block/block/base.rb +251 -0
- data/app/models/concerns/ruby_to_block/block/character.rb +42 -0
- data/app/models/concerns/ruby_to_block/block/character_event.rb +27 -0
- data/app/models/concerns/ruby_to_block/block/character_method_call.rb +29 -0
- data/app/models/concerns/ruby_to_block/block/character_new.rb +7 -0
- data/app/models/concerns/ruby_to_block/block/character_operation.rb +80 -0
- data/app/models/concerns/ruby_to_block/block/control_if.rb +45 -0
- data/app/models/concerns/ruby_to_block/block/control_loop.rb +19 -0
- data/app/models/concerns/ruby_to_block/block/control_sleep.rb +18 -0
- data/app/models/concerns/ruby_to_block/block/do.rb +24 -0
- data/app/models/concerns/ruby_to_block/block/else.rb +12 -0
- data/app/models/concerns/ruby_to_block/block/end.rb +26 -0
- data/app/models/concerns/ruby_to_block/block/events_on_click.rb +14 -0
- data/app/models/concerns/ruby_to_block/block/events_on_key_push_or_down.rb +17 -0
- data/app/models/concerns/ruby_to_block/block/events_on_start.rb +14 -0
- data/app/models/concerns/ruby_to_block/block/hardware_init_hardware.rb +14 -0
- data/app/models/concerns/ruby_to_block/block/hardware_led_off.rb +16 -0
- data/app/models/concerns/ruby_to_block/block/hardware_led_on.rb +16 -0
- data/app/models/concerns/ruby_to_block/block/hardware_on_sensor_change.rb +17 -0
- data/app/models/concerns/ruby_to_block/block/hardware_rgb_led_off.rb +18 -0
- data/app/models/concerns/ruby_to_block/block/hardware_rgb_led_on.rb +23 -0
- data/app/models/concerns/ruby_to_block/block/hardware_sensor_value.rb +23 -0
- data/app/models/concerns/ruby_to_block/block/hardware_two_wheel_drive_car.rb +26 -0
- data/app/models/concerns/ruby_to_block/block/looks_hide.rb +8 -0
- data/app/models/concerns/ruby_to_block/block/looks_say.rb +20 -0
- data/app/models/concerns/ruby_to_block/block/looks_show.rb +8 -0
- data/app/models/concerns/ruby_to_block/block/looks_vanish.rb +8 -0
- data/app/models/concerns/ruby_to_block/block/math_number.rb +14 -0
- data/app/models/concerns/ruby_to_block/block/motion_change_x_by.rb +20 -0
- data/app/models/concerns/ruby_to_block/block/motion_change_y_by.rb +20 -0
- data/app/models/concerns/ruby_to_block/block/motion_move.rb +15 -0
- data/app/models/concerns/ruby_to_block/block/motion_point_towards_character.rb +24 -0
- data/app/models/concerns/ruby_to_block/block/motion_point_towards_mouse.rb +9 -0
- data/app/models/concerns/ruby_to_block/block/motion_reach_wall.rb +24 -0
- data/app/models/concerns/ruby_to_block/block/motion_rotate_left.rb +20 -0
- data/app/models/concerns/ruby_to_block/block/motion_rotate_right.rb +20 -0
- data/app/models/concerns/ruby_to_block/block/motion_self_angle.rb +23 -0
- data/app/models/concerns/ruby_to_block/block/motion_self_x.rb +23 -0
- data/app/models/concerns/ruby_to_block/block/motion_self_y.rb +23 -0
- data/app/models/concerns/ruby_to_block/block/motion_set_angle.rb +15 -0
- data/app/models/concerns/ruby_to_block/block/motion_set_x.rb +38 -0
- data/app/models/concerns/ruby_to_block/block/motion_set_y.rb +15 -0
- data/app/models/concerns/ruby_to_block/block/motion_turn.rb +8 -0
- data/app/models/concerns/ruby_to_block/block/motion_turn_if_reach_wall.rb +8 -0
- data/app/models/concerns/ruby_to_block/block/null.rb +17 -0
- data/app/models/concerns/ruby_to_block/block/operators_compare.rb +36 -0
- data/app/models/concerns/ruby_to_block/block/operators_false.rb +8 -0
- data/app/models/concerns/ruby_to_block/block/operators_true.rb +8 -0
- data/app/models/concerns/ruby_to_block/block/require_smalruby.rb +7 -0
- data/app/models/concerns/ruby_to_block/block/ruby_comment.rb +16 -0
- data/app/models/concerns/ruby_to_block/block/ruby_expression.rb +14 -0
- data/app/models/concerns/ruby_to_block/block/ruby_statement.rb +23 -0
- data/app/models/concerns/ruby_to_block/block/sensing_hit.rb +23 -0
- data/app/models/concerns/ruby_to_block/block/sound_play.rb +15 -0
- data/app/models/concerns/ruby_to_block/block/sound_preset_sounds.rb +31 -0
- data/app/models/concerns/ruby_to_block/block/text.rb +15 -0
- data/app/models/concerns/ruby_to_block/block/value.rb +12 -0
- data/app/models/concerns/ruby_to_block/block.rb +97 -0
- data/app/models/concerns/ruby_to_block/context.rb +97 -0
- data/app/models/concerns/ruby_to_block/formatter.rb +26 -0
- data/app/models/concerns/ruby_to_block.rb +17 -360
- data/app/models/source_code.rb +3 -1
- data/app/views/editor/_toolbox.html.haml +16 -0
- data/lib/smalruby_editor/version.rb +3 -3
- data/public/assets/{application-64a390efe879c386a5950515064f062d.css → application-28b7bed56c5389dfa372e972c75b6676.css} +17 -10
- data/public/assets/application-28b7bed56c5389dfa372e972c75b6676.css.gz +0 -0
- data/public/assets/{application-8bfffad1222d4e198f3c7ccc1cbd774f.js → application-4f747690ebc8ec4815ae36021fdb2c44.js} +135 -0
- data/public/assets/{application-8bfffad1222d4e198f3c7ccc1cbd774f.js.gz → application-4f747690ebc8ec4815ae36021fdb2c44.js.gz} +0 -0
- data/public/assets/manifest-332a5a1668194028b55103e0ea45c054.json +1 -1
- data/smalruby-editor.gemspec +1 -1
- data/spec/acceptance/block_mode/blocks/hardware/two_wheel_drive_car.feature +69 -0
- data/spec/acceptance/ruby_mode/translate.feature +1 -1
- data/spec/controllers/source_codes_controller_spec.rb +14 -11
- data/spec/models/concerns/ruby_to_block/block/character_method_call_spec.rb +175 -0
- data/spec/models/concerns/ruby_to_block/block/control_if_spec.rb +75 -0
- data/spec/models/concerns/ruby_to_block/block/control_loop_spec.rb +68 -0
- data/spec/models/concerns/ruby_to_block/block/events_on_start_spec.rb +120 -0
- data/spec/models/concerns/ruby_to_block/block/hardware_spec.rb +120 -0
- data/spec/models/concerns/ruby_to_block/block/looks_say_spec.rb +79 -0
- data/spec/models/concerns/ruby_to_block/block/looks_spec.rb +74 -0
- data/spec/models/concerns/ruby_to_block/block/motion_move_spec.rb +63 -0
- data/spec/models/concerns/ruby_to_block/block/motion_reach_wall_spec.rb +67 -0
- data/spec/models/concerns/ruby_to_block/block/motion_spec.rb +392 -0
- data/spec/models/concerns/ruby_to_block/block/motion_turn_spec.rb +54 -0
- data/spec/models/concerns/ruby_to_block/block/require_smalruby_spec.rb +39 -0
- data/spec/models/concerns/ruby_to_block/block/ruby_comment_spec.rb +55 -0
- data/spec/models/concerns/ruby_to_block/block/ruby_statement_spec.rb +113 -0
- data/spec/models/concerns/ruby_to_block/block/shared/block_examples.rb +44 -0
- data/spec/models/concerns/ruby_to_block/block/sound_spec.rb +46 -0
- data/spec/models/concerns/ruby_to_block/block_spec.rb +49 -0
- data/spec/models/concerns/ruby_to_block_spec.rb +421 -217
- data/spec/support/ruby_to_block.rb +10 -0
- metadata +108 -10
- data/public/assets/application-64a390efe879c386a5950515064f062d.css.gz +0 -0
@@ -0,0 +1,14 @@
|
|
1
|
+
module RubyToBlock
|
2
|
+
module Block
|
3
|
+
class EventsOnClick < CharacterEvent
|
4
|
+
blocknize '^\s*' + CHAR_RE + 'on\(:click\)\s+do\s*$',
|
5
|
+
statement: true, indent: true
|
6
|
+
|
7
|
+
def self.process_match_data(md, context)
|
8
|
+
md2 = regexp.match(md[type])
|
9
|
+
add_character_event_blocks(context, md2[1], new)
|
10
|
+
true
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module RubyToBlock
|
2
|
+
module Block
|
3
|
+
class EventsOnKeyPushOrDown < CharacterEvent
|
4
|
+
# rubocop:disable LineLength
|
5
|
+
blocknize '^\s*' + CHAR_RE + 'on\(:key_(down|push),\s*([^),]+)\)\s+do\s*$',
|
6
|
+
statement: true, indent: true
|
7
|
+
# rubocop:enable LineLength
|
8
|
+
|
9
|
+
def self.process_match_data(md, context)
|
10
|
+
md2 = regexp.match(md[type])
|
11
|
+
add_character_event_blocks(context, md2[1],
|
12
|
+
new(fields: { KEY: md2[3], POD: md2[2] }))
|
13
|
+
true
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module RubyToBlock
|
2
|
+
module Block
|
3
|
+
class EventsOnStart < CharacterEvent
|
4
|
+
blocknize '^\s*' + CHAR_RE + 'on\(:start\)\s+do\s*$',
|
5
|
+
statement: true, indent: true
|
6
|
+
|
7
|
+
def self.process_match_data(md, context)
|
8
|
+
md2 = regexp.match(md[type])
|
9
|
+
add_character_event_blocks(context, md2[1], new)
|
10
|
+
true
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
module RubyToBlock
|
3
|
+
module Block
|
4
|
+
class HardwareInitHardware < Base
|
5
|
+
blocknize '^\s*init_hardware\s*$', statement: true
|
6
|
+
|
7
|
+
def self.process_match_data(md, context)
|
8
|
+
context.blocks.push(new)
|
9
|
+
|
10
|
+
true
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
module RubyToBlock
|
3
|
+
module Block
|
4
|
+
class HardwareLedOff < CharacterMethodCall
|
5
|
+
blocknize '^\s*' + CHAR_RE + 'led\("(D(?:[2-9]|1[0-3]))"\).off\s*$',
|
6
|
+
statement: true
|
7
|
+
|
8
|
+
def self.process_match_data(md, context)
|
9
|
+
md2 = regexp.match(md[type])
|
10
|
+
add_character_method_call_block(context, md2[1],
|
11
|
+
new(fields: { PIN: md2[2] }))
|
12
|
+
true
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
module RubyToBlock
|
3
|
+
module Block
|
4
|
+
class HardwareLedOn < CharacterMethodCall
|
5
|
+
blocknize '^\s*' + CHAR_RE + 'led\("(D(?:[2-9]|1[0-3]))"\).on\s*$',
|
6
|
+
statement: true
|
7
|
+
|
8
|
+
def self.process_match_data(md, context)
|
9
|
+
md2 = regexp.match(md[type])
|
10
|
+
add_character_method_call_block(context, md2[1],
|
11
|
+
new(fields: { PIN: md2[2] }))
|
12
|
+
true
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module RubyToBlock
|
2
|
+
module Block
|
3
|
+
class HardwareOnSensorChange < CharacterEvent
|
4
|
+
# rubocop:disable LineLength
|
5
|
+
blocknize '^\s*' + CHAR_RE + 'on\(:sensor_change,\s*"(A[0-5])"\s*\)\s+do\s*$',
|
6
|
+
statement: true, indent: true
|
7
|
+
# rubocop:enable LineLength
|
8
|
+
|
9
|
+
def self.process_match_data(md, context)
|
10
|
+
md2 = regexp.match(md[type])
|
11
|
+
add_character_event_blocks(context, md2[1],
|
12
|
+
new(fields: { PIN: md2[2] }))
|
13
|
+
true
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
module RubyToBlock
|
3
|
+
module Block
|
4
|
+
class HardwareRgbLedOff < CharacterMethodCall
|
5
|
+
# rubocop:disable LineLength
|
6
|
+
blocknize '^\s*' + CHAR_RE + 'rgb_led_(anode|cathode)\("(D[39])"\)\.off\s*$',
|
7
|
+
statement: true
|
8
|
+
# rubocop:enable LineLength
|
9
|
+
|
10
|
+
def self.process_match_data(md, context)
|
11
|
+
md2 = regexp.match(md[type])
|
12
|
+
block = new(fields: { AC: md2[2], PIN: md2[3] })
|
13
|
+
add_character_method_call_block(context, md2[1], block)
|
14
|
+
true
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
module RubyToBlock
|
3
|
+
module Block
|
4
|
+
class HardwareRgbLedOn < CharacterMethodCall
|
5
|
+
# rubocop:disable LineLength
|
6
|
+
blocknize '^\s*' + CHAR_RE + 'rgb_led_(anode|cathode)\("(D[39])"\).on\(color:\s*\[(\d+),\s*(\d+),\s*(\d+)\]\)\s*$',
|
7
|
+
statement: true
|
8
|
+
# rubocop:enable LineLength
|
9
|
+
|
10
|
+
def self.process_match_data(md, context)
|
11
|
+
md2 = regexp.match(md[type])
|
12
|
+
|
13
|
+
color = [md2[4], md2[5], md2[6]].map(&:to_i)
|
14
|
+
return false if color.any? { |c| c < 0 || c > 255 }
|
15
|
+
color_code = '#' + color.map { |c| sprintf('%02x', c) }.join
|
16
|
+
block = new(fields: { AC: md2[2], PIN: md2[3], COLOUR: color_code })
|
17
|
+
|
18
|
+
add_character_method_call_block(context, md2[1], block)
|
19
|
+
true
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module RubyToBlock
|
2
|
+
module Block
|
3
|
+
class HardwareSensorValue < Value
|
4
|
+
include CharacterOperation
|
5
|
+
|
6
|
+
blocknize '^\s*' + CHAR_RE + 'sensor\(\s*"(A[0-5])"\s*\)\.value\s*$',
|
7
|
+
value: true
|
8
|
+
|
9
|
+
def self.process_match_data(md, context)
|
10
|
+
md2 = regexp.match(md[type])
|
11
|
+
|
12
|
+
character = get_character(context, md2[1])
|
13
|
+
return false if context.receiver != character
|
14
|
+
|
15
|
+
block = new(fields: { PIN: md2[2] })
|
16
|
+
context.add_value(block)
|
17
|
+
block.character = character
|
18
|
+
|
19
|
+
true
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
module RubyToBlock
|
3
|
+
module Block
|
4
|
+
class HardwareTwoWheelDriveCar < CharacterMethodCall
|
5
|
+
# rubocop:disable LineLength
|
6
|
+
blocknize '^\s*' + CHAR_RE + 'two_wheel_drive_car\("(D(?:[2-9]|10))"\).(forward|backward|turn_left|turn_right|stop)\s*$',
|
7
|
+
statement: true
|
8
|
+
# rubocop:enable LineLength
|
9
|
+
|
10
|
+
attr_accessor :method_name
|
11
|
+
|
12
|
+
def self.process_match_data(md, context)
|
13
|
+
md2 = regexp.match(md[type])
|
14
|
+
block =
|
15
|
+
add_character_method_call_block(context, md2[1],
|
16
|
+
new(fields: { PIN: md2[2] }))
|
17
|
+
block.method_name = md2[3]
|
18
|
+
true
|
19
|
+
end
|
20
|
+
|
21
|
+
def type
|
22
|
+
"hardware_two_wheel_drive_car_#{method_name}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
module RubyToBlock
|
3
|
+
module Block
|
4
|
+
class LooksSay < CharacterMethodCall
|
5
|
+
blocknize '^\s*' + CHAR_RE + 'say\(message:\s*("[^"]*")\)\s*$',
|
6
|
+
statement: true, inline: true
|
7
|
+
|
8
|
+
def self.process_match_data(md, context)
|
9
|
+
md2 = regexp.match(md[type])
|
10
|
+
|
11
|
+
block = new
|
12
|
+
_, context.current_block =
|
13
|
+
*add_child_or_create_character_new_block(context, md2[1], block)
|
14
|
+
process_value_string(context, block, md2[2], :TEXT)
|
15
|
+
|
16
|
+
true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
module RubyToBlock
|
3
|
+
module Block
|
4
|
+
class MathNumber < Value
|
5
|
+
blocknize '^\s*([+-]?\d+(?:\.\d+)?)\s*$', value: true
|
6
|
+
|
7
|
+
def self.process_match_data(md, context)
|
8
|
+
context.add_value(new(fields: { NUM: md[type].sub(/^\+/, '') }))
|
9
|
+
|
10
|
+
true
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
module RubyToBlock
|
3
|
+
module Block
|
4
|
+
class MotionChangeXBy < CharacterMethodCall
|
5
|
+
blocknize '^\s*' + CHAR_RE + 'x\s*\+=\s*(\S+)\s*$',
|
6
|
+
statement: true, inline: true
|
7
|
+
|
8
|
+
def self.process_match_data(md, context)
|
9
|
+
md2 = regexp.match(md[type])
|
10
|
+
|
11
|
+
block = new
|
12
|
+
_, context.current_block =
|
13
|
+
*add_child_or_create_character_new_block(context, md2[1], block)
|
14
|
+
process_value_string(context, block, md2[2], 'X')
|
15
|
+
|
16
|
+
true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
module RubyToBlock
|
3
|
+
module Block
|
4
|
+
class MotionChangeYBy < CharacterMethodCall
|
5
|
+
blocknize '^\s*' + CHAR_RE + 'y\s*\+=\s*(\S+)\s*$',
|
6
|
+
statement: true, inline: true
|
7
|
+
|
8
|
+
def self.process_match_data(md, context)
|
9
|
+
md2 = regexp.match(md[type])
|
10
|
+
|
11
|
+
block = new
|
12
|
+
_, context.current_block =
|
13
|
+
*add_child_or_create_character_new_block(context, md2[1], block)
|
14
|
+
process_value_string(context, block, md2[2], 'Y')
|
15
|
+
|
16
|
+
true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
module RubyToBlock
|
3
|
+
module Block
|
4
|
+
class MotionMove < CharacterMethodCall
|
5
|
+
blocknize '^\s*' + CHAR_RE + 'move\((.+)\)\s*$',
|
6
|
+
statement: true, inline: true
|
7
|
+
|
8
|
+
def self.process_match_data(md, context)
|
9
|
+
md2 = regexp.match(md[type])
|
10
|
+
add_character_method_call_block(context, md2[1], new, STEP: md2[2])
|
11
|
+
true
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
module RubyToBlock
|
3
|
+
module Block
|
4
|
+
class MotionPointTowardsCharacter < CharacterMethodCall
|
5
|
+
blocknize '^\s*' + CHAR_RE + 'point_towards\(([^:)]+)\)\s*$',
|
6
|
+
statement: true
|
7
|
+
|
8
|
+
def self.process_match_data(md, context)
|
9
|
+
md2 = regexp.match(md[type])
|
10
|
+
|
11
|
+
name = md2[2]
|
12
|
+
name.strip!
|
13
|
+
c = context.characters[name]
|
14
|
+
return false unless c
|
15
|
+
|
16
|
+
block = new(fields: { CHAR: name })
|
17
|
+
_, context.current_block =
|
18
|
+
*add_child_or_create_character_new_block(context, md2[1], block)
|
19
|
+
|
20
|
+
true
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
module RubyToBlock
|
3
|
+
module Block
|
4
|
+
class MotionReachWall < Value
|
5
|
+
include CharacterOperation
|
6
|
+
|
7
|
+
blocknize '^\s*' + CHAR_RE + 'reach_wall\?\s*$',
|
8
|
+
value: true
|
9
|
+
|
10
|
+
def self.process_match_data(md, context)
|
11
|
+
md2 = regexp.match(md[type])
|
12
|
+
|
13
|
+
character = get_character(context, md2[1])
|
14
|
+
return false if context.receiver != character
|
15
|
+
|
16
|
+
block = new
|
17
|
+
context.add_value(block)
|
18
|
+
block.character = character
|
19
|
+
|
20
|
+
true
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
module RubyToBlock
|
3
|
+
module Block
|
4
|
+
class MotionRotateLeft < CharacterMethodCall
|
5
|
+
blocknize '^\s*' + CHAR_RE + 'rotate\(\-(\d+)\)\s*$',
|
6
|
+
statement: true, inline: true
|
7
|
+
|
8
|
+
def self.process_match_data(md, context)
|
9
|
+
md2 = regexp.match(md[type])
|
10
|
+
|
11
|
+
block = new
|
12
|
+
_, context.current_block =
|
13
|
+
*add_child_or_create_character_new_block(context, md2[1], block)
|
14
|
+
process_value_string(context, block, md2[2], :ANGLE)
|
15
|
+
|
16
|
+
true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
module RubyToBlock
|
3
|
+
module Block
|
4
|
+
class MotionRotateRight < CharacterMethodCall
|
5
|
+
blocknize '^\s*' + CHAR_RE + 'rotate\(\+?(\d+)\)\s*$',
|
6
|
+
statement: true, inline: true
|
7
|
+
|
8
|
+
def self.process_match_data(md, context)
|
9
|
+
md2 = regexp.match(md[type])
|
10
|
+
|
11
|
+
block = new
|
12
|
+
_, context.current_block =
|
13
|
+
*add_child_or_create_character_new_block(context, md2[1], block)
|
14
|
+
process_value_string(context, block, md2[2], :ANGLE)
|
15
|
+
|
16
|
+
true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module RubyToBlock
|
2
|
+
module Block
|
3
|
+
class MotionSelfAngle < Value
|
4
|
+
include CharacterOperation
|
5
|
+
|
6
|
+
blocknize '^\s*' + CHAR_RE + 'angle\s*$',
|
7
|
+
value: true
|
8
|
+
|
9
|
+
def self.process_match_data(md, context)
|
10
|
+
md2 = regexp.match(md[type])
|
11
|
+
|
12
|
+
character = get_character(context, md2[1])
|
13
|
+
return false if context.receiver != character
|
14
|
+
|
15
|
+
block = new
|
16
|
+
context.add_value(block)
|
17
|
+
block.character = character
|
18
|
+
|
19
|
+
true
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module RubyToBlock
|
2
|
+
module Block
|
3
|
+
class MotionSelfX < Value
|
4
|
+
include CharacterOperation
|
5
|
+
|
6
|
+
blocknize '^\s*' + CHAR_RE + 'x\s*$',
|
7
|
+
value: true
|
8
|
+
|
9
|
+
def self.process_match_data(md, context)
|
10
|
+
md2 = regexp.match(md[type])
|
11
|
+
|
12
|
+
character = get_character(context, md2[1])
|
13
|
+
return false if context.receiver != character
|
14
|
+
|
15
|
+
block = new
|
16
|
+
context.add_value(block)
|
17
|
+
block.character = character
|
18
|
+
|
19
|
+
true
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module RubyToBlock
|
2
|
+
module Block
|
3
|
+
class MotionSelfY < Value
|
4
|
+
include CharacterOperation
|
5
|
+
|
6
|
+
blocknize '^\s*' + CHAR_RE + 'y\s*$',
|
7
|
+
value: true
|
8
|
+
|
9
|
+
def self.process_match_data(md, context)
|
10
|
+
md2 = regexp.match(md[type])
|
11
|
+
|
12
|
+
character = get_character(context, md2[1])
|
13
|
+
return false if context.receiver != character
|
14
|
+
|
15
|
+
block = new
|
16
|
+
context.add_value(block)
|
17
|
+
block.character = character
|
18
|
+
|
19
|
+
true
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
module RubyToBlock
|
3
|
+
module Block
|
4
|
+
class MotionSetAngle < CharacterMethodCall
|
5
|
+
blocknize '^\s*' + CHAR_RE + 'angle\s*=\s*(\S+)\s*$',
|
6
|
+
statement: true, inline: true
|
7
|
+
|
8
|
+
def self.process_match_data(md, context)
|
9
|
+
md2 = regexp.match(md[type])
|
10
|
+
add_character_method_call_block(context, md2[1], new, ANGLE: md2[2])
|
11
|
+
true
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
module RubyToBlock
|
3
|
+
module Block
|
4
|
+
class MotionSetX < CharacterMethodCall
|
5
|
+
blocknize '^\s*' + CHAR_RE + 'x\s*=\s*(\S+)\s*$',
|
6
|
+
statement: true, inline: true
|
7
|
+
|
8
|
+
def self.process_match_data(md, context)
|
9
|
+
md2 = regexp.match(md[type])
|
10
|
+
block = add_character_method_call_block(context, md2[1], new,
|
11
|
+
X: md2[2])
|
12
|
+
|
13
|
+
md3 = MotionSetY.regexp.match(context.look_next_line)
|
14
|
+
process_motion_set_y(context, block, md3) if md3
|
15
|
+
|
16
|
+
true
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.process_motion_set_y(context, block, md)
|
20
|
+
if block.character == get_character(context, md[1])
|
21
|
+
process_value_string(context, block, md[2], :Y)
|
22
|
+
context.next_line
|
23
|
+
end
|
24
|
+
rescue
|
25
|
+
return
|
26
|
+
end
|
27
|
+
private_class_method :process_motion_set_y
|
28
|
+
|
29
|
+
def type
|
30
|
+
if @values.key?(:Y)
|
31
|
+
'motion_set_x_y'
|
32
|
+
else
|
33
|
+
super
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
module RubyToBlock
|
3
|
+
module Block
|
4
|
+
class MotionSetY < CharacterMethodCall
|
5
|
+
blocknize '^\s*' + CHAR_RE + 'y\s*=\s*(\S+)\s*$',
|
6
|
+
statement: true, inline: true
|
7
|
+
|
8
|
+
def self.process_match_data(md, context)
|
9
|
+
md2 = regexp.match(md[type])
|
10
|
+
add_character_method_call_block(context, md2[1], new, Y: md2[2])
|
11
|
+
true
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
module RubyToBlock
|
3
|
+
module Block
|
4
|
+
class OperatorsCompare < Value
|
5
|
+
blocknize '^\s*(\S+?)\s*(<|<=|==|>=|>)\s*(\S+?)\s*$',
|
6
|
+
value: true, inline: true
|
7
|
+
|
8
|
+
OPERATOR_TO_TYPE = {
|
9
|
+
'<' => "#{type}_lt",
|
10
|
+
'<=' => "#{type}_lte",
|
11
|
+
'==' => "#{type}_eq",
|
12
|
+
'>=' => "#{type}_gte",
|
13
|
+
'>' => "#{type}_gt",
|
14
|
+
}
|
15
|
+
|
16
|
+
attr_accessor :compare_type
|
17
|
+
|
18
|
+
def self.process_match_data(md, context)
|
19
|
+
md2 = regexp.match(md[type])
|
20
|
+
|
21
|
+
block = new
|
22
|
+
context.add_value(block)
|
23
|
+
|
24
|
+
process_value_string(context, block, md2[1], :A)
|
25
|
+
block.compare_type = md2[2]
|
26
|
+
process_value_string(context, block, md2[3], :B)
|
27
|
+
|
28
|
+
true
|
29
|
+
end
|
30
|
+
|
31
|
+
def type
|
32
|
+
OPERATOR_TO_TYPE[@compare_type]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|