Skip to content

major grammar updates #92

@pdawyndt

Description

@pdawyndt

Design principles

A new version of the Scratch-LN grammar should follow these design principles:

  • the grammar can only make a distinction between certain block shapes
    • stack blocks (surrounded by optional square brackets; see later that we no longer need the square brackets for options) (no distinction made between blocks with two connectors, hat blocks, cap blocks and C-blocks; this is deferred to the visitor)
    • reporter blocks (surrounded by round brackets)
    • boolean blocks (surrounded by angle brackets)
  • the grammar uses a modifier to make a distinction between
    • atomic reporter blocks (default)
    • list reporter blocks (modifier required)
  • the grammar can only make a distinction between certain literal types
    • text (surrounded by single or double quotes and optional curly braces; selected options should be treated as text, which frees the use of square brackets for other use)
    • numbers (surrounded by curly braces)
    • colors (starts with a hash and optionally surrounded by curly braces)
  • the grammar makes a distinction between
    • block delimiters (separate connected blocks)
    • stack delimiters (separate distinct stacks: both top-level stacks and substacks)
  • the grammar makes a distinction between top-level stacks and substacks
    • a top-level stack can either be a standalone reporter block, a standalone boolean block or a sequence of connected stack blocks (this is what the grammar calls a stack)
    • a substack can only be a sequence of connected stack blocks
  • the grammar can only assume that
    • all blocks may have arguments (surrounded by curly braces; either make them mandatory or recognize parts-of-tags as specific literal types; the latter requires escaping more characters that are used to recognize literals, otherwise only the curly braces need escaping)
    • all stack blocks may have two connectors (reporter blocks and boolean blocks have no connectors; they are always standalone)
    • all stack blocks may have substacks that are only composed of stack blocks (this is supported using Python-style indentation)
  • grammar uses Python-style indentation to reflect the shape of C-blocks; this would remove the end keyword that is not visible on the Scratch blocks anyway and would allow the grammar to recognize substacks
  • visitor uses block specification from Scratch Extensions to
    • make a distinction between built-in blocks (stack blocks, reporter blocks and boolean blocks) and user-defined blocks; warnings should be issued when certain block shapes can only be built-in (no user-defined reporter blocks or boolean blocks for now in Scratch 3.0)
    • check restrictions on arguments of built-in blocks; in that respect the grammar should not recognize options but treat them as strings with the visitor checking if a selected is valid; a warning should be issued if arguments are invalid (wrong type for literals, wrong shape for blocks)
    • make a distinction between different shapes of stack blocks (cap blocks and hat blocks that only have one connector); a warning should be issued if a hat block is not on top of a stack or if a cap block does not close a stack (as a recovery, these blocks could start a new stack, but may be problematic for substacks)
    • check which built-in blocks can have substacks; having the C-style blocks supported by indentation and the checking being done in the visitor would actually make the grammar keyword-free; issue a warning if a stack block does not support substacks (only built-in blocks may have substacks); this would drop all C-blocks from the grammar and allow the visitor to recognize them dynamically based on the extensions that have been loaded and the language selected for Scratch-LN

Metadata

Metadata

Assignees

No one assigned

    Labels

    grammarThis issue requires changes to the grammar

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions