Skip to content
Clement Julia edited this page Jul 30, 2021 · 8 revisions

Welcome to the AutomatedPuzzleScript wiki!

Parsing

WHY BETTER: In the JS implementation, everything is done in a single pass: parsing, checking and compiling. This creates a gigantic code base that is unable to do anything efficiently since it only has access to the current line and everything before, whereas the rascal implementation first implodes everything into data types that can be manipulated before checking. Section order is also forced in the JS implementation

WHY WORSE: Manual parsing allows for relevant error messages all the way, a helpful but tedious process, the rascal implementation simply throws a ParseError without more info. To some extend this is alleviated by creating very lax syntax rules and then double checking in post. This is still an issue, the grammar can only be SO flexible before it becomes ambiguous (see Sprite Length Case).

Current Limitations

  • The parsing for comments is not perfect and you can still run into ambiguous cases and syntax errors

Static Checker

Things are checked in the sequential order in which they appear below, this is necessary as some errors only happens if a specific set of things is missing from MULTIPLE sections.

Philosophy: If we run into an error, we keep checking other issues anyways even if it makes the game unplayable. We assume that the game is unplayable even if there is a single error, so accidentally causing a few more to provide a more thorough check won't make that much difference.

WHY BETTER: In the JS implementation, many errors have to be checked for multiple times

Game

  • ERROR - Duplicate sections: Section is defined more than once
  • WARN - Section Missing: A section is missing

Prelude

  • ERROR - Invalid Palette: Color palette not found
  • ERROR - Invalid Color: Keyword expected color argument

Object

  • ERROR - Existing Legend

  • ERROR - Duplicate Object: Duplicate object name

  • ERROR - Invalid Color: Color not found in color palette

  • ERROR - Invalid Sprite Length: Sprite length not exactly 5 pixels

  • ERROR - Invalid Color Index: Index references color not defined

  • ERROR - Too Many Colors: Sprite cannot have more than 10 colors

  • WARN - Unused Color: Color defined not used in sprite

Legend

  • ERROR - Duplicate Legend: Happens when the user tries to define a legend that already exists

  • ERROR - Mixed Legend: Happens when the user uses a mix of 'and' and 'or' in the legend definition

  • ERROR - Mixed Legend: Happens when the user uses combinations in an alias or vice versa

  • ERROR - Undefined Object: Happens when the user references an object that doesn't exist in the legend values

  • ERROR - No Player: No object named player detected (only happens if it is also not defined in OBJECT)

  • ERROR - Invalid Reference: Happens when a user attempts to use a reference that cannot be used in this type of legend (such as aggregate in combined or vice versa)

  • WARN - Self Definition: A legend has the same name as the object it defines

Sound

Layers

  • ERROR - Undefined Object: Object (or reference) in layer is not defined

  • ERROR - Aggregate Object: Object is an aggregate and cannot be used in a layer

  • ERROR - Unused Object: Object not used in layer

  • ERROR - Aggregate Background: Background cannot not be made up of an combined object

  • WARN - Duplicate in Layer: Object defined in multiple layers

Rules

Rules are quite complex to parse and as such the syntax is very strict, this means a lot of simple errors will cause a SyntaxError rather than more helpful generated one.

Currently missing:

  • Loops

Conditions

  • WARN - No Conditions: No conditions have been defined

I've discovered that the error checking in the javascript implementation is not very good, it doesn't seem to raise any error besides checking that we don't use combinations and that keywords/objects are valid. I think this can be an area in which the rascal implementation severely improve. In my testing, I grew quite frustrated trying to generate bad code for my type checker to pick up on since it seemed that everything would work as long as it was valid even when it resulted in games that could not be won or games that could be won without doing anything.

All Crate on Target
No Crate

Win conditions that require both that there be some crates on the level and no crates, which raises no error.

Level

  • ERROR - Invalid Level Length: All lines of the level must be the same length

  • ERROR - Undefined Object: Object (or reference) in level not defined

  • ERORR - Ambiguous Definition: Legend defined with 'or' cannot appear in Level

  • ERROR - Undefined Legend: Legend used in level not defined

  • WARN - No Levels: No levels defined

  • WARN - Message Too Long: Message too long to fit on screen

Clone this wiki locally