Skip to content

Commit

Permalink
feat: add 'contains' function to syntax and block definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
aspizu committed Jan 23, 2025
1 parent fef41df commit 66b2712
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion editors/code/syntaxes/goboscript.tmGrammar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ patterns:
- name: support.function.builtin
match: "\\b(move|turn_left|turn_right|goto_random_position|goto_mouse_pointer|goto|glide|glide_to_random_position|glide_to_mouse_pointer|point_in_direction|point_towards_mouse_pointer|point_towards_random_direction|point_towards|change_x|set_x|change_y|set_y|if_on_edge_bounce|set_rotation_style_left_right|set_rotation_style_do_not_rotate|set_rotation_style_all_around|say|think|switch_costume|next_costume|switch_backdrop|next_backdrop|set_size|change_size|change_color_effect|change_fisheye_effect|change_whirl_effect|change_pixelate_effect|change_mosaic_effect|change_brightness_effect|change_ghost_effect|set_color_effect|set_fisheye_effect|set_whirl_effect|set_pixelate_effect|set_mosaic_effect|set_brightness_effect|set_ghost_effect|clear_graphic_effects|show|hide|goto_front|goto_back|go_forward|go_backward|play_sound_until_done|start_sound|stop_all_sounds|change_pitch_effect|change_pan_effect|set_pitch_effect|set_pan_effect|change_volume|set_volume|clear_sound_effects|broadcast|broadcast_and_wait|wait|wait_until|stop_all|stop_this_script|stop_other_scripts|delete_this_clone|clone|ask|set_drag_mode_draggable|set_drag_mode_not_draggable|reset_timer|erase_all|stamp|pen_down|pen_up|set_pen_color|change_pen_size|set_pen_size|set_pen_hue|set_pen_saturation|set_pen_brightness|set_pen_transparency|change_pen_hue|change_pen_saturation|change_pen_brightness|change_pen_transparency|rest|set_tempo|change_tempo)\\b"
- name: entity.name.type
match: "\\b(distance_to_moues_pointer|distance_to|x_position|y_position|direction|size|costume_number|costume_name|backdrop_number|backdrop_name|volume|touching_mouse_pointer|touching_edge|touching|key_pressed|mouse_down|mouse_x|mouse_y|loudness|timer|current_year|current_month|current_date|current_day_of_week|current_hour|current_minute|current_second|days_since_2000|username|touching_color|color_is_touching_color|answer|random)\\b"
match: "\\b(x_position|y_position|direction|size|costume_number|costume_name|backdrop_number|backdrop_name|volume|distance_to_mouse_pointer|distance_to|touching_mouse_pointer|touching_edge|touching|key_pressed|mouse_down|mouse_x|mouse_y|loudness|timer|current_year|current_month|current_date|current_day_of_week|current_hour|current_minute|current_second|days_since_2000|username|touching_color|color_is_touching_color|answer|random|contains)\\b"
- name: punctuation
match: ",|;"
- name: keyword.operator
Expand Down
1 change: 1 addition & 0 deletions gdsl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,4 @@ color_is_touching_color coloristouchingcolor COLOR,COLOR2|
answer answer | |
[operator]=======================================================|====================|=
random random FROM,TO | |
contains contains STRING1,STRING2| |
7 changes: 7 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
set shell := ["powershell.exe", "-c"]


gdsl:
python gdsl.py
cargo +nightly fmt
cargo fix --allow-dirty
7 changes: 7 additions & 0 deletions src/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1076,6 +1076,7 @@ pub enum Repr {
ColorIsTouchingColor,
Answer,
Random,
Contains,
}

impl Repr {
Expand Down Expand Up @@ -1162,6 +1163,7 @@ impl Repr {
("color_is_touching_color", _) => Some(Self::ColorIsTouchingColor),
("answer", _) => Some(Self::Answer),
("random", _) => Some(Self::Random),
("contains", _) => Some(Self::Contains),
_ => None,
}
}
Expand Down Expand Up @@ -1201,6 +1203,7 @@ impl Repr {
Self::ColorIsTouchingColor => "color_is_touching_color",
Self::Answer => "answer",
Self::Random => "random",
Self::Contains => "contains",
}
}

Expand Down Expand Up @@ -1239,6 +1242,7 @@ impl Repr {
"color_is_touching_color",
"answer",
"random",
"contains",
]
}

Expand Down Expand Up @@ -1277,6 +1281,7 @@ impl Repr {
Self::ColorIsTouchingColor => "sensing_coloristouchingcolor",
Self::Answer => "sensing_answer",
Self::Random => "operator_random",
Self::Contains => "operator_contains",
}
}

Expand Down Expand Up @@ -1315,6 +1320,7 @@ impl Repr {
Self::ColorIsTouchingColor => &["COLOR", "COLOR2"],
Self::Answer => &[],
Self::Random => &["FROM", "TO"],
Self::Contains => &["STRING1", "STRING2"],
}
}

Expand Down Expand Up @@ -1353,6 +1359,7 @@ impl Repr {
Self::ColorIsTouchingColor => None,
Self::Answer => None,
Self::Random => None,
Self::Contains => None,
}
}
}
3 changes: 2 additions & 1 deletion src/visitor/transformations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,8 @@ pub fn coerce_condition(expr: &Expr) -> Option<Expr> {
| Repr::Touching
| Repr::TouchingColor
| Repr::TouchingEdge
| Repr::TouchingMousePointer,
| Repr::TouchingMousePointer
| Repr::Contains,
..
}
) {
Expand Down

0 comments on commit 66b2712

Please sign in to comment.