├── LL ├── build.properties ├── src │ ├── tests │ │ ├── correctTestData │ │ │ ├── project1 │ │ │ │ ├── Module2.rcp │ │ │ │ ├── Module1.rcp │ │ │ │ ├── Alphabet.alp │ │ │ │ ├── Project.lsp │ │ │ │ ├── Module2.grm │ │ │ │ └── Module1.grm │ │ │ ├── project0 │ │ │ │ ├── Module.rcp │ │ │ │ ├── Alphabet.alp │ │ │ │ ├── Project.lsp │ │ │ │ └── Module.grm │ │ │ ├── isolatedLevelSpecifications │ │ │ │ ├── occurrence.sanr │ │ │ │ ├── adjacency.sanr │ │ │ │ └── occurrenceAndContainment.sanr │ │ │ ├── project2 │ │ │ │ ├── Project.sanr │ │ │ │ ├── Alphabet.alp │ │ │ │ ├── Project.lsp │ │ │ │ └── Module.grm │ │ │ ├── isolatedRecipes │ │ │ │ ├── comment.rcp │ │ │ │ ├── diceNotation.rcp │ │ │ │ ├── singleInstruction.rcp │ │ │ │ ├── basicInstructions.rcp │ │ │ │ ├── advancedInstructions.rcp │ │ │ │ └── allInstructions.rcp │ │ │ ├── dungeon │ │ │ │ ├── m2.rcp │ │ │ │ ├── m3.rcp │ │ │ │ ├── dungeon.sanr │ │ │ │ ├── m3.grm │ │ │ │ ├── m2.grm │ │ │ │ ├── Alphabet1.alp │ │ │ │ ├── dungeon.lsp │ │ │ │ └── m1.grm │ │ │ ├── dungeonVar1 │ │ │ │ ├── m3.rcp │ │ │ │ ├── m2.rcp │ │ │ │ ├── dungeon.sanr │ │ │ │ ├── m3.grm │ │ │ │ ├── m2.grm │ │ │ │ ├── m4.grm │ │ │ │ ├── Alphabet1.alp │ │ │ │ ├── dungeon.lsp │ │ │ │ └── m1.grm │ │ │ ├── dungeonVar2 │ │ │ │ ├── m3.rcp │ │ │ │ ├── m2.rcp │ │ │ │ ├── dungeon.sanr │ │ │ │ ├── m3.grm │ │ │ │ ├── m2.grm │ │ │ │ ├── Alphabet1.alp │ │ │ │ ├── m4.grm │ │ │ │ ├── dungeon.lsp │ │ │ │ └── m1.grm │ │ │ ├── dungeonVar3 │ │ │ │ ├── m3.rcp │ │ │ │ ├── m2.rcp │ │ │ │ ├── dungeon.sanr │ │ │ │ ├── m4.rcp │ │ │ │ ├── m3.grm │ │ │ │ ├── m2.grm │ │ │ │ ├── Alphabet1.alp │ │ │ │ ├── m4.grm │ │ │ │ ├── dungeon.lsp │ │ │ │ └── m1.grm │ │ │ ├── isolatedAlphabets │ │ │ │ ├── onlyColors.alp │ │ │ │ ├── symbolWithWildCard.alp │ │ │ │ ├── colorsAndAbbreviation.alp │ │ │ │ ├── completeSymbol.alp │ │ │ │ └── mixedSymbols.alp │ │ │ ├── isolatedProjects │ │ │ │ ├── onlyAlphabet.lsp │ │ │ │ ├── singleModule.lsp │ │ │ │ ├── options.lsp │ │ │ │ ├── completeModule.lsp │ │ │ │ ├── registers.lsp │ │ │ │ ├── multipleModulesWithAlphabet.lsp │ │ │ │ └── complexProject.lsp │ │ │ └── isolatedGrammars │ │ │ │ ├── simpleRule.grm │ │ │ │ ├── allOptions.grm │ │ │ │ ├── ruleWithMultipleRightHands.grm │ │ │ │ ├── allRuleSettings.grm │ │ │ │ ├── allMemberTypes.grm │ │ │ │ └── onlyStart.grm │ │ ├── incorrectTestData │ │ │ ├── isolatedGrammars │ │ │ │ ├── unsupportedMapTypes.grm │ │ │ │ ├── wrongVersion.grm │ │ │ │ ├── wrongMapSize.grm │ │ │ │ └── mismatchingMapSize.grm │ │ │ └── isolatedProjects │ │ │ │ └── wrongVersion.lsp │ │ ├── parsing │ │ │ ├── Utility.rsc │ │ │ ├── LevelSpecification.rsc │ │ │ ├── Alphabet.rsc │ │ │ ├── Recipe.rsc │ │ │ ├── Grammar.rsc │ │ │ └── Project.rsc │ │ ├── execution │ │ │ ├── CompleteProjects.rsc │ │ │ ├── ModuleHierarchy.rsc │ │ │ └── History.rsc │ │ └── AllTests.rsc │ ├── visual │ │ ├── projects │ │ │ ├── dungeon │ │ │ │ ├── m3.rcp │ │ │ │ ├── m2.rcp │ │ │ │ ├── dungeon.sanr │ │ │ │ ├── m3.grm │ │ │ │ ├── m2.grm │ │ │ │ ├── Alphabet1.alp │ │ │ │ ├── dungeon.lsp │ │ │ │ └── m1.grm │ │ │ ├── v1 │ │ │ │ ├── EndResult.grm │ │ │ │ ├── Description.txt │ │ │ │ ├── AddVariation.rcp │ │ │ │ ├── PickLargeTemplates.rcp │ │ │ │ ├── BoulderMaps.sanr │ │ │ │ ├── PickVariables.grm │ │ │ │ ├── AddVariation.grm │ │ │ │ ├── BoulderMaps.lsp │ │ │ │ └── Symbols.alp │ │ │ ├── v2 │ │ │ │ ├── EndResult.grm │ │ │ │ ├── Description.txt │ │ │ │ ├── AddVariation.rcp │ │ │ │ ├── PickLargeTemplates.rcp │ │ │ │ ├── BoulderMaps.sanr │ │ │ │ ├── PickVariables.grm │ │ │ │ ├── AddVariation.grm │ │ │ │ ├── BoulderMaps.lsp │ │ │ │ └── Symbols.alp │ │ │ ├── v3 │ │ │ │ ├── EndResult.grm │ │ │ │ ├── Description.txt │ │ │ │ ├── AddVariation.rcp │ │ │ │ ├── PickLargeTemplates.rcp │ │ │ │ ├── BoulderMaps.sanr │ │ │ │ ├── PickVariables.grm │ │ │ │ ├── AddVariation.grm │ │ │ │ ├── BoulderMaps.lsp │ │ │ │ └── Symbols.alp │ │ │ ├── v4 │ │ │ │ ├── EndResult.grm │ │ │ │ ├── Description.txt │ │ │ │ ├── AddVariation.rcp │ │ │ │ ├── PickLargeTemplates.rcp │ │ │ │ ├── BoulderMaps.sanr │ │ │ │ ├── PickVariables.grm │ │ │ │ ├── AddVariation.grm │ │ │ │ ├── BoulderMaps.lsp │ │ │ │ └── Symbols.alp │ │ │ ├── dungeonVar1 │ │ │ │ ├── m3.rcp │ │ │ │ ├── m2.rcp │ │ │ │ ├── dungeon.sanr │ │ │ │ ├── m4.grm │ │ │ │ ├── m3.grm │ │ │ │ ├── m2.grm │ │ │ │ ├── Alphabet1.alp │ │ │ │ ├── dungeon.lsp │ │ │ │ └── m1.grm │ │ │ ├── dungeonVar2 │ │ │ │ ├── m3.rcp │ │ │ │ ├── m2.rcp │ │ │ │ ├── dungeon.sanr │ │ │ │ ├── m3.grm │ │ │ │ ├── m4.grm │ │ │ │ ├── m2.grm │ │ │ │ ├── Alphabet1.alp │ │ │ │ ├── dungeon.lsp │ │ │ │ └── m1.grm │ │ │ └── dungeonVar3 │ │ │ │ ├── m3.rcp │ │ │ │ ├── m2.rcp │ │ │ │ ├── dungeon.sanr │ │ │ │ ├── m4.rcp │ │ │ │ ├── m3.grm │ │ │ │ ├── m2.grm │ │ │ │ ├── Alphabet1.alp │ │ │ │ ├── m4.grm │ │ │ │ ├── dungeon.lsp │ │ │ │ └── m1.grm │ │ └── IDE │ │ │ ├── index.html │ │ │ └── index.css │ ├── utility │ │ ├── Integer.rsc │ │ ├── String.rsc │ │ ├── Time.rsc │ │ └── TileMap.rsc │ ├── execution │ │ ├── MergeFunctions.rsc │ │ ├── DataStructures.rsc │ │ ├── ModuleHierarchy.rsc │ │ ├── Execution.rsc │ │ └── instructions │ │ │ └── Instructions.rsc │ ├── ide │ │ ├── LoadIDE.rsc │ │ └── Registration.rsc │ ├── analysis │ │ ├── sanrWrapper │ │ │ ├── PropertyToText.rsc │ │ │ ├── PropertyHistory.rsc │ │ │ └── Report.rsc │ │ └── madWrapper │ │ │ ├── SymbolHierarchy.rsc │ │ │ ├── MADFramework.rsc │ │ │ └── DataTransformation.rsc │ ├── errors │ │ ├── Execution.rsc │ │ └── Parsing.rsc │ ├── parsing │ │ ├── transformations │ │ │ ├── Properties.rsc │ │ │ ├── Alphabet.rsc │ │ │ ├── Instruction.rsc │ │ │ ├── Utility.rsc │ │ │ ├── Project.rsc │ │ │ ├── CompleteSyntaxTree.rsc │ │ │ ├── Recipe.rsc │ │ │ └── Grammar.rsc │ │ ├── check │ │ │ ├── Interface.rsc │ │ │ ├── Version.rsc │ │ │ ├── Maps.rsc │ │ │ └── Names.rsc │ │ ├── Interface.rsc │ │ ├── languages │ │ │ ├── alphabet │ │ │ │ ├── AST.rsc │ │ │ │ └── Syntax.rsc │ │ │ ├── recipe │ │ │ │ ├── AST.rsc │ │ │ │ └── Syntax.rsc │ │ │ ├── project │ │ │ │ ├── AST.rsc │ │ │ │ └── Syntax.rsc │ │ │ └── grammar │ │ │ │ └── AST.rsc │ │ ├── DataStructures.rsc │ │ └── Parser.rsc │ └── experiments │ │ └── MapSize.rsc ├── .settings │ └── org.eclipse.core.resources.prefs ├── META-INF │ ├── RASCAL.MF │ └── MANIFEST.MF ├── .classpath └── .project ├── .gitignore ├── .project ├── README.md ├── styleGuide.md └── LICENSE /LL/build.properties: -------------------------------------------------------------------------------- 1 | bin.includes = META-INF/ 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | LL/bin/ 3 | /.metadata/ 4 | 5 | *.output 6 | -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/project1/Module2.rcp: -------------------------------------------------------------------------------- 1 | IterateRule("ruleName") -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/project0/Module.rcp: -------------------------------------------------------------------------------- 1 | ExecuteRule("ruleName", 100) -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/isolatedLevelSpecifications/occurrence.sanr: -------------------------------------------------------------------------------- 1 | 3x water -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/project2/Project.sanr: -------------------------------------------------------------------------------- 1 | no defined adjacent to undefined -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/isolatedRecipes/comment.rcp: -------------------------------------------------------------------------------- 1 | //IterateRule("SeedTerrainA") -------------------------------------------------------------------------------- /LL/src/visual/projects/dungeon/m3.rcp: -------------------------------------------------------------------------------- 1 | IterateRule("addWater") ExecuteRule("addPillar", 3) -------------------------------------------------------------------------------- /LL/src/visual/projects/v1/EndResult.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 1 1 0:undefined -------------------------------------------------------------------------------- /LL/src/visual/projects/v2/EndResult.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 1 1 0:undefined -------------------------------------------------------------------------------- /LL/src/visual/projects/v3/EndResult.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 1 1 0:undefined -------------------------------------------------------------------------------- /LL/src/visual/projects/v4/EndResult.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 1 1 0:undefined -------------------------------------------------------------------------------- /LL/src/visual/projects/dungeon/m2.rcp: -------------------------------------------------------------------------------- 1 | IterateRule("addNorthDoor") IterateRule("addEastDoor") -------------------------------------------------------------------------------- /LL/src/visual/projects/dungeonVar1/m3.rcp: -------------------------------------------------------------------------------- 1 | IterateRule("addWater") ExecuteRule("addPillar", 3) -------------------------------------------------------------------------------- /LL/src/visual/projects/dungeonVar2/m3.rcp: -------------------------------------------------------------------------------- 1 | IterateRule("addWater") ExecuteRule("addPillar", 3) -------------------------------------------------------------------------------- /LL/src/visual/projects/dungeonVar3/m3.rcp: -------------------------------------------------------------------------------- 1 | IterateRule("addWater") ExecuteRule("addPillar", 3) -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/dungeon/m2.rcp: -------------------------------------------------------------------------------- 1 | IterateRule("addNorthDoor") IterateRule("addEastDoor") -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/dungeon/m3.rcp: -------------------------------------------------------------------------------- 1 | IterateRule("addWater") ExecuteRule("addPillar", 3) -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/dungeonVar1/m3.rcp: -------------------------------------------------------------------------------- 1 | IterateRule("addWater") ExecuteRule("addPillar", 3) -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/dungeonVar2/m3.rcp: -------------------------------------------------------------------------------- 1 | IterateRule("addWater") ExecuteRule("addPillar", 3) -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/dungeonVar3/m3.rcp: -------------------------------------------------------------------------------- 1 | IterateRule("addWater") ExecuteRule("addPillar", 3) -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/isolatedLevelSpecifications/adjacency.sanr: -------------------------------------------------------------------------------- 1 | no water adjacent to sand -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/isolatedRecipes/diceNotation.rcp: -------------------------------------------------------------------------------- 1 | ExecuteRule("ruleName", 2D3+1) 2 | -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/isolatedRecipes/singleInstruction.rcp: -------------------------------------------------------------------------------- 1 | IterateRule("SeedTerrainA") 2 | -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/project1/Module1.rcp: -------------------------------------------------------------------------------- 1 | ExecuteRule("rule1", 100) IterateRule("rule2") -------------------------------------------------------------------------------- /LL/src/visual/projects/dungeonVar1/m2.rcp: -------------------------------------------------------------------------------- 1 | IterateRule("addNorthDoor") IterateRule("addEastDoor") -------------------------------------------------------------------------------- /LL/src/visual/projects/dungeonVar2/m2.rcp: -------------------------------------------------------------------------------- 1 | IterateRule("addNorthDoor") IterateRule("addEastDoor") -------------------------------------------------------------------------------- /LL/src/visual/projects/dungeonVar3/m2.rcp: -------------------------------------------------------------------------------- 1 | IterateRule("addNorthDoor") IterateRule("addEastDoor") -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/dungeonVar1/m2.rcp: -------------------------------------------------------------------------------- 1 | IterateRule("addNorthDoor") IterateRule("addEastDoor") -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/dungeonVar2/m2.rcp: -------------------------------------------------------------------------------- 1 | IterateRule("addNorthDoor") IterateRule("addEastDoor") -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/dungeonVar3/m2.rcp: -------------------------------------------------------------------------------- 1 | IterateRule("addNorthDoor") IterateRule("addEastDoor") -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/isolatedLevelSpecifications/occurrenceAndContainment.sanr: -------------------------------------------------------------------------------- 1 | 3x water in lake -------------------------------------------------------------------------------- /LL/src/visual/projects/v3/Description.txt: -------------------------------------------------------------------------------- 1 | ------------------------ 2 | - Not enough diamonds. %?? 3 | -------------------------------------------------------------------------------- /LL/src/visual/projects/v4/Description.txt: -------------------------------------------------------------------------------- 1 | ------------------------ 2 | - Not enough diamonds. %?? 3 | -------------------------------------------------------------------------------- /LL/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/isolatedAlphabets/onlyColors.alp: -------------------------------------------------------------------------------- 1 | TILEMAP 1 1 undefined(color=#404040, fill=#B0B0B0) -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/isolatedAlphabets/symbolWithWildCard.alp: -------------------------------------------------------------------------------- 1 | TILEMAP 1 1 *(color=#404040, fill=#B0B0B0) -------------------------------------------------------------------------------- /LL/META-INF/RASCAL.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 0.0.1 2 | Main-Function: main 3 | Main-Module: Plugin 4 | Source: src 5 | 6 | -------------------------------------------------------------------------------- /LL/src/tests/incorrectTestData/isolatedGrammars/unsupportedMapTypes.grm: -------------------------------------------------------------------------------- 1 | version: 0.5f 2 | start: GRAPH 0:undefined 3 | -------------------------------------------------------------------------------- /LL/src/tests/incorrectTestData/isolatedGrammars/wrongVersion.grm: -------------------------------------------------------------------------------- 1 | version: 0.5f 2 | start: TILEMAP 1 1 0:undefined 3 | -------------------------------------------------------------------------------- /LL/src/visual/projects/v2/Description.txt: -------------------------------------------------------------------------------- 1 | ------------------------ 2 | - Not enough diamonds. % ?? 3 | - Puzzle bug. %?? -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/isolatedAlphabets/colorsAndAbbreviation.alp: -------------------------------------------------------------------------------- 1 | TILEMAP 1 1 undefined(color=#404040, fill=#B0B0B0) 2 | -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/isolatedProjects/onlyAlphabet.lsp: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | alphabet: 3 | name: "Alphabet" 4 | position: (-1,-40) 5 | -------------------------------------------------------------------------------- /LL/src/tests/incorrectTestData/isolatedProjects/wrongVersion.lsp: -------------------------------------------------------------------------------- 1 | version: 0.4f 2 | alphabet: 3 | name: "Alphabet" 4 | position: (-1,-40) 5 | -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/isolatedAlphabets/completeSymbol.alp: -------------------------------------------------------------------------------- 1 | TILEMAP 1 1 2 | undefined(color=#404040, fill=#B0B0B0, abbreviation="u", shape=2) -------------------------------------------------------------------------------- /LL/src/visual/projects/v1/Description.txt: -------------------------------------------------------------------------------- 1 | ------------------------ 2 | - Not enough diamonds. 3 | - Some non terminal symbols. 4 | - Puzzle bug. -------------------------------------------------------------------------------- /LL/src/tests/incorrectTestData/isolatedGrammars/wrongMapSize.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 1 1 0:undefined 1:undefined 2:undefined 3:undefined 3 | -------------------------------------------------------------------------------- /LL/src/visual/projects/dungeon/dungeon.sanr: -------------------------------------------------------------------------------- 1 | 2x door in addWalls 2 | 1x water 3 | 3x pillar 4 | 0x pillar adjacent to door 5 | 0x water adjacent to pillar -------------------------------------------------------------------------------- /LL/src/visual/projects/dungeonVar1/dungeon.sanr: -------------------------------------------------------------------------------- 1 | 2x door in addWalls 2 | 1x water 3 | 3x pillar 4 | 0x pillar adjacent to door 5 | 0x water adjacent to pillar -------------------------------------------------------------------------------- /LL/src/visual/projects/dungeonVar2/dungeon.sanr: -------------------------------------------------------------------------------- 1 | 2x door in addWalls 2 | 1x water 3 | 3x pillar 4 | 0x pillar adjacent to door 5 | 0x water adjacent to pillar -------------------------------------------------------------------------------- /LL/src/visual/projects/dungeonVar3/dungeon.sanr: -------------------------------------------------------------------------------- 1 | 2x door in addWalls 2 | 1x water 3 | 3x pillar 4 | 0x pillar adjacent to door 5 | 0x water adjacent to pillar -------------------------------------------------------------------------------- /LL/src/visual/projects/dungeonVar3/m4.rcp: -------------------------------------------------------------------------------- 1 | IterateRule("startRoute") IterateRule("continueRoute") IterateRule("continueRoute2") ExecuteRule("continueRoute3", 4) -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/dungeon/dungeon.sanr: -------------------------------------------------------------------------------- 1 | 2x door in addWalls 2 | 1x water 3 | 3x pillar 4 | no pillar adjacent to door 5 | no water adjacent to pillar 6 | -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/dungeonVar1/dungeon.sanr: -------------------------------------------------------------------------------- 1 | 2x door in addWalls 2 | 1x water 3 | 3x pillar 4 | no pillar adjacent to door 5 | no water adjacent to pillar -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/dungeonVar2/dungeon.sanr: -------------------------------------------------------------------------------- 1 | 2x door in addWalls 2 | 1x water 3 | 3x pillar 4 | no pillar adjacent to door 5 | no water adjacent to pillar -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/dungeonVar3/dungeon.sanr: -------------------------------------------------------------------------------- 1 | 2x door in addWalls 2 | 1x water 3 | 3x pillar 4 | no pillar adjacent to door 5 | no water adjacent to pillar -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/dungeonVar3/m4.rcp: -------------------------------------------------------------------------------- 1 | IterateRule("startRoute") IterateRule("continueRoute") IterateRule("continueRoute2") ExecuteRule("continueRoute3", 4) -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/isolatedRecipes/basicInstructions.rcp: -------------------------------------------------------------------------------- 1 | IterateRule("ruleName") 2 | ExecuteRule("ruleName", 100) 3 | CreateTileMap(width, height, "undefined") 4 | -------------------------------------------------------------------------------- /LL/src/visual/projects/v1/AddVariation.rcp: -------------------------------------------------------------------------------- 1 | ExecuteRule("SwapSpaceAndDirt2x2", 20) ExecuteRule("SwapSpaceAndDirt2x1", 0) ExecuteRule("SwapDiamond", 20) ExecuteRule("ReplaceDirt", 5) -------------------------------------------------------------------------------- /LL/src/visual/projects/v2/AddVariation.rcp: -------------------------------------------------------------------------------- 1 | ExecuteRule("SwapSpaceAndDirt2x2", 20) ExecuteRule("SwapSpaceAndDirt2x1", 0) ExecuteRule("SwapDiamond", 20) ExecuteRule("ReplaceDirt", 5) -------------------------------------------------------------------------------- /LL/src/visual/projects/v3/AddVariation.rcp: -------------------------------------------------------------------------------- 1 | ExecuteRule("SwapSpaceAndDirt2x2", 20) ExecuteRule("SwapSpaceAndDirt2x1", 0) ExecuteRule("SwapDiamond", 20) ExecuteRule("ReplaceDirt", 5) -------------------------------------------------------------------------------- /LL/src/visual/projects/v4/AddVariation.rcp: -------------------------------------------------------------------------------- 1 | ExecuteRule("SwapSpaceAndDirt2x2", 20) ExecuteRule("SwapSpaceAndDirt2x1", 0) ExecuteRule("SwapDiamond", 20) ExecuteRule("ReplaceDirt", 5) -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/isolatedGrammars/simpleRule.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 1 1 0:undefined 3 | rule: RuleName = TILEMAP 1 1 0:undefined > {0 = TILEMAP 1 1 0:undefined} 4 | -------------------------------------------------------------------------------- /LL/src/visual/projects/dungeonVar1/m4.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 1 1 0:undefined 3 | rule: clearDoors(width=2, gt=4) = TILEMAP 2 1 0:pillar 1:door > {0 = TILEMAP 2 1 0:floor 1:door} 4 | -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/project1/Alphabet.alp: -------------------------------------------------------------------------------- 1 | TILEMAP 1 1 *(color=#B0B0B0, fill=#404040) undefined(color=#404040, fill=#B0B0B0, abbreviation="u") defined(color=#000000, fill=#FFFFFF, abbreviation="d") 2 | -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/project0/Alphabet.alp: -------------------------------------------------------------------------------- 1 | TILEMAP 1 1 2 | *(color=#B0B0B0, fill=#404040) 3 | undefined(color=#404040, fill=#B0B0B0, abbreviation="u") 4 | defined(color=#404040, fill=#B0B0B0, abbreviation="d") -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/project2/Alphabet.alp: -------------------------------------------------------------------------------- 1 | TILEMAP 1 1 2 | *(color=#B0B0B0, fill=#404040) 3 | undefined(color=#404040, fill=#B0B0B0, abbreviation="u") 4 | defined(color=#404040, fill=#B0B0B0, abbreviation="d") -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/isolatedGrammars/allOptions.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 1 1 0:undefined 3 | checkCollisions: true 4 | stayWithinBounds: true 5 | trackNonTerminals: true 6 | findOnlyOneOption: false 7 | -------------------------------------------------------------------------------- /LL/src/tests/incorrectTestData/isolatedGrammars/mismatchingMapSize.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 1 1 0:undefined 3 | rule: RuleName = TILEMAP 1 1 0:undefined > {0 = TILEMAP 2 2 0:defined 1:defined 2:defined 3:defined} 4 | -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/isolatedProjects/singleModule.lsp: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | module: 3 | name: "Module" 4 | position: (1,40) 5 | type: Recipe 6 | match: None 7 | grammar: true 8 | recipe: true 9 | showMembers: true 10 | -------------------------------------------------------------------------------- /LL/src/visual/projects/dungeon/m3.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 1 1 0:undefined 3 | rule: addWater = TILEMAP 1 1 0:floor > {0 = TILEMAP 1 1 0:water} 4 | rule: addPillar = TILEMAP 1 1 0:floor > {0 = TILEMAP 1 1 0:pillar} 5 | -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/dungeon/m3.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 1 1 0:undefined 3 | rule: addWater = TILEMAP 1 1 0:floor > {0 = TILEMAP 1 1 0:water} 4 | rule: addPillar = TILEMAP 1 1 0:floor > {0 = TILEMAP 1 1 0:pillar} 5 | -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/isolatedGrammars/ruleWithMultipleRightHands.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 1 1 0:undefined 3 | rule: RuleName = TILEMAP 1 1 0:undefined > {0 = TILEMAP 1 1 0:undefined} | {1 = TILEMAP 1 1 0:undefined} 4 | -------------------------------------------------------------------------------- /LL/src/visual/projects/dungeonVar1/m3.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 1 1 0:undefined 3 | rule: addWater = TILEMAP 1 1 0:floor > {0 = TILEMAP 1 1 0:water} 4 | rule: addPillar = TILEMAP 1 1 0:floor > {0 = TILEMAP 1 1 0:pillar} 5 | -------------------------------------------------------------------------------- /LL/src/visual/projects/dungeonVar2/m3.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 1 1 0:undefined 3 | rule: addWater = TILEMAP 1 1 0:floor > {0 = TILEMAP 1 1 0:water} 4 | rule: addPillar = TILEMAP 1 1 0:floor > {0 = TILEMAP 1 1 0:pillar} 5 | -------------------------------------------------------------------------------- /LL/src/visual/projects/dungeonVar2/m4.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 1 1 0:undefined 3 | rule: clearDoors(width=2, height=2, gt=7) = TILEMAP 2 2 0:wall 1:door 2:floor 3:pillar > {0 = TILEMAP 2 2 0:wall 1:door 2:pillar 3:floor} 4 | -------------------------------------------------------------------------------- /LL/src/visual/projects/dungeonVar3/m3.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 1 1 0:undefined 3 | rule: addWater = TILEMAP 1 1 0:floor > {0 = TILEMAP 1 1 0:water} 4 | rule: addPillar = TILEMAP 1 1 0:floor > {0 = TILEMAP 1 1 0:pillar} 5 | -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/dungeonVar1/m3.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 1 1 0:undefined 3 | rule: addWater = TILEMAP 1 1 0:floor > {0 = TILEMAP 1 1 0:water} 4 | rule: addPillar = TILEMAP 1 1 0:floor > {0 = TILEMAP 1 1 0:pillar} 5 | -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/dungeonVar2/m3.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 1 1 0:undefined 3 | rule: addWater = TILEMAP 1 1 0:floor > {0 = TILEMAP 1 1 0:water} 4 | rule: addPillar = TILEMAP 1 1 0:floor > {0 = TILEMAP 1 1 0:pillar} 5 | -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/dungeonVar3/m3.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 1 1 0:undefined 3 | rule: addWater = TILEMAP 1 1 0:floor > {0 = TILEMAP 1 1 0:water} 4 | rule: addPillar = TILEMAP 1 1 0:floor > {0 = TILEMAP 1 1 0:pillar} 5 | -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/isolatedRecipes/advancedInstructions.rcp: -------------------------------------------------------------------------------- 1 | IterateRuleCellular("ruleName") 2 | ExecuteRuleCellular("ruleName", 1) 3 | IterateRuleLSystem("ruleName") 4 | ExecuteRuleLSystem("ruleName", 1) 5 | ReplaceLabels("ruleName", "undefined") 6 | -------------------------------------------------------------------------------- /LL/src/utility/Integer.rsc: -------------------------------------------------------------------------------- 1 | module utility::Integer 2 | 3 | public int sign(int number) 4 | { 5 | if (number > 1) 6 | { 7 | return 1; 8 | } 9 | else if (number < 1) 10 | { 11 | return -1; 12 | } 13 | else 14 | { 15 | return 0; 16 | } 17 | } -------------------------------------------------------------------------------- /LL/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Bundle-ManifestVersion: 2 3 | Bundle-Name: Ludoscope_Light 4 | Bundle-SymbolicName: Ludoscope_Light 5 | Bundle-Version: 1.0.0 6 | Require-Bundle: rascal_eclipse 7 | Bundle-RequiredExecutionEnvironment: JavaSE-1.8 8 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | LudoscopeLite 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /LL/src/visual/projects/dungeon/m2.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 1 1 0:undefined 3 | rule: addNorthDoor(height=2) = TILEMAP 1 2 0:wall 1:floor > {0 = TILEMAP 1 2 0:door 1:floor} 4 | rule: addEastDoor(width=2) = TILEMAP 2 1 0:floor 1:wall > {0 = TILEMAP 2 1 0:floor 1:door} 5 | -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/dungeon/m2.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 1 1 0:undefined 3 | rule: addNorthDoor(height=2) = TILEMAP 1 2 0:wall 1:floor > {0 = TILEMAP 1 2 0:door 1:floor} 4 | rule: addEastDoor(width=2) = TILEMAP 2 1 0:floor 1:wall > {0 = TILEMAP 2 1 0:floor 1:door} 5 | -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/isolatedGrammars/allRuleSettings.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 1 1 0:undefined 3 | rule: RuleName(width=2, height=2, gt=7) = TILEMAP 2 2 0:undefined 1:undefined 2:undefined 3:undefined > {0 = TILEMAP 2 2 0:defined 1:defined 2:defined 3:defined} 4 | -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/isolatedProjects/options.lsp: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | option: Width 9 3 | option: Height 5 4 | option: Tile "undefined" 5 | option: Register "requests" 6 | option: Find "blocked" 7 | option: Replace "undefined" 8 | option: SplitX 5 9 | option: SplitY 5 10 | -------------------------------------------------------------------------------- /LL/src/visual/projects/dungeonVar1/m2.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 1 1 0:undefined 3 | rule: addNorthDoor(height=2) = TILEMAP 1 2 0:wall 1:floor > {0 = TILEMAP 1 2 0:door 1:floor} 4 | rule: addEastDoor(width=2) = TILEMAP 2 1 0:floor 1:wall > {0 = TILEMAP 2 1 0:floor 1:door} 5 | -------------------------------------------------------------------------------- /LL/src/visual/projects/dungeonVar2/m2.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 1 1 0:undefined 3 | rule: addNorthDoor(height=2) = TILEMAP 1 2 0:wall 1:floor > {0 = TILEMAP 1 2 0:door 1:floor} 4 | rule: addEastDoor(width=2) = TILEMAP 2 1 0:floor 1:wall > {0 = TILEMAP 2 1 0:floor 1:door} 5 | -------------------------------------------------------------------------------- /LL/src/visual/projects/dungeonVar3/m2.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 1 1 0:undefined 3 | rule: addNorthDoor(height=2) = TILEMAP 1 2 0:wall 1:route > {0 = TILEMAP 1 2 0:door 1:route} 4 | rule: addEastDoor(width=2) = TILEMAP 2 1 0:route 1:wall > {0 = TILEMAP 2 1 0:route 1:door} 5 | -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/dungeonVar1/m2.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 1 1 0:undefined 3 | rule: addNorthDoor(height=2) = TILEMAP 1 2 0:wall 1:floor > {0 = TILEMAP 1 2 0:door 1:floor} 4 | rule: addEastDoor(width=2) = TILEMAP 2 1 0:floor 1:wall > {0 = TILEMAP 2 1 0:floor 1:door} 5 | -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/dungeonVar2/m2.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 1 1 0:undefined 3 | rule: addNorthDoor(height=2) = TILEMAP 1 2 0:wall 1:floor > {0 = TILEMAP 1 2 0:door 1:floor} 4 | rule: addEastDoor(width=2) = TILEMAP 2 1 0:floor 1:wall > {0 = TILEMAP 2 1 0:floor 1:door} 5 | -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/dungeonVar3/m2.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 1 1 0:undefined 3 | rule: addNorthDoor(height=2) = TILEMAP 1 2 0:wall 1:route > {0 = TILEMAP 1 2 0:door 1:route} 4 | rule: addEastDoor(width=2) = TILEMAP 2 1 0:route 1:wall > {0 = TILEMAP 2 1 0:route 1:door} 5 | -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/dungeonVar1/m4.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 1 1 0:undefined 3 | rule: clearEastDoor(width=2) = TILEMAP 2 1 0:pillar 1:door > {0 = TILEMAP 2 1 0:floor 1:door} 4 | rule: clearNorthDoor(height=2) = TILEMAP 1 2 0:door 1:pillar > {0 = TILEMAP 1 2 0:door 1:floor} 5 | -------------------------------------------------------------------------------- /LL/src/visual/projects/v1/PickLargeTemplates.rcp: -------------------------------------------------------------------------------- 1 | IterateRule("AddTemplateStart") IterateRule("AddTemplateEnd") IterateRule("AddTemplateMonster") ExecuteRule("AddTemplateReward", 1) ExecuteRule("AddTemplateMaze", 1) ExecuteRule("AddTemplateBoulder", 1) ExecuteRule("AddTemplateTraversal", 1) ExecuteRule("AddTemplatePuzzle", 1) -------------------------------------------------------------------------------- /LL/src/visual/projects/v2/PickLargeTemplates.rcp: -------------------------------------------------------------------------------- 1 | IterateRule("AddTemplateStart") IterateRule("AddTemplateEnd") IterateRule("AddTemplateMonster") ExecuteRule("AddTemplateReward", 1) ExecuteRule("AddTemplateMaze", 1) ExecuteRule("AddTemplateBoulder", 1) ExecuteRule("AddTemplateTraversal", 1) ExecuteRule("AddTemplatePuzzle", 1) -------------------------------------------------------------------------------- /LL/src/visual/projects/v3/PickLargeTemplates.rcp: -------------------------------------------------------------------------------- 1 | IterateRule("AddTemplateStart") IterateRule("AddTemplateEnd") IterateRule("AddTemplateMonster") ExecuteRule("AddTemplateReward", 1) ExecuteRule("AddTemplateMaze", 1) ExecuteRule("AddTemplateBoulder", 1) ExecuteRule("AddTemplateTraversal", 1) ExecuteRule("AddTemplatePuzzle", 1) -------------------------------------------------------------------------------- /LL/src/visual/projects/v4/PickLargeTemplates.rcp: -------------------------------------------------------------------------------- 1 | IterateRule("AddTemplateStart") IterateRule("AddTemplateEnd") IterateRule("AddTemplateMonster") ExecuteRule("AddTemplateReward", 1) ExecuteRule("AddTemplateMaze", 1) ExecuteRule("AddTemplateBoulder", 1) ExecuteRule("AddTemplateTraversal", 1) ExecuteRule("AddTemplatePuzzle", 1) -------------------------------------------------------------------------------- /LL/src/visual/projects/dungeon/Alphabet1.alp: -------------------------------------------------------------------------------- 1 | TILEMAP 1 1 *(color=#B0B0B0, fill=#404040) floor(color=#000000, fill=#FFFFFF, abbreviation="f") wall(color=#000000, fill=#404040, abbreviation="w") door(color=#000000, fill=#7DF07D, abbreviation="d") pillar(color=#000000, fill=#F04B4B, abbreviation="p") water(color=#000000, fill=#7D7DDC, abbreviation="a") -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/dungeon/Alphabet1.alp: -------------------------------------------------------------------------------- 1 | TILEMAP 1 1 *(color=#B0B0B0, fill=#404040) floor(color=#000000, fill=#FFFFFF, abbreviation="f") wall(color=#000000, fill=#404040, abbreviation="w") door(color=#000000, fill=#7DF07D, abbreviation="d") pillar(color=#000000, fill=#F04B4B, abbreviation="p") water(color=#000000, fill=#7D7DDC, abbreviation="a") -------------------------------------------------------------------------------- /LL/src/visual/projects/dungeonVar1/Alphabet1.alp: -------------------------------------------------------------------------------- 1 | TILEMAP 1 1 *(color=#B0B0B0, fill=#404040) floor(color=#000000, fill=#FFFFFF, abbreviation="f") wall(color=#000000, fill=#404040, abbreviation="w") door(color=#000000, fill=#7DF07D, abbreviation="d") pillar(color=#000000, fill=#F04B4B, abbreviation="p") water(color=#000000, fill=#7D7DDC, abbreviation="a") -------------------------------------------------------------------------------- /LL/src/visual/projects/dungeonVar2/Alphabet1.alp: -------------------------------------------------------------------------------- 1 | TILEMAP 1 1 *(color=#B0B0B0, fill=#404040) floor(color=#000000, fill=#FFFFFF, abbreviation="f") wall(color=#000000, fill=#404040, abbreviation="w") door(color=#000000, fill=#7DF07D, abbreviation="d") pillar(color=#000000, fill=#F04B4B, abbreviation="p") water(color=#000000, fill=#7D7DDC, abbreviation="a") -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/dungeonVar1/Alphabet1.alp: -------------------------------------------------------------------------------- 1 | TILEMAP 1 1 *(color=#B0B0B0, fill=#404040) floor(color=#000000, fill=#FFFFFF, abbreviation="f") wall(color=#000000, fill=#404040, abbreviation="w") door(color=#000000, fill=#7DF07D, abbreviation="d") pillar(color=#000000, fill=#F04B4B, abbreviation="p") water(color=#000000, fill=#7D7DDC, abbreviation="a") -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/dungeonVar2/Alphabet1.alp: -------------------------------------------------------------------------------- 1 | TILEMAP 1 1 *(color=#B0B0B0, fill=#404040) floor(color=#000000, fill=#FFFFFF, abbreviation="f") wall(color=#000000, fill=#404040, abbreviation="w") door(color=#000000, fill=#7DF07D, abbreviation="d") pillar(color=#000000, fill=#F04B4B, abbreviation="p") water(color=#000000, fill=#7D7DDC, abbreviation="a") -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/project2/Project.lsp: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | module: 3 | name: "Module" 4 | alphabet: "Alphabet" 5 | position: (1,40) 6 | type: Recipe 7 | match: None 8 | grammar: true 9 | showMembers: true 10 | 11 | alphabet: 12 | name: "Alphabet" 13 | position: (-1,-40) 14 | 15 | option: Width 5 16 | option: Height 5 17 | option: Tile "undefined" 18 | -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/project0/Project.lsp: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | module: 3 | name: "Module" 4 | alphabet: "Alphabet" 5 | position: (1,40) 6 | type: Recipe 7 | match: None 8 | grammar: true 9 | recipe: true 10 | showMembers: true 11 | 12 | alphabet: 13 | name: "Alphabet" 14 | position: (-1,-40) 15 | 16 | option: Width 5 17 | option: Height 5 18 | option: Tile "undefined" 19 | -------------------------------------------------------------------------------- /LL/src/visual/projects/dungeonVar3/Alphabet1.alp: -------------------------------------------------------------------------------- 1 | TILEMAP 1 1 *(color=#B0B0B0, fill=#404040) floor(color=#000000, fill=#FFFFFF, abbreviation="f") route(color=#000000, fill=#DDDDDD, abbreviation="r") wall(color=#000000, fill=#404040, abbreviation="w") door(color=#000000, fill=#7DF07D, abbreviation="d") pillar(color=#000000, fill=#F04B4B, abbreviation="p") water(color=#000000, fill=#7D7DDC, abbreviation="a") -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/dungeonVar3/Alphabet1.alp: -------------------------------------------------------------------------------- 1 | TILEMAP 1 1 *(color=#B0B0B0, fill=#404040) floor(color=#000000, fill=#FFFFFF, abbreviation="f") route(color=#000000, fill=#DDDDDD, abbreviation="r") wall(color=#000000, fill=#404040, abbreviation="w") door(color=#000000, fill=#7DF07D, abbreviation="d") pillar(color=#000000, fill=#F04B4B, abbreviation="p") water(color=#000000, fill=#7D7DDC, abbreviation="a") -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/isolatedProjects/completeModule.lsp: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | module: 3 | name: "SetSpawnLocations" 4 | alphabet: "MapTiles" 5 | position: (144,124) 6 | type: Recipe 7 | fileName: "name.txt" 8 | match: None 9 | inputs: "CombineTerrain" 10 | maxIterations: 5 11 | filter: "filterName" 12 | grammar: true 13 | executionType: LSystem 14 | recipe: true 15 | showMembers: true 16 | alwaysStartWithToken: true 17 | -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/project0/Module.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 5 5 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 3 | rule: ruleName = TILEMAP 1 1 0:undefined > {0 = TILEMAP 1 1 0:defined} 4 | -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/project2/Module.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 5 5 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 3 | rule: ruleName = TILEMAP 1 1 0:undefined > {0 = TILEMAP 1 1 0:defined} 4 | -------------------------------------------------------------------------------- /LL/src/execution/MergeFunctions.rsc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Merge inputs 4 | // @brief This file contains functions that help merge mutliple module 5 | // inputs. 6 | // @contributor Quinten Heijn - samuel.heijn@gmail.com - UvA 7 | // @date 01-05-2018 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | module execution::MergeFunctions -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/isolatedProjects/registers.lsp: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | register: width 9 3 | register: height 5 4 | register: requests ["moonlight", "flowstone", "bigLeaves"] 5 | register: setRequests false 6 | register: terrainA "high" 7 | register: terrainB "bushes" 8 | register: terrainC "bushes" 9 | register: terrainD "shallowWater" 10 | register: terrainE "bushes" 11 | register: terrainF "bushes" 12 | register: elevation 12 13 | register: entrance "west" 14 | register: barrierX null 15 | -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/project1/Project.lsp: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | module: 3 | name: "Module1" 4 | alphabet: "Alphabet" 5 | position: (-300,-16) 6 | type: Recipe 7 | match: None 8 | grammar: true 9 | recipe: true 10 | showMembers: true 11 | 12 | alphabet: 13 | name: "Alphabet" 14 | position: (-284,-226) 15 | 16 | module: 17 | name: "Module2" 18 | alphabet: "Alphabet" 19 | position: (-108,-32) 20 | type: Recipe 21 | match: None 22 | inputs: "Module1" 23 | grammar: true 24 | recipe: true 25 | showMembers: true -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/isolatedProjects/multipleModulesWithAlphabet.lsp: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | module: 3 | name: "Module1" 4 | alphabet: "Alphabet" 5 | position: (-300,-16) 6 | type: Recipe 7 | match: None 8 | grammar: true 9 | recipe: true 10 | showMembers: true 11 | 12 | alphabet: 13 | name: "Alphabet" 14 | position: (-284,-226) 15 | 16 | module: 17 | name: "Module2" 18 | alphabet: "Alphabet" 19 | position: (-108,-32) 20 | type: Recipe 21 | match: None 22 | inputs: "Module1" 23 | grammar: true 24 | recipe: true 25 | showMembers: true 26 | -------------------------------------------------------------------------------- /LL/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/isolatedRecipes/allInstructions.rcp: -------------------------------------------------------------------------------- 1 | IterateRuleCellular("ruleName") 2 | ExecuteRuleCellular("ruleName", 1) 3 | IterateRuleLSystem("ruleName") 4 | ExecuteRuleLSystem("ruleName", 1) 5 | IterateRule("ruleName") 6 | ExecuteRule("ruleName", 100) 7 | IterateFromRegister("register") 8 | ExecuteFromRegister("register", 100) 9 | SetRegister("register", 10) 10 | ReplaceLabels("ruleName", "undefined") 11 | CreateTileMap(width, height, "undefined") 12 | CreateTileMap(1, 1, "undefined") 13 | SplitTiles(1, 1) 14 | TransformSymbols("symbolName", "symbolName(setting=value)") 15 | KeepTopOfStack 16 | -------------------------------------------------------------------------------- /LL/src/ide/LoadIDE.rsc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Load IDE 4 | // @brief This file can be run to load an IDE for LL in ecplise. 5 | // @contributor Quinten Heijn - samuel.heijn@gmail.com - UvA 6 | // @date 02-05-2018 7 | // 8 | ////////////////////////////////////////////////////////////////////////////// 9 | 10 | module ide::LoadIDE 11 | 12 | import IO; 13 | import ide::Registration; 14 | 15 | public void main() 16 | { 17 | registerLanguages(); 18 | addSyntaxHighLights(); 19 | addMenuItems(); 20 | println("IDE loaded."); 21 | } -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/dungeonVar2/m4.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 1 1 0:undefined 3 | rule: clearNorthDoor(width=2, height=2) = TILEMAP 2 2 0:wall 1:door 2:floor 3:pillar > {0 = TILEMAP 2 2 0:wall 1:door 2:pillar 3:floor} 4 | rule: clearNorthDoor2(width=2, height=2) = TILEMAP 2 2 0:door 1:wall 2:pillar 3:floor > {0 = TILEMAP 2 2 0:door 1:wall 2:floor 3:pillar} 5 | rule: clearEastDoor(width=2, height=2) = TILEMAP 2 2 0:pillar 1:door 2:floor 3:wall > {0 = TILEMAP 2 2 0:floor 1:door 2:pillar 3:wall} 6 | rule: clearEastDoor2(width=2, height=2) = TILEMAP 2 2 0:floor 1:wall 2:pillar 3:door > {0 = TILEMAP 2 2 0:pillar 1:wall 2:floor 3:door} 7 | -------------------------------------------------------------------------------- /LL/src/visual/projects/v1/BoulderMaps.sanr: -------------------------------------------------------------------------------- 1 | 0x dirtOrSpace 2 | 0x diamondOrBoulder 3 | 0x dirtOrDiamond 4 | 0x fireflyOrButterfly 5 | 0x brickOrMagic 6 | 0x dirtOrBoulder 7 | 0x TemplateSpot 8 | 0x Empty 9 | 0x TemplateStart 10 | 0x TemplateEnd 11 | 0x TemplateMonster 12 | 0x TemplateReward 13 | 0x TemplateBoulder 14 | 0x TemplateTraversal 15 | 0x TemplateMaze1 16 | 0x TemplateMaze2 17 | 0x TemplateMaze3 18 | 0x TemplateMaze4 19 | 20 | 1x rockford 21 | 1x exit 22 | 1x firefly in AddTemplateMaze 23 | 1x diamond in AddTemplateMaze 24 | 2x dirt in AddTemplateMaze 25 | 1x boulder adjacent to space in AddMediumTemplatePuzzle 26 | 27 | at least 5x diamond 28 | at most 15x diamond -------------------------------------------------------------------------------- /LL/src/visual/projects/v2/BoulderMaps.sanr: -------------------------------------------------------------------------------- 1 | 0x dirtOrSpace 2 | 0x diamondOrBoulder 3 | 0x dirtOrDiamond 4 | 0x fireflyOrButterfly 5 | 0x brickOrMagic 6 | 0x dirtOrBoulder 7 | 0x TemplateSpot 8 | 0x Empty 9 | 0x TemplateStart 10 | 0x TemplateEnd 11 | 0x TemplateMonster 12 | 0x TemplateReward 13 | 0x TemplateBoulder 14 | 0x TemplateTraversal 15 | 0x TemplateMaze1 16 | 0x TemplateMaze2 17 | 0x TemplateMaze3 18 | 0x TemplateMaze4 19 | 20 | 1x rockford 21 | 1x exit 22 | 1x firefly in AddTemplateMaze 23 | 1x diamond in AddTemplateMaze 24 | 2x dirt in AddTemplateMaze 25 | 1x boulder adjacent to space in AddMediumTemplatePuzzle 26 | 27 | at least 5x diamond 28 | at most 15x diamond -------------------------------------------------------------------------------- /LL/src/visual/projects/v3/BoulderMaps.sanr: -------------------------------------------------------------------------------- 1 | 0x dirtOrSpace 2 | 0x diamondOrBoulder 3 | 0x dirtOrDiamond 4 | 0x fireflyOrButterfly 5 | 0x brickOrMagic 6 | 0x dirtOrBoulder 7 | 0x TemplateSpot 8 | 0x Empty 9 | 0x TemplateStart 10 | 0x TemplateEnd 11 | 0x TemplateMonster 12 | 0x TemplateReward 13 | 0x TemplateBoulder 14 | 0x TemplateTraversal 15 | 0x TemplateMaze1 16 | 0x TemplateMaze2 17 | 0x TemplateMaze3 18 | 0x TemplateMaze4 19 | 20 | 1x rockford 21 | 1x exit 22 | 1x firefly in AddTemplateMaze 23 | 1x diamond in AddTemplateMaze 24 | 2x dirt in AddTemplateMaze 25 | 1x boulder adjacent to space in AddMediumTemplatePuzzle 26 | 27 | at least 5x diamond 28 | at most 15x diamond -------------------------------------------------------------------------------- /LL/src/visual/projects/v4/BoulderMaps.sanr: -------------------------------------------------------------------------------- 1 | 0x dirtOrSpace 2 | 0x diamondOrBoulder 3 | 0x dirtOrDiamond 4 | 0x fireflyOrButterfly 5 | 0x brickOrMagic 6 | 0x dirtOrBoulder 7 | 0x TemplateSpot 8 | 0x Empty 9 | 0x TemplateStart 10 | 0x TemplateEnd 11 | 0x TemplateMonster 12 | 0x TemplateReward 13 | 0x TemplateBoulder 14 | 0x TemplateTraversal 15 | 0x TemplateMaze1 16 | 0x TemplateMaze2 17 | 0x TemplateMaze3 18 | 0x TemplateMaze4 19 | 20 | 1x rockford 21 | 1x exit 22 | 1x firefly in AddTemplateMaze 23 | 1x diamond in AddTemplateMaze 24 | 2x dirt in AddTemplateMaze 25 | 1x boulder adjacent to space in AddMediumTemplatePuzzle 26 | 27 | at least 5x diamond 28 | at most 15x diamond -------------------------------------------------------------------------------- /LL/src/visual/projects/dungeonVar3/m4.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 1 1 0:undefined 3 | rule: startRoute(width=2) = TILEMAP 2 1 0:floor 1:wall > {0 = TILEMAP 2 1 0:route 1:wall} 4 | rule: continueRoute(width=5) = TILEMAP 5 1 0:floor 1:floor 2:floor 3:route 4:wall > {0 = TILEMAP 5 1 0:floor 1:floor 2:route 3:route 4:wall} | {1 = TILEMAP 5 1 0:floor 1:route 2:route 3:route 4:wall} | {2 = TILEMAP 5 1 0:route 1:route 2:route 3:route 4:wall} 5 | rule: continueRoute2(width=2, height=2) = TILEMAP 2 2 0:floor 1:floor 2:route 3:route > {0 = TILEMAP 2 2 0:route 1:floor 2:route 3:route} 6 | rule: continueRoute3(height=3) = TILEMAP 1 3 0:floor 1:route 2:route > {0 = TILEMAP 1 3 0:route 1:route 2:route} 7 | -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/dungeonVar3/m4.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 1 1 0:undefined 3 | rule: startRoute(width=2) = TILEMAP 2 1 0:floor 1:wall > {0 = TILEMAP 2 1 0:route 1:wall} 4 | rule: continueRoute(width=5) = TILEMAP 5 1 0:floor 1:floor 2:floor 3:route 4:wall > {0 = TILEMAP 5 1 0:floor 1:floor 2:route 3:route 4:wall} | {1 = TILEMAP 5 1 0:floor 1:route 2:route 3:route 4:wall} | {2 = TILEMAP 5 1 0:route 1:route 2:route 3:route 4:wall} 5 | rule: continueRoute2(width=2, height=2) = TILEMAP 2 2 0:floor 1:floor 2:route 3:route > {0 = TILEMAP 2 2 0:route 1:floor 2:route 3:route} 6 | rule: continueRoute3(height=3) = TILEMAP 1 3 0:floor 1:route 2:route > {0 = TILEMAP 1 3 0:route 1:route 2:route} 7 | -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/isolatedAlphabets/mixedSymbols.alp: -------------------------------------------------------------------------------- 1 | TILEMAP 1 1 2 | *(color=#404040, fill=#B0B0B0) 3 | undefined(color=#404040, fill=#B0B0B0, abbreviation="u") 4 | open(color=#000000, fill=#FFFFFF, abbreviation="") 5 | PathToSite(color=#000000, fill=#FFFF60, abbreviation="P") 6 | entrance(color=#FFFFFF, fill=#00C000, abbreviation="e", shape=3) 7 | barrier(color=#FFFFFF, fill=#C00000, abbreviation="b") 8 | barrierEdge(color=#FFFFFF, fill=#C00000, abbreviation="e") 9 | spot(color=#FFFFFF, fill=#0000C0, abbreviation="s", shape=3) 10 | spawnLocation(color=#FFFFFF, fill=#C00000, abbreviation="s", shape=3) 11 | terrainA(color=#00FF00, fill=#008000, abbreviation="A") 12 | dirt(color=#000000, fill=#907040, abbreviation="") -------------------------------------------------------------------------------- /LL/src/visual/projects/dungeon/dungeon.lsp: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | alphabet: 3 | name: "Alphabet1" 4 | position: (-15,-117) 5 | 6 | module: 7 | name: "m2" 8 | alphabet: "Alphabet1" 9 | position: (14,90) 10 | type: Recipe 11 | match: None 12 | inputs: "m1" 13 | grammar: true 14 | recipe: true 15 | showMembers: true 16 | 17 | module: 18 | name: "m1" 19 | alphabet: "Alphabet1" 20 | position: (-111,93) 21 | type: Grammar 22 | match: None 23 | maxIterations: 1 24 | grammar: true 25 | showMembers: true 26 | 27 | module: 28 | name: "m3" 29 | alphabet: "Alphabet1" 30 | position: (122,94) 31 | type: Recipe 32 | match: None 33 | inputs: "m2" 34 | grammar: true 35 | recipe: true 36 | showMembers: true 37 | 38 | option: Width 6 39 | option: Height 6 40 | option: Tile "floor" -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/dungeon/dungeon.lsp: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | alphabet: 3 | name: "Alphabet1" 4 | position: (-15,-117) 5 | 6 | module: 7 | name: "m2" 8 | alphabet: "Alphabet1" 9 | position: (14,90) 10 | type: Recipe 11 | match: None 12 | inputs: "m1" 13 | grammar: true 14 | recipe: true 15 | showMembers: true 16 | 17 | module: 18 | name: "m1" 19 | alphabet: "Alphabet1" 20 | position: (-111,93) 21 | type: Grammar 22 | match: None 23 | maxIterations: 1 24 | grammar: true 25 | showMembers: true 26 | 27 | module: 28 | name: "m3" 29 | alphabet: "Alphabet1" 30 | position: (122,94) 31 | type: Recipe 32 | match: None 33 | inputs: "m2" 34 | grammar: true 35 | recipe: true 36 | showMembers: true 37 | 38 | option: Width 6 39 | option: Height 6 40 | option: Tile "floor" 41 | -------------------------------------------------------------------------------- /LL/src/visual/projects/v1/PickVariables.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 1 1 0:undefined 3 | rule: PickDirtOrSpace = TILEMAP 1 1 0:dirtOrSpace > {0 = TILEMAP 1 1 0:dirt} | {1 = TILEMAP 1 1 0:space} 4 | rule: PickDiamondOrBoulder = TILEMAP 1 1 0:diamondOrBoulder > {0 = TILEMAP 1 1 0:diamond} | {1 = TILEMAP 1 1 0:boulder} 5 | rule: PickDirtOrDiamond = TILEMAP 1 1 0:dirtOrDiamond > {0 = TILEMAP 1 1 0:dirt} | {1 = TILEMAP 1 1 0:diamond} 6 | rule: PickFireFlyOrButterfly = TILEMAP 1 1 0:fireflyOrButterfly > {0 = TILEMAP 1 1 0:dirt} | {1 = TILEMAP 1 1 0:diamond} 7 | rule: PickBrickOrMagic = TILEMAP 1 1 0:brickOrMagic > {0 = TILEMAP 1 1 0:brick} | {1 = TILEMAP 1 1 0:magic} 8 | rule: PickDirtOrBoulder = TILEMAP 1 1 0:dirtOrBoulder > {0 = TILEMAP 1 1 0:dirt} | {1 = TILEMAP 1 1 0:boulder} 9 | -------------------------------------------------------------------------------- /LL/src/visual/projects/v3/PickVariables.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 1 1 0:undefined 3 | rule: PickDirtOrSpace = TILEMAP 1 1 0:dirtOrSpace > {0 = TILEMAP 1 1 0:dirt} | {1 = TILEMAP 1 1 0:space} 4 | rule: PickDiamondOrBoulder = TILEMAP 1 1 0:diamondOrBoulder > {0 = TILEMAP 1 1 0:diamond} | {1 = TILEMAP 1 1 0:boulder} 5 | rule: PickDirtOrDiamond = TILEMAP 1 1 0:dirtOrDiamond > {0 = TILEMAP 1 1 0:dirt} | {1 = TILEMAP 1 1 0:diamond} 6 | rule: PickFireFlyOrButterfly = TILEMAP 1 1 0:fireflyOrButterfly > {0 = TILEMAP 1 1 0:dirt} | {1 = TILEMAP 1 1 0:diamond} 7 | rule: PickBrickOrMagic = TILEMAP 1 1 0:brickOrMagic > {0 = TILEMAP 1 1 0:brick} | {1 = TILEMAP 1 1 0:magic} 8 | rule: PickDirtOrBoulder = TILEMAP 1 1 0:dirtOrBoulder > {0 = TILEMAP 1 1 0:dirt} | {1 = TILEMAP 1 1 0:boulder} 9 | -------------------------------------------------------------------------------- /LL/src/visual/projects/v4/PickVariables.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 1 1 0:undefined 3 | rule: PickDirtOrSpace = TILEMAP 1 1 0:dirtOrSpace > {0 = TILEMAP 1 1 0:dirt} | {1 = TILEMAP 1 1 0:space} 4 | rule: PickDiamondOrBoulder = TILEMAP 1 1 0:diamondOrBoulder > {0 = TILEMAP 1 1 0:diamond} | {1 = TILEMAP 1 1 0:boulder} 5 | rule: PickDirtOrDiamond = TILEMAP 1 1 0:dirtOrDiamond > {0 = TILEMAP 1 1 0:dirt} | {1 = TILEMAP 1 1 0:diamond} 6 | rule: PickFireFlyOrButterfly = TILEMAP 1 1 0:fireflyOrButterfly > {0 = TILEMAP 1 1 0:dirt} | {1 = TILEMAP 1 1 0:diamond} 7 | rule: PickBrickOrMagic = TILEMAP 1 1 0:brickOrMagic > {0 = TILEMAP 1 1 0:brick} | {1 = TILEMAP 1 1 0:magic} 8 | rule: PickDirtOrBoulder = TILEMAP 1 1 0:dirtOrBoulder > {0 = TILEMAP 1 1 0:dirt} | {1 = TILEMAP 1 1 0:boulder} 9 | -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/isolatedGrammars/allMemberTypes.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 1 1 0:undefined 3 | rule: RuleName = TILEMAP 1 1 0:undefined(setting==false) > {0 = TILEMAP 1 1 0:undefined(setting=true)} 4 | rule: RuleName = TILEMAP 1 1 0:undefined(setting==5) > {0 = TILEMAP 1 1 0:undefined(setting=-5)} 5 | rule: RuleName = TILEMAP 1 1 0:undefined(setting==-1.2f) > {0 = TILEMAP 1 1 0:undefined(setting=1.2f)} 6 | rule: RuleName = TILEMAP 1 1 0:undefined(setting==#FFFFFF) > {0 = TILEMAP 1 1 0:undefined(setting=#000000)} 7 | rule: RuleName = TILEMAP 1 1 0:undefined(setting==(1,2,3)) > {0 = TILEMAP 1 1 0:undefined(setting=(3,2,1))} 8 | rule: RuleName = TILEMAP 1 1 0:undefined(settings==["string", 1, 2, 3, true]) > {0 = TILEMAP 1 1 0:undefined(setting=["otherString", 3, 2, 1, false])} -------------------------------------------------------------------------------- /LL/src/analysis/sanrWrapper/PropertyToText.rsc: -------------------------------------------------------------------------------- 1 | module analysis::sanrWrapper::PropertyToText 2 | 3 | import sanr::language::AST; 4 | 5 | public str propertyToText(Property property) 6 | { 7 | str condition = ""; 8 | str tile = ""; 9 | str filterNow = ""; 10 | str filterWhere = ""; 11 | 12 | visit(property) { 13 | case exact(int size): condition = "x "; 14 | case atLeast(int size): condition = "at least x "; 15 | case atMost(int size): condition = "at most x "; 16 | case tileSet(str tileName, FilterNow filterNow, FilterWhere filterWhere): tile = tileName; 17 | case nowAdjacent(str tileName): filterNow = " adjacent to "; 18 | case everRule(str ruleName): filterWhere = " in "; 19 | }; 20 | 21 | return condition + tile + filterNow + filterWhere; 22 | } -------------------------------------------------------------------------------- /LL/src/errors/Execution.rsc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Execution errors 4 | // @brief This file contains data types for execution errors. 5 | // @contributor Quinten Heijn - samuel.heijn@gmail.com - UvA 6 | // @date 01-05-2018 7 | // 8 | ////////////////////////////////////////////////////////////////////////////// 9 | 10 | module errors::Execution 11 | 12 | data ExecutionError 13 | = moduleConnection(list[str] moduleNames); 14 | 15 | str errorToString(moduleConnection(list[str] moduleNames)) 16 | { 17 | str errorMessage = "Execution error: the following modules didn\'t get an input:"; 18 | for (str moduleName <- moduleNames) 19 | { 20 | errorMessage += "\n "; 21 | } 22 | 23 | return errorMessage; 24 | } -------------------------------------------------------------------------------- /LL/src/visual/projects/v2/PickVariables.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 1 1 0:undefined 3 | rule: PickDirtOrSpace = TILEMAP 1 1 0:dirtOrSpace > {0 = TILEMAP 1 1 0:dirt} | {1 = TILEMAP 1 1 0:space} 4 | rule: PickDiamondOrBoulder = TILEMAP 1 1 0:diamondOrBoulder > {0 = TILEMAP 1 1 0:diamond} | {1 = TILEMAP 1 1 0:boulder} | {2 = TILEMAP 1 1 0:boulder} 5 | rule: PickDirtOrDiamond = TILEMAP 1 1 0:dirtOrDiamond > {0 = TILEMAP 1 1 0:dirt} | {1 = TILEMAP 1 1 0:diamond} | {2 = TILEMAP 1 1 0:dirt} 6 | rule: PickFireFlyOrButterfly = TILEMAP 1 1 0:fireflyOrButterfly > {0 = TILEMAP 1 1 0:dirt} | {1 = TILEMAP 1 1 0:diamond} 7 | rule: PickBrickOrMagic = TILEMAP 1 1 0:brickOrMagic > {0 = TILEMAP 1 1 0:brick} | {1 = TILEMAP 1 1 0:magic} 8 | rule: PickDirtOrBoulder = TILEMAP 1 1 0:dirtOrBoulder > {0 = TILEMAP 1 1 0:dirt} | {1 = TILEMAP 1 1 0:boulder} 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | LUDOSCOPE LITE 2 | ================================================================================ 3 | 4 | Project Description 5 | -------------------------------------------------------------------------------- 6 | Ludoscope Lite is an implementation of Ludoscope in Rascal. The aim of this 7 | project is to make a version of Ludoscope that is easy to understand and 8 | that allows for quick protoyping. 9 | 10 | 11 | How to use 12 | -------------------------------------------------------------------------------- 13 | The IDE can be loaded by running 'LoadIDE.rsc' in eclipse. Once the IDE is 14 | loaded, Ludoscope project files (.lsp) can be executed from the impluse editor 15 | in the right click menu. 16 | 17 | Dependencies 18 | ------------------------------------------------------------------------------- 19 | - MAD metric (GitHub link will be added here). 20 | -------------------------------------------------------------------------------- /LL/src/visual/projects/v1/AddVariation.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 1 1 0:undefined 3 | rule: SwapSpaceAndDirt2x1(width=2, gt=2) = TILEMAP 2 1 0:dirt 1:space > {0 = TILEMAP 2 1 0:space 1:dirt} 4 | rule: SwapSpaceAndDirt2x2(width=2, height=2, gt=2) = TILEMAP 2 2 0:dirt 1:dirt 2:space 3:dirt > {0 = TILEMAP 2 2 0:dirt 1:dirt 2:dirt 3:space} 5 | rule: SwapDiamond(width=2, gt=1) = TILEMAP 2 1 0:boulder 1:diamond > {0 = TILEMAP 2 1 0:diamond 1:boulder} 6 | rule: ReplaceDirt(width=4, height=3, gt=7) = TILEMAP 4 3 0:dirt 1:dirt 2:dirt 3:dirt 4:dirt 5:dirt 6:dirt 7:dirt 8:dirt 9:dirt 10:dirt 11:dirt > {0 = TILEMAP 4 3 0:dirt 1:dirt 2:dirt 3:dirt 4:dirt 5:space 6:dirt 7:dirt 8:dirt 9:dirt 10:dirt 11:dirt} | {1 = TILEMAP 4 3 0:dirt 1:dirt 2:dirt 3:dirt 4:dirt 5:diamond 6:dirt 7:dirt 8:dirt 9:dirt 10:dirt 11:dirt} | {2 = TILEMAP 4 3 0:dirt 1:dirt 2:dirt 3:dirt 4:dirt 5:brick 6:dirt 7:dirt 8:dirt 9:dirt 10:dirt 11:dirt} 7 | -------------------------------------------------------------------------------- /LL/src/visual/projects/v2/AddVariation.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 1 1 0:undefined 3 | rule: SwapSpaceAndDirt2x1(width=2, gt=2) = TILEMAP 2 1 0:dirt 1:space > {0 = TILEMAP 2 1 0:space 1:dirt} 4 | rule: SwapSpaceAndDirt2x2(width=2, height=2, gt=2) = TILEMAP 2 2 0:dirt 1:dirt 2:space 3:dirt > {0 = TILEMAP 2 2 0:dirt 1:dirt 2:dirt 3:space} 5 | rule: SwapDiamond(width=2, gt=1) = TILEMAP 2 1 0:boulder 1:diamond > {0 = TILEMAP 2 1 0:diamond 1:boulder} 6 | rule: ReplaceDirt(width=4, height=3, gt=7) = TILEMAP 4 3 0:dirt 1:dirt 2:dirt 3:dirt 4:dirt 5:dirt 6:dirt 7:dirt 8:dirt 9:dirt 10:dirt 11:dirt > {0 = TILEMAP 4 3 0:dirt 1:dirt 2:dirt 3:dirt 4:dirt 5:space 6:dirt 7:dirt 8:dirt 9:dirt 10:dirt 11:dirt} | {1 = TILEMAP 4 3 0:dirt 1:dirt 2:dirt 3:dirt 4:dirt 5:diamond 6:dirt 7:dirt 8:dirt 9:dirt 10:dirt 11:dirt} | {2 = TILEMAP 4 3 0:dirt 1:dirt 2:dirt 3:dirt 4:dirt 5:brick 6:dirt 7:dirt 8:dirt 9:dirt 10:dirt 11:dirt} 7 | -------------------------------------------------------------------------------- /LL/src/visual/projects/v3/AddVariation.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 1 1 0:undefined 3 | rule: SwapSpaceAndDirt2x1(width=2, gt=2) = TILEMAP 2 1 0:dirt 1:space > {0 = TILEMAP 2 1 0:space 1:dirt} 4 | rule: SwapSpaceAndDirt2x2(width=2, height=2, gt=2) = TILEMAP 2 2 0:dirt 1:dirt 2:space 3:dirt > {0 = TILEMAP 2 2 0:dirt 1:dirt 2:dirt 3:space} 5 | rule: SwapDiamond(width=2, gt=1) = TILEMAP 2 1 0:boulder 1:diamond > {0 = TILEMAP 2 1 0:diamond 1:boulder} 6 | rule: ReplaceDirt(width=4, height=3, gt=7) = TILEMAP 4 3 0:dirt 1:dirt 2:dirt 3:dirt 4:dirt 5:dirt 6:dirt 7:dirt 8:dirt 9:dirt 10:dirt 11:dirt > {0 = TILEMAP 4 3 0:dirt 1:dirt 2:dirt 3:dirt 4:dirt 5:space 6:dirt 7:dirt 8:dirt 9:dirt 10:dirt 11:dirt} | {1 = TILEMAP 4 3 0:dirt 1:dirt 2:dirt 3:dirt 4:dirt 5:diamond 6:dirt 7:dirt 8:dirt 9:dirt 10:dirt 11:dirt} | {2 = TILEMAP 4 3 0:dirt 1:dirt 2:dirt 3:dirt 4:dirt 5:brick 6:dirt 7:dirt 8:dirt 9:dirt 10:dirt 11:dirt} 7 | -------------------------------------------------------------------------------- /LL/src/visual/projects/v4/AddVariation.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 1 1 0:undefined 3 | rule: SwapSpaceAndDirt2x1(width=2, gt=2) = TILEMAP 2 1 0:dirt 1:space > {0 = TILEMAP 2 1 0:space 1:dirt} 4 | rule: SwapSpaceAndDirt2x2(width=2, height=2, gt=2) = TILEMAP 2 2 0:dirt 1:dirt 2:space 3:dirt > {0 = TILEMAP 2 2 0:dirt 1:dirt 2:dirt 3:space} 5 | rule: SwapDiamond(width=2, gt=1) = TILEMAP 2 1 0:boulder 1:diamond > {0 = TILEMAP 2 1 0:diamond 1:boulder} 6 | rule: ReplaceDirt(width=4, height=3, gt=7) = TILEMAP 4 3 0:dirt 1:dirt 2:dirt 3:dirt 4:dirt 5:dirt 6:dirt 7:dirt 8:dirt 9:dirt 10:dirt 11:dirt > {0 = TILEMAP 4 3 0:dirt 1:dirt 2:dirt 3:dirt 4:dirt 5:space 6:dirt 7:dirt 8:dirt 9:dirt 10:dirt 11:dirt} | {1 = TILEMAP 4 3 0:dirt 1:dirt 2:dirt 3:dirt 4:dirt 5:boulder 6:dirt 7:dirt 8:dirt 9:dirt 10:dirt 11:dirt} | {2 = TILEMAP 4 3 0:dirt 1:dirt 2:dirt 3:dirt 4:dirt 5:brick 6:dirt 7:dirt 8:dirt 9:dirt 10:dirt 11:dirt} 7 | -------------------------------------------------------------------------------- /LL/src/visual/projects/dungeonVar1/dungeon.lsp: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | alphabet: 3 | name: "Alphabet1" 4 | position: (-20,-106) 5 | 6 | module: 7 | name: "m2" 8 | alphabet: "Alphabet1" 9 | position: (8,102) 10 | type: Recipe 11 | match: None 12 | inputs: "m1" 13 | grammar: true 14 | recipe: true 15 | showMembers: true 16 | 17 | module: 18 | name: "m1" 19 | alphabet: "Alphabet1" 20 | position: (-116,104) 21 | type: Grammar 22 | match: None 23 | maxIterations: 1 24 | grammar: true 25 | showMembers: true 26 | 27 | module: 28 | name: "m3" 29 | alphabet: "Alphabet1" 30 | position: (116,106) 31 | type: Recipe 32 | match: None 33 | inputs: "m2" 34 | grammar: true 35 | recipe: true 36 | showMembers: true 37 | 38 | module: 39 | name: "m4" 40 | alphabet: "Alphabet1" 41 | position: (248,108) 42 | type: Grammar 43 | match: None 44 | inputs: "m3" 45 | grammar: true 46 | showMembers: true 47 | 48 | option: Width 6 49 | option: Height 6 50 | option: Tile "floor" 51 | -------------------------------------------------------------------------------- /LL/src/visual/projects/dungeonVar2/dungeon.lsp: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | alphabet: 3 | name: "Alphabet1" 4 | position: (-82,-106) 5 | 6 | module: 7 | name: "m2" 8 | alphabet: "Alphabet1" 9 | position: (-54,102) 10 | type: Recipe 11 | match: None 12 | inputs: "m1" 13 | grammar: true 14 | recipe: true 15 | showMembers: true 16 | 17 | module: 18 | name: "m1" 19 | alphabet: "Alphabet1" 20 | position: (-178,104) 21 | type: Grammar 22 | match: None 23 | maxIterations: 1 24 | grammar: true 25 | showMembers: true 26 | 27 | module: 28 | name: "m3" 29 | alphabet: "Alphabet1" 30 | position: (54,106) 31 | type: Recipe 32 | match: None 33 | inputs: "m2" 34 | grammar: true 35 | recipe: true 36 | showMembers: true 37 | 38 | module: 39 | name: "m4" 40 | alphabet: "Alphabet1" 41 | position: (178,100) 42 | type: Grammar 43 | match: None 44 | inputs: "m3" 45 | grammar: true 46 | showMembers: true 47 | 48 | option: Width 6 49 | option: Height 6 50 | option: Tile "floor" 51 | -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/dungeonVar1/dungeon.lsp: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | alphabet: 3 | name: "Alphabet1" 4 | position: (-20,-106) 5 | 6 | module: 7 | name: "m2" 8 | alphabet: "Alphabet1" 9 | position: (8,102) 10 | type: Recipe 11 | match: None 12 | inputs: "m1" 13 | grammar: true 14 | recipe: true 15 | showMembers: true 16 | 17 | module: 18 | name: "m1" 19 | alphabet: "Alphabet1" 20 | position: (-116,104) 21 | type: Grammar 22 | match: None 23 | maxIterations: 1 24 | grammar: true 25 | showMembers: true 26 | 27 | module: 28 | name: "m3" 29 | alphabet: "Alphabet1" 30 | position: (116,106) 31 | type: Recipe 32 | match: None 33 | inputs: "m2" 34 | grammar: true 35 | recipe: true 36 | showMembers: true 37 | 38 | module: 39 | name: "m4" 40 | alphabet: "Alphabet1" 41 | position: (248,108) 42 | type: Grammar 43 | match: None 44 | inputs: "m3" 45 | grammar: true 46 | showMembers: true 47 | 48 | option: Width 6 49 | option: Height 6 50 | option: Tile "floor" 51 | -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/dungeonVar2/dungeon.lsp: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | alphabet: 3 | name: "Alphabet1" 4 | position: (-82,-106) 5 | 6 | module: 7 | name: "m2" 8 | alphabet: "Alphabet1" 9 | position: (-54,102) 10 | type: Recipe 11 | match: None 12 | inputs: "m1" 13 | grammar: true 14 | recipe: true 15 | showMembers: true 16 | 17 | module: 18 | name: "m1" 19 | alphabet: "Alphabet1" 20 | position: (-178,104) 21 | type: Grammar 22 | match: None 23 | maxIterations: 1 24 | grammar: true 25 | showMembers: true 26 | 27 | module: 28 | name: "m3" 29 | alphabet: "Alphabet1" 30 | position: (54,106) 31 | type: Recipe 32 | match: None 33 | inputs: "m2" 34 | grammar: true 35 | recipe: true 36 | showMembers: true 37 | 38 | module: 39 | name: "m4" 40 | alphabet: "Alphabet1" 41 | position: (178,100) 42 | type: Grammar 43 | match: None 44 | inputs: "m3" 45 | grammar: true 46 | showMembers: true 47 | 48 | option: Width 6 49 | option: Height 6 50 | option: Tile "floor" 51 | -------------------------------------------------------------------------------- /LL/src/utility/String.rsc: -------------------------------------------------------------------------------- 1 | module utility::String 2 | 3 | import String; 4 | 5 | public str removeQuotes(str string) 6 | { 7 | return string[1..-1]; 8 | } 9 | 10 | public str cleanGrammarName(str name) 11 | { 12 | return removeQuotes(name[6..]); 13 | } 14 | 15 | public str cleanContainerName(str name) 16 | { 17 | return name[3..]; 18 | } 19 | 20 | public str cleanAlphabetName(str name) 21 | { 22 | return removeQuotes(name[10..]); 23 | } 24 | 25 | public str cleanRecipeBool(str text) 26 | { 27 | return text[8..]; 28 | } 29 | 30 | public loc fileLocation(loc projectLocation, str filename, str extension) 31 | { 32 | return projectLocation.parent + (filename + extension); 33 | } 34 | 35 | public str fileName(loc file) 36 | { 37 | int extensionLength = size(file.extension); 38 | str fileName = file.file; 39 | int lengthOfDot = 1; 40 | int endFileName = size(fileName) - extensionLength - lengthOfDot; 41 | return fileName[0 .. endFileName]; 42 | } -------------------------------------------------------------------------------- /LL/src/visual/projects/dungeonVar3/dungeon.lsp: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | alphabet: 3 | name: "Alphabet1" 4 | position: (44,-106) 5 | 6 | module: 7 | name: "m2" 8 | alphabet: "Alphabet1" 9 | position: (50,101) 10 | type: Recipe 11 | match: None 12 | inputs: "m4" 13 | grammar: true 14 | recipe: true 15 | showMembers: true 16 | 17 | module: 18 | name: "m1" 19 | alphabet: "Alphabet1" 20 | position: (-180,95) 21 | type: Grammar 22 | match: None 23 | maxIterations: 1 24 | grammar: true 25 | showMembers: true 26 | 27 | module: 28 | name: "m3" 29 | alphabet: "Alphabet1" 30 | position: (180,106) 31 | type: Recipe 32 | match: None 33 | inputs: "m2" 34 | grammar: true 35 | recipe: true 36 | showMembers: true 37 | 38 | module: 39 | name: "m4" 40 | alphabet: "Alphabet1" 41 | position: (-66,102) 42 | type: Recipe 43 | match: None 44 | inputs: "m1" 45 | grammar: true 46 | recipe: true 47 | showMembers: true 48 | 49 | option: Width 6 50 | option: Height 6 51 | option: Tile "floor" 52 | -------------------------------------------------------------------------------- /LL/src/parsing/transformations/Properties.rsc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Transform properties 4 | // @brief Functions that move the relevant content from the AST to 5 | // a new ADT declared in DataStructures.rsc. 6 | // @contributor Quinten Heijn - samuel.heijn@gmail.com - UvA 7 | // @date 23-04-2018 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | module parsing::transformations::Properties 12 | 13 | import parsing::Parser; 14 | import parsing::DataStructures; 15 | import sanr::language::AST; 16 | 17 | public TransformationArtifact transformProperties 18 | ( 19 | TransformationArtifact artifact, 20 | SyntaxTree syntaxTree 21 | ) 22 | { 23 | visit(syntaxTree) 24 | { 25 | case LevelSpecification specification: 26 | { 27 | artifact.project.specification = specification; 28 | } 29 | } 30 | return artifact; 31 | } 32 | -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/dungeonVar3/dungeon.lsp: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | alphabet: 3 | name: "Alphabet1" 4 | position: (44,-106) 5 | 6 | module: 7 | name: "m2" 8 | alphabet: "Alphabet1" 9 | position: (50,101) 10 | type: Recipe 11 | match: None 12 | inputs: "m4" 13 | grammar: true 14 | recipe: true 15 | showMembers: true 16 | 17 | module: 18 | name: "m1" 19 | alphabet: "Alphabet1" 20 | position: (-180,95) 21 | type: Grammar 22 | match: None 23 | maxIterations: 1 24 | grammar: true 25 | showMembers: true 26 | 27 | module: 28 | name: "m3" 29 | alphabet: "Alphabet1" 30 | position: (180,106) 31 | type: Recipe 32 | match: None 33 | inputs: "m2" 34 | grammar: true 35 | recipe: true 36 | showMembers: true 37 | 38 | module: 39 | name: "m4" 40 | alphabet: "Alphabet1" 41 | position: (-66,102) 42 | type: Recipe 43 | match: None 44 | inputs: "m1" 45 | grammar: true 46 | recipe: true 47 | showMembers: true 48 | 49 | option: Width 6 50 | option: Height 6 51 | option: Tile "floor" 52 | -------------------------------------------------------------------------------- /LL/src/visual/projects/dungeon/m1.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 6 6 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 3 | rule: addWalls(width=6, height=6) = TILEMAP 6 6 0:floor 1:floor 2:floor 3:floor 4:floor 5:floor 6:floor 7:floor 8:floor 9:floor 10:floor 11:floor 12:floor 13:floor 14:floor 15:floor 16:floor 17:floor 18:floor 19:floor 20:floor 21:floor 22:floor 23:floor 24:floor 25:floor 26:floor 27:floor 28:floor 29:floor 30:floor 31:floor 32:floor 33:floor 34:floor 35:floor > {0 = TILEMAP 6 6 0:wall 1:wall 2:wall 3:wall 4:wall 5:wall 6:wall 7:floor 8:floor 9:floor 10:floor 11:wall 12:wall 13:floor 14:floor 15:floor 16:floor 17:wall 18:wall 19:floor 20:floor 21:floor 22:floor 23:wall 24:wall 25:floor 26:floor 27:floor 28:floor 29:wall 30:wall 31:wall 32:wall 33:wall 34:wall 35:wall} -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/dungeon/m1.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 6 6 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 3 | rule: addWalls(width=6, height=6) = TILEMAP 6 6 0:floor 1:floor 2:floor 3:floor 4:floor 5:floor 6:floor 7:floor 8:floor 9:floor 10:floor 11:floor 12:floor 13:floor 14:floor 15:floor 16:floor 17:floor 18:floor 19:floor 20:floor 21:floor 22:floor 23:floor 24:floor 25:floor 26:floor 27:floor 28:floor 29:floor 30:floor 31:floor 32:floor 33:floor 34:floor 35:floor > {0 = TILEMAP 6 6 0:wall 1:wall 2:wall 3:wall 4:wall 5:wall 6:wall 7:floor 8:floor 9:floor 10:floor 11:wall 12:wall 13:floor 14:floor 15:floor 16:floor 17:wall 18:wall 19:floor 20:floor 21:floor 22:floor 23:wall 24:wall 25:floor 26:floor 27:floor 28:floor 29:wall 30:wall 31:wall 32:wall 33:wall 34:wall 35:wall} 4 | -------------------------------------------------------------------------------- /LL/src/tests/parsing/Utility.rsc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Utility functions 4 | // @brief This file contains functions that are needed to test parsing. 5 | // @contributor Quinten Heijn - samuel.heijn@gmail.com - UvA 6 | // @date 24-04-2018 7 | // 8 | ////////////////////////////////////////////////////////////////////////////// 9 | 10 | module tests::parsing::Utility 11 | 12 | import IO; 13 | import List; 14 | import errors::Parsing; 15 | import parsing::Parser; 16 | import parsing::DataStructures; 17 | 18 | public bool checkErrors(SyntaxTree syntaxTree) 19 | { 20 | for (ParsingError error <- syntaxTree.errors) 21 | { 22 | println(errorToString(error)); 23 | } 24 | return (size(syntaxTree.errors) == 0); 25 | } 26 | 27 | public bool checkErrors(TransformationArtifact artifact) 28 | { 29 | for (ParsingError error <- artifact.errors) 30 | { 31 | println(errorToString(error)); 32 | } 33 | return (size(artifact.errors) == 0); 34 | } -------------------------------------------------------------------------------- /LL/src/visual/projects/dungeonVar1/m1.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 6 6 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 3 | rule: addWalls(width=6, height=6) = TILEMAP 6 6 0:floor 1:floor 2:floor 3:floor 4:floor 5:floor 6:floor 7:floor 8:floor 9:floor 10:floor 11:floor 12:floor 13:floor 14:floor 15:floor 16:floor 17:floor 18:floor 19:floor 20:floor 21:floor 22:floor 23:floor 24:floor 25:floor 26:floor 27:floor 28:floor 29:floor 30:floor 31:floor 32:floor 33:floor 34:floor 35:floor > {0 = TILEMAP 6 6 0:wall 1:wall 2:wall 3:wall 4:wall 5:wall 6:wall 7:floor 8:floor 9:floor 10:floor 11:wall 12:wall 13:floor 14:floor 15:floor 16:floor 17:wall 18:wall 19:floor 20:floor 21:floor 22:floor 23:wall 24:wall 25:floor 26:floor 27:floor 28:floor 29:wall 30:wall 31:wall 32:wall 33:wall 34:wall 35:wall} 4 | -------------------------------------------------------------------------------- /LL/src/visual/projects/dungeonVar2/m1.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 6 6 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 3 | rule: addWalls(width=6, height=6) = TILEMAP 6 6 0:floor 1:floor 2:floor 3:floor 4:floor 5:floor 6:floor 7:floor 8:floor 9:floor 10:floor 11:floor 12:floor 13:floor 14:floor 15:floor 16:floor 17:floor 18:floor 19:floor 20:floor 21:floor 22:floor 23:floor 24:floor 25:floor 26:floor 27:floor 28:floor 29:floor 30:floor 31:floor 32:floor 33:floor 34:floor 35:floor > {0 = TILEMAP 6 6 0:wall 1:wall 2:wall 3:wall 4:wall 5:wall 6:wall 7:floor 8:floor 9:floor 10:floor 11:wall 12:wall 13:floor 14:floor 15:floor 16:floor 17:wall 18:wall 19:floor 20:floor 21:floor 22:floor 23:wall 24:wall 25:floor 26:floor 27:floor 28:floor 29:wall 30:wall 31:wall 32:wall 33:wall 34:wall 35:wall} 4 | -------------------------------------------------------------------------------- /LL/src/visual/projects/dungeonVar3/m1.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 6 6 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 3 | rule: addWalls(width=6, height=6) = TILEMAP 6 6 0:floor 1:floor 2:floor 3:floor 4:floor 5:floor 6:floor 7:floor 8:floor 9:floor 10:floor 11:floor 12:floor 13:floor 14:floor 15:floor 16:floor 17:floor 18:floor 19:floor 20:floor 21:floor 22:floor 23:floor 24:floor 25:floor 26:floor 27:floor 28:floor 29:floor 30:floor 31:floor 32:floor 33:floor 34:floor 35:floor > {0 = TILEMAP 6 6 0:wall 1:wall 2:wall 3:wall 4:wall 5:wall 6:wall 7:floor 8:floor 9:floor 10:floor 11:wall 12:wall 13:floor 14:floor 15:floor 16:floor 17:wall 18:wall 19:floor 20:floor 21:floor 22:floor 23:wall 24:wall 25:floor 26:floor 27:floor 28:floor 29:wall 30:wall 31:wall 32:wall 33:wall 34:wall 35:wall} 4 | -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/dungeonVar1/m1.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 6 6 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 3 | rule: addWalls(width=6, height=6) = TILEMAP 6 6 0:floor 1:floor 2:floor 3:floor 4:floor 5:floor 6:floor 7:floor 8:floor 9:floor 10:floor 11:floor 12:floor 13:floor 14:floor 15:floor 16:floor 17:floor 18:floor 19:floor 20:floor 21:floor 22:floor 23:floor 24:floor 25:floor 26:floor 27:floor 28:floor 29:floor 30:floor 31:floor 32:floor 33:floor 34:floor 35:floor > {0 = TILEMAP 6 6 0:wall 1:wall 2:wall 3:wall 4:wall 5:wall 6:wall 7:floor 8:floor 9:floor 10:floor 11:wall 12:wall 13:floor 14:floor 15:floor 16:floor 17:wall 18:wall 19:floor 20:floor 21:floor 22:floor 23:wall 24:wall 25:floor 26:floor 27:floor 28:floor 29:wall 30:wall 31:wall 32:wall 33:wall 34:wall 35:wall} 4 | -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/dungeonVar2/m1.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 6 6 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 3 | rule: addWalls(width=6, height=6) = TILEMAP 6 6 0:floor 1:floor 2:floor 3:floor 4:floor 5:floor 6:floor 7:floor 8:floor 9:floor 10:floor 11:floor 12:floor 13:floor 14:floor 15:floor 16:floor 17:floor 18:floor 19:floor 20:floor 21:floor 22:floor 23:floor 24:floor 25:floor 26:floor 27:floor 28:floor 29:floor 30:floor 31:floor 32:floor 33:floor 34:floor 35:floor > {0 = TILEMAP 6 6 0:wall 1:wall 2:wall 3:wall 4:wall 5:wall 6:wall 7:floor 8:floor 9:floor 10:floor 11:wall 12:wall 13:floor 14:floor 15:floor 16:floor 17:wall 18:wall 19:floor 20:floor 21:floor 22:floor 23:wall 24:wall 25:floor 26:floor 27:floor 28:floor 29:wall 30:wall 31:wall 32:wall 33:wall 34:wall 35:wall} 4 | -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/dungeonVar3/m1.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 6 6 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 0:floor 3 | rule: addWalls(width=6, height=6) = TILEMAP 6 6 0:floor 1:floor 2:floor 3:floor 4:floor 5:floor 6:floor 7:floor 8:floor 9:floor 10:floor 11:floor 12:floor 13:floor 14:floor 15:floor 16:floor 17:floor 18:floor 19:floor 20:floor 21:floor 22:floor 23:floor 24:floor 25:floor 26:floor 27:floor 28:floor 29:floor 30:floor 31:floor 32:floor 33:floor 34:floor 35:floor > {0 = TILEMAP 6 6 0:wall 1:wall 2:wall 3:wall 4:wall 5:wall 6:wall 7:floor 8:floor 9:floor 10:floor 11:wall 12:wall 13:floor 14:floor 15:floor 16:floor 17:wall 18:wall 19:floor 20:floor 21:floor 22:floor 23:wall 24:wall 25:floor 26:floor 27:floor 28:floor 29:wall 30:wall 31:wall 32:wall 33:wall 34:wall 35:wall} 4 | -------------------------------------------------------------------------------- /LL/src/parsing/check/Interface.rsc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Check Interface 4 | // @brief Interface for all checks on the synstax tree and transformed 5 | // syntax tree. 6 | // @contributor Quinten Heijn - samuel.heijn@gmail.com - UvA 7 | // @date 28-04-2018 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | module parsing::check::Interface 12 | 13 | import parsing::Parser; 14 | import parsing::DataStructures; 15 | 16 | import parsing::check::Version; 17 | import parsing::check::Maps; 18 | import parsing::check::Names; 19 | 20 | public SyntaxTree checkSyntaxTree(SyntaxTree syntaxTree) 21 | { 22 | syntaxTree = checkVersion(syntaxTree); 23 | syntaxTree = checkMapTypes(syntaxTree); 24 | return syntaxTree; 25 | } 26 | 27 | public TransformationArtifact checkTransformationArtifact 28 | ( 29 | TransformationArtifact artifact 30 | ) 31 | { 32 | artifact = checkPropertyNames(artifact); 33 | return artifact; 34 | } -------------------------------------------------------------------------------- /LL/src/parsing/transformations/Alphabet.rsc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Transform Alphabet 4 | // @brief Functions that move the relevant content from the AST to 5 | // a new ADT declared in DataStructures.rsc. 6 | // @contributor Quinten Heijn - samuel.heijn@gmail.com - UvA 7 | // @date 23-04-2018 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | module parsing::transformations::Alphabet 12 | 13 | import parsing::languages::alphabet::AST; 14 | import parsing::DataStructures; 15 | import parsing::Parser; 16 | 17 | alias AbstractAlphabet = parsing::languages::alphabet::AST::Alphabet; 18 | 19 | public TransformationArtifact transformAplhabets(TransformationArtifact artifact, 20 | SyntaxTree syntaxTree) 21 | { 22 | for (str fileName <- syntaxTree.alphabets) 23 | { 24 | AbstractAlphabet abstractAlphabet = syntaxTree.alphabets[fileName]; 25 | artifact.project.alphabets += (fileName : abstractAlphabet); 26 | } 27 | return artifact; 28 | } 29 | -------------------------------------------------------------------------------- /LL/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | LL 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | rascal_eclipse.rascal_builder 15 | 16 | 17 | 18 | 19 | rascal_eclipse.term_builder 20 | 21 | 22 | 23 | 24 | org.eclipse.pde.ManifestBuilder 25 | 26 | 27 | 28 | 29 | org.eclipse.pde.SchemaBuilder 30 | 31 | 32 | 33 | 34 | 35 | rascal_eclipse.rascal_nature 36 | org.eclipse.jdt.core.javanature 37 | org.eclipse.pde.PluginNature 38 | rascal_eclipse.term_nature 39 | 40 | 41 | -------------------------------------------------------------------------------- /LL/src/parsing/Interface.rsc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Interface for parsing 4 | // @brief Interface for parsing and transforming LL projects. 5 | // @contributor Quinten Heijn - samuel.heijn@gmail.com - UvA 6 | // @date 23-04-2018 7 | // 8 | ////////////////////////////////////////////////////////////////////////////// 9 | 10 | module parsing::Interface 11 | 12 | import List; 13 | import parsing::Parser; 14 | import parsing::DataStructures; 15 | import parsing::transformations::CompleteSyntaxTree; 16 | import parsing::check::Interface; 17 | 18 | public TransformationArtifact parseAndTransform(loc projectFile) 19 | { 20 | TransformationArtifact artifact = transformationArtifact(undefinedProject(), []); 21 | SyntaxTree syntaxTree = parseCompleteProject(projectFile); 22 | syntaxTree = checkSyntaxTree(syntaxTree); 23 | 24 | if (size(syntaxTree.errors) == 0) 25 | { 26 | artifact = transformSyntaxTree(syntaxTree); 27 | artifact = checkTransformationArtifact(artifact); 28 | } 29 | else 30 | { 31 | artifact.errors = syntaxTree.errors; 32 | } 33 | 34 | return artifact; 35 | } -------------------------------------------------------------------------------- /LL/src/parsing/transformations/Instruction.rsc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Transform Instructions 4 | // @brief Functions that replace the AST constructor with a new 5 | // constructor from DataStructures.rsc. 6 | // @contributor Quinten Heijn - samuel.heijn@gmail.com - UvA 7 | // @date 23-04-2018 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | module parsing::transformations::Instruction 12 | 13 | import List; 14 | import parsing::DataStructures; 15 | import parsing::languages::recipe::AST; 16 | import utility::String; 17 | 18 | alias AbstractInstruction = parsing::languages::recipe::AST::Instruction; 19 | 20 | public Instruction parseInstruction 21 | ( 22 | TransformationArtifact artifact, 23 | iterateRule(bool commented, str ruleName) 24 | ) 25 | { 26 | return itterateRule(removeQuotes(ruleName)); 27 | } 28 | 29 | public Instruction parseInstruction 30 | ( 31 | TransformationArtifact artifact, 32 | executeRule(bool commented, str ruleName, int executions) 33 | ) 34 | { 35 | return executeRule(removeQuotes(ruleName), executions); 36 | } -------------------------------------------------------------------------------- /LL/src/utility/Time.rsc: -------------------------------------------------------------------------------- 1 | module utility::Time 2 | 3 | import DateTime; 4 | 5 | public Duration addDuration(Duration sum, Duration addition) 6 | { 7 | sum.years += addition.years; 8 | sum.months += addition.months; 9 | sum.days += addition.days; 10 | sum.hours += addition.hours; 11 | sum.minutes += addition.minutes; 12 | sum.seconds += addition.seconds; 13 | sum.milliseconds += addition.milliseconds; 14 | return sum; 15 | } 16 | 17 | public str durationToString(Duration time) 18 | { 19 | return "msms"; 20 | } 21 | 22 | public int durationToMilliseconds(Duration time) 23 | { 24 | return time.milliseconds + (time.seconds * 1000) + (time.minutes * 60000); 25 | } 26 | 27 | public Duration flattenDuration(Duration duration) 28 | { 29 | duration.seconds += duration.milliseconds / 1000; 30 | duration.milliseconds = duration.milliseconds % 1000; 31 | 32 | duration.minutes += duration.seconds / 60; 33 | duration.seconds = duration.seconds % 60; 34 | 35 | duration.hours += duration.minutes / 60; 36 | duration.minutes = duration.minutes % 60; 37 | 38 | duration.days += duration.hours / 24; 39 | duration.hours = duration.hours % 24; 40 | return duration; 41 | } -------------------------------------------------------------------------------- /LL/src/parsing/transformations/Utility.rsc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Utility functions 4 | // @brief Functions that help with the transformations. 5 | // @contributor Quinten Heijn - samuel.heijn@gmail.com - UvA 6 | // @date 23-04-2018 7 | // 8 | ////////////////////////////////////////////////////////////////////////////// 9 | 10 | module parsing::transformations::Utility 11 | 12 | import List; 13 | import parsing::DataStructures; 14 | 15 | public int findModuleIndex(str moduleName, TransformationArtifact artifact) 16 | { 17 | for (int i <- [0 .. size(artifact.project.modules)]) 18 | { 19 | if (artifact.project.modules[i].name == moduleName) 20 | { 21 | return i; 22 | } 23 | } 24 | } 25 | 26 | public list[bool] parseBitFlag(int bitFlag, int minimumSize) 27 | { 28 | list[bool] bitList = []; 29 | 30 | while (bitFlag != 0) 31 | { 32 | if (bitFlag % 2 == 1) 33 | { 34 | bitList += [true]; 35 | } 36 | else 37 | { 38 | bitList += [false]; 39 | } 40 | bitFlag = bitFlag / 2; 41 | } 42 | 43 | for (int i <- [size(bitList) .. minimumSize]) 44 | { 45 | bitList += [false]; 46 | } 47 | return bitList; 48 | } -------------------------------------------------------------------------------- /LL/src/parsing/check/Version.rsc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Check versions 4 | // @brief Function for checking the versions of project 5 | // and grammars files. 6 | // @contributor Quinten Heijn - samuel.heijn@gmail.com - UvA 7 | // @date 24-04-2018 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | module parsing::check::Version 12 | 13 | import parsing::languages::project::AST; 14 | import parsing::languages::grammar::AST; 15 | 16 | import parsing::Parser; 17 | import errors::Parsing; 18 | 19 | alias AbstractGrammar = parsing::languages::grammar::AST::Grammar; 20 | alias AbstractProject = parsing::languages::project::AST::Project; 21 | 22 | public SyntaxTree checkVersion(SyntaxTree syntaxTree) 23 | { 24 | for (AbstractProject abstractProject <- syntaxTree.project) 25 | { 26 | if (abstractProject.version != "0.6f") 27 | { 28 | syntaxTree.errors += [version(abstractProject.version)]; 29 | } 30 | } 31 | 32 | for (str grammarName <- syntaxTree.grammars) 33 | { 34 | AbstractGrammar abstractGrammar = syntaxTree.grammars[grammarName]; 35 | if (abstractGrammar.version != "0.6f") 36 | { 37 | syntaxTree.errors += [version(abstractGrammar.version)]; 38 | } 39 | } 40 | return syntaxTree; 41 | } 42 | -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/isolatedGrammars/onlyStart.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 10 10 0:undefined 1:undefined 2:undefined 3:undefined 4:undefined 5:undefined 6:undefined 7:undefined 8:undefined 9:undefined 10:undefined 11:undefined 12:undefined 13:undefined 14:undefined 15:undefined 16:undefined 17:undefined 18:undefined 19:undefined 20:undefined 21:undefined 22:undefined 23:undefined 24:undefined 25:undefined 26:undefined 27:undefined 28:undefined 29:undefined 30:undefined 31:undefined 32:undefined 33:undefined 34:undefined 35:undefined 36:undefined 37:undefined 38:undefined 39:undefined 40:undefined 41:undefined 42:undefined 43:undefined 44:undefined 45:undefined 46:undefined 47:undefined 48:undefined 49:undefined 50:undefined 51:undefined 52:undefined 53:undefined 54:undefined 55:undefined 56:undefined 57:undefined 58:undefined 59:undefined 60:undefined 61:undefined 62:undefined 63:undefined 64:undefined 65:undefined 66:undefined 67:undefined 68:undefined 69:undefined 70:undefined 71:undefined 72:undefined 73:undefined 74:undefined 75:undefined 76:undefined 77:undefined 78:undefined 79:undefined 80:undefined 81:undefined 82:undefined 83:undefined 84:undefined 85:undefined 86:undefined 87:undefined 88:undefined 89:undefined 90:undefined 91:undefined 92:undefined 93:undefined 94:undefined 95:undefined 96:undefined 97:undefined 98:undefined 99:undefined 3 | -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/project1/Module2.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 10 10 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 3 | rule: ruleName = TILEMAP 1 1 0:undefined > {0 = TILEMAP 1 1 0:defined} 4 | -------------------------------------------------------------------------------- /LL/src/utility/TileMap.rsc: -------------------------------------------------------------------------------- 1 | module utility::TileMap 2 | 3 | import List; 4 | import parsing::DataStructures; 5 | 6 | data Transformations = 7 | transformations(bool horizontal, bool vertical, int rotated); 8 | 9 | public list[list[str]] createTileMap(str symbol, int width, int height) 10 | { 11 | return [[symbol | int i <- [0 .. width]] | int j <- [0 .. height]]; 12 | } 13 | 14 | public TileMap applyTransformation 15 | ( 16 | Transformations transformations, 17 | TileMap tileMap 18 | ) 19 | { 20 | if (transformations.horizontal) 21 | { 22 | tileMap = mirrorHorizontal(tileMap); 23 | } 24 | 25 | if (transformations.vertical) 26 | { 27 | tileMap = mirrorVertical(tileMap); 28 | } 29 | 30 | for (int i <- [0 .. transformations.rotated]) 31 | { 32 | tileMap = rotateCounterClockwise(tileMap); 33 | } 34 | 35 | return tileMap; 36 | } 37 | 38 | public TileMap rotateCounterClockwise(TileMap tileMap) 39 | { 40 | TileMap rotation = []; 41 | for (int i <- reverse([0 .. size(head(tileMap))])) 42 | { 43 | list[str] newRow = []; 44 | for (list[str] row <- tileMap) 45 | { 46 | newRow += row[i]; 47 | } 48 | rotation += [newRow]; 49 | } 50 | return rotation; 51 | } 52 | 53 | public TileMap mirrorHorizontal(TileMap tileMap) 54 | { 55 | return [reverse(row) | list[str] row <- tileMap]; 56 | } 57 | 58 | public TileMap mirrorVertical(TileMap tileMap) 59 | { 60 | return reverse(tileMap); 61 | } -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/project1/Module1.grm: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | start: TILEMAP 10 10 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 0:undefined 3 | rule: rule1 = TILEMAP 1 1 0:undefined > {0 = TILEMAP 1 1 0:defined} 4 | rule: rule2 = TILEMAP 1 1 0:defined > {0 = TILEMAP 1 1 0:undefined} 5 | -------------------------------------------------------------------------------- /styleGuide.md: -------------------------------------------------------------------------------- 1 | 2 | STYLE GUIDE 3 | ================================================================================ 4 | 5 | Naming 6 | -------------------------------------------------------------------------------- 7 | - In general: 8 | - Use CamelCase 9 | - Do not abreviate 10 | - files: UpperCamelCase 11 | - variables: lowerCamelCase 12 | - private variables: start with an underscore 13 | - functions: lowerCamelCase 14 | - data strucutres: UpperCammelCase 15 | - folders: lowerCamelCase 16 | 17 | 18 | Layout 19 | -------------------------------------------------------------------------------- 20 | - Try not to extend past 80 characters per line (allows to use multiple windows) 21 | - Use // comments for TODO's 22 | - Use /* for actual comments 23 | - Use the following style for banners: 24 | 25 | ``` 26 | ////////////////////////////////////////////////////////////////////////////// 27 | // Text 28 | ////////////////////////////////////////////////////////////////////////////// 29 | ``` 30 | 31 | - Use the following header for each file: 32 | ``` 33 | ////////////////////////////////////////////////////////////////////////////// 34 | // 35 | // *Name of the file* 36 | // @brief *brief description of the content* 37 | // @contributor *Name* - *email* - *company* 38 | // @date *dd-mm-yyyy* 39 | // 40 | ////////////////////////////////////////////////////////////////////////////// 41 | ``` 42 | - Tabs are 2 spaces 43 | - Braces require a new line 44 | -------------------------------------------------------------------------------- /LL/src/parsing/transformations/Project.rsc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Transform Project 4 | // @brief Functions that move the relevant content from the AST to 5 | // a new ADT declared in DataStructures.rsc. 6 | // @contributor Quinten Heijn - samuel.heijn@gmail.com - UvA 7 | // @date 23-04-2018 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | module parsing::transformations::Project 12 | 13 | import parsing::Parser; 14 | import parsing::languages::grammar::AST; 15 | import parsing::DataStructures; 16 | import utility::String; 17 | 18 | // TODO: implement options and registers. 19 | public TransformationArtifact transformProject(TransformationArtifact artifact, 20 | SyntaxTree syntaxTree) 21 | { 22 | visit (syntaxTree.project[0]) 23 | { 24 | case lspmodule(str name, str alphabet, str position, str moduleType, str fileName, 25 | str match, list[str] inputs, str maxIterations, str moduleFilter, str grammar, 26 | str executionType, str recipe, str showMembers, str alwaysStartWithToken) : 27 | { 28 | list[str] cleanInputs = [removeQuotes(input) | str input <- inputs]; 29 | artifact.project.modules += 30 | [ludoscopeModule(cleanGrammarName(name), 31 | cleanInputs, 32 | cleanAlphabetName(alphabet), 33 | [[]], 34 | (), 35 | [])]; 36 | } 37 | } 38 | 39 | return artifact; 40 | } 41 | -------------------------------------------------------------------------------- /LL/src/visual/projects/v1/BoulderMaps.lsp: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | module: 3 | name: "StartingMap" 4 | alphabet: "Symbols" 5 | position: (-325,89) 6 | type: Grammar 7 | match: None 8 | grammar: true 9 | showMembers: true 10 | 11 | alphabet: 12 | name: "Symbols" 13 | position: (-196,-91) 14 | 15 | module: 16 | name: "PickMediumTemplates" 17 | alphabet: "Symbols" 18 | position: (-54,90) 19 | type: Grammar 20 | match: None 21 | inputs: "PickLargeTemplates" 22 | grammar: true 23 | showMembers: true 24 | 25 | module: 26 | name: "PickVariables" 27 | alphabet: "Symbols" 28 | position: (79,90) 29 | type: Grammar 30 | match: None 31 | inputs: "PickMediumTemplates" 32 | maxIterations: 800 33 | grammar: true 34 | showMembers: true 35 | 36 | module: 37 | name: "AddVariation" 38 | alphabet: "Symbols" 39 | position: (189,89) 40 | type: Recipe 41 | match: None 42 | inputs: "PickVariables" 43 | grammar: true 44 | recipe: true 45 | showMembers: true 46 | 47 | module: 48 | name: "EndResult" 49 | alphabet: "Symbols" 50 | position: (325,89) 51 | type: Grammar 52 | match: None 53 | inputs: "AddVariation" 54 | grammar: true 55 | showMembers: true 56 | 57 | module: 58 | name: "PickLargeTemplates" 59 | alphabet: "Symbols" 60 | position: (-204,91) 61 | type: Recipe 62 | match: None 63 | inputs: "StartingMap" 64 | maxIterations: 2 65 | grammar: true 66 | recipe: true 67 | showMembers: true 68 | 69 | option: Width 40 70 | option: Height 20 71 | option: Tile "Empty" 72 | option: SplitX 5 73 | option: SplitY 5 74 | option: Member "Changed" 75 | -------------------------------------------------------------------------------- /LL/src/visual/projects/v2/BoulderMaps.lsp: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | module: 3 | name: "StartingMap" 4 | alphabet: "Symbols" 5 | position: (-325,91) 6 | type: Grammar 7 | match: None 8 | grammar: true 9 | showMembers: true 10 | 11 | alphabet: 12 | name: "Symbols" 13 | position: (-200,-93) 14 | 15 | module: 16 | name: "PickMediumTemplates" 17 | alphabet: "Symbols" 18 | position: (-54,92) 19 | type: Grammar 20 | match: None 21 | inputs: "PickLargeTemplates" 22 | grammar: true 23 | showMembers: true 24 | 25 | module: 26 | name: "PickVariables" 27 | alphabet: "Symbols" 28 | position: (79,92) 29 | type: Grammar 30 | match: None 31 | inputs: "PickMediumTemplates" 32 | maxIterations: 800 33 | grammar: true 34 | showMembers: true 35 | 36 | module: 37 | name: "AddVariation" 38 | alphabet: "Symbols" 39 | position: (189,91) 40 | type: Recipe 41 | match: None 42 | inputs: "PickVariables" 43 | grammar: true 44 | recipe: true 45 | showMembers: true 46 | 47 | module: 48 | name: "EndResult" 49 | alphabet: "Symbols" 50 | position: (325,91) 51 | type: Grammar 52 | match: None 53 | inputs: "AddVariation" 54 | grammar: true 55 | showMembers: true 56 | 57 | module: 58 | name: "PickLargeTemplates" 59 | alphabet: "Symbols" 60 | position: (-204,93) 61 | type: Recipe 62 | match: None 63 | inputs: "StartingMap" 64 | maxIterations: 2 65 | grammar: true 66 | recipe: true 67 | showMembers: true 68 | 69 | option: Width 40 70 | option: Height 20 71 | option: Tile "Empty" 72 | option: SplitX 5 73 | option: SplitY 5 74 | option: Member "Changed" 75 | -------------------------------------------------------------------------------- /LL/src/visual/projects/v3/BoulderMaps.lsp: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | module: 3 | name: "StartingMap" 4 | alphabet: "Symbols" 5 | position: (-325,89) 6 | type: Grammar 7 | match: None 8 | grammar: true 9 | showMembers: true 10 | 11 | alphabet: 12 | name: "Symbols" 13 | position: (-196,-91) 14 | 15 | module: 16 | name: "PickMediumTemplates" 17 | alphabet: "Symbols" 18 | position: (-54,90) 19 | type: Grammar 20 | match: None 21 | inputs: "PickLargeTemplates" 22 | grammar: true 23 | showMembers: true 24 | 25 | module: 26 | name: "PickVariables" 27 | alphabet: "Symbols" 28 | position: (79,90) 29 | type: Grammar 30 | match: None 31 | inputs: "PickMediumTemplates" 32 | maxIterations: 800 33 | grammar: true 34 | showMembers: true 35 | 36 | module: 37 | name: "AddVariation" 38 | alphabet: "Symbols" 39 | position: (189,89) 40 | type: Recipe 41 | match: None 42 | inputs: "PickVariables" 43 | grammar: true 44 | recipe: true 45 | showMembers: true 46 | 47 | module: 48 | name: "EndResult" 49 | alphabet: "Symbols" 50 | position: (325,89) 51 | type: Grammar 52 | match: None 53 | inputs: "AddVariation" 54 | grammar: true 55 | showMembers: true 56 | 57 | module: 58 | name: "PickLargeTemplates" 59 | alphabet: "Symbols" 60 | position: (-204,91) 61 | type: Recipe 62 | match: None 63 | inputs: "StartingMap" 64 | maxIterations: 2 65 | grammar: true 66 | recipe: true 67 | showMembers: true 68 | 69 | option: Width 40 70 | option: Height 20 71 | option: Tile "Empty" 72 | option: SplitX 5 73 | option: SplitY 5 74 | option: Member "Changed" 75 | -------------------------------------------------------------------------------- /LL/src/visual/projects/v4/BoulderMaps.lsp: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | module: 3 | name: "StartingMap" 4 | alphabet: "Symbols" 5 | position: (-325,89) 6 | type: Grammar 7 | match: None 8 | grammar: true 9 | showMembers: true 10 | 11 | alphabet: 12 | name: "Symbols" 13 | position: (-196,-91) 14 | 15 | module: 16 | name: "PickMediumTemplates" 17 | alphabet: "Symbols" 18 | position: (-54,90) 19 | type: Grammar 20 | match: None 21 | inputs: "PickLargeTemplates" 22 | grammar: true 23 | showMembers: true 24 | 25 | module: 26 | name: "PickVariables" 27 | alphabet: "Symbols" 28 | position: (79,90) 29 | type: Grammar 30 | match: None 31 | inputs: "PickMediumTemplates" 32 | maxIterations: 800 33 | grammar: true 34 | showMembers: true 35 | 36 | module: 37 | name: "AddVariation" 38 | alphabet: "Symbols" 39 | position: (189,89) 40 | type: Recipe 41 | match: None 42 | inputs: "PickVariables" 43 | grammar: true 44 | recipe: true 45 | showMembers: true 46 | 47 | module: 48 | name: "EndResult" 49 | alphabet: "Symbols" 50 | position: (325,89) 51 | type: Grammar 52 | match: None 53 | inputs: "AddVariation" 54 | grammar: true 55 | showMembers: true 56 | 57 | module: 58 | name: "PickLargeTemplates" 59 | alphabet: "Symbols" 60 | position: (-204,91) 61 | type: Recipe 62 | match: None 63 | inputs: "StartingMap" 64 | maxIterations: 2 65 | grammar: true 66 | recipe: true 67 | showMembers: true 68 | 69 | option: Width 40 70 | option: Height 20 71 | option: Tile "Empty" 72 | option: SplitX 5 73 | option: SplitY 5 74 | option: Member "Changed" 75 | -------------------------------------------------------------------------------- /LL/src/execution/DataStructures.rsc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Execution Data Structures 4 | // @brief This file contains datastructures needed for execution an LL 5 | // project. 6 | // @contributor Quinten Heijn - samuel.heijn@gmail.com - UvA 7 | // @date 01-05-2018 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | module execution::DataStructures 12 | 13 | import analysis::sanrWrapper::PropertyHistory; 14 | import sanr::PropertyValidation; 15 | //import execution::history::DataStructures; 16 | import parsing::DataStructures; 17 | import errors::Execution; 18 | 19 | import sanr::DataStructures; 20 | 21 | alias OutputMap = map[str, TileMap]; 22 | alias ModuleHierarchy = list[set[LudoscopeModule]]; 23 | alias Location = tuple[int x, int y]; 24 | 25 | data ExecutionArtifact = 26 | executionArtifact(OutputMap output, 27 | TileMap currentState, 28 | ExecutionHistory history, 29 | PropertyReport propertyReport, 30 | list[ExecutionError] errors) 31 | | emptyExecutionArtifact(); 32 | 33 | data PreparationArtifact = 34 | preparationArtifact(ModuleHierarchy hierarchy, list[ExecutionError] errors) 35 | | emptyPreparationArtifact(); 36 | 37 | alias ExecutionHistory = list[Step]; 38 | 39 | data Step = 40 | step(TileMap tileMap, 41 | str moduleName, 42 | Instruction instruction, 43 | str ruleName, 44 | int rightHand, 45 | Coordinates location); -------------------------------------------------------------------------------- /LL/src/visual/IDE/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 26 | 27 | 28 |
29 |
30 | 31 | 32 | -------------------------------------------------------------------------------- /LL/src/parsing/transformations/CompleteSyntaxTree.rsc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Transform AST 4 | // @brief Functions that move the relevant content from the AST to 5 | // a new ADT declared in DataStructures.rsc. 6 | // @contributor Quinten Heijn - samuel.heijn@gmail.com - UvA 7 | // @date 23-04-2018 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | // TODO: put transformations in seprate files. 12 | module parsing::transformations::CompleteSyntaxTree 13 | 14 | import parsing::Parser; 15 | import parsing::DataStructures; 16 | 17 | import parsing::transformations::TransformInstructions; 18 | import parsing::transformations::Project; 19 | import parsing::transformations::Alphabet; 20 | import parsing::transformations::Grammar; 21 | import parsing::transformations::Recipe; 22 | import parsing::transformations::Properties; 23 | 24 | import sanr::language::AST; 25 | 26 | public TransformationArtifact transformSyntaxTree(SyntaxTree syntaxTree) 27 | { 28 | LudoscopeProject project = ludoscopeProject([], (), specification([])); 29 | TransformationArtifact artifact = transformationArtifact(project, []); 30 | 31 | artifact = transformProject(artifact, syntaxTree); 32 | artifact = transformAplhabets(artifact, syntaxTree); 33 | artifact = transformGrammars(artifact, syntaxTree); 34 | artifact = transformRecipes(artifact, syntaxTree); 35 | artifact = transformProperties(artifact, syntaxTree); 36 | 37 | artifact = addEmptyRecipes(artifact); 38 | 39 | return artifact; 40 | } 41 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2018, Quinten Heijn 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | * Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /LL/src/parsing/transformations/Recipe.rsc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Transform Alphabet 4 | // @brief Functions that move the relevant content from the AST to 5 | // a new ADT declared in DataStructures.rsc. 6 | // @contributor Quinten Heijn - samuel.heijn@gmail.com - UvA 7 | // @date 23-04-2018 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | module parsing::transformations::Recipe 12 | 13 | import parsing::Parser; 14 | import parsing::DataStructures; 15 | import parsing::transformations::Utility; 16 | import parsing::transformations::Instruction; 17 | import parsing::languages::recipe::AST; 18 | 19 | public TransformationArtifact transformRecipes(TransformationArtifact artifact, 20 | SyntaxTree syntaxTree) 21 | { 22 | for (str recipeName <- syntaxTree.recipes) 23 | { 24 | int moduleIndex = findModuleIndex(recipeName, artifact); 25 | 26 | for (AbstractInstruction instruction 27 | <- syntaxTree.recipes[recipeName].instructions) 28 | { 29 | if (!instruction.commented) 30 | { 31 | artifact.project.modules[moduleIndex].recipe += 32 | [parseInstruction(artifact, instruction)]; 33 | } 34 | } 35 | } 36 | return artifact; 37 | } 38 | 39 | public TransformationArtifact addEmptyRecipes(TransformationArtifact artifact) 40 | { 41 | artifact = visit(artifact) 42 | { 43 | case ludoscopeModule(name, inputs, alphabetName, startingState, rules, []) => 44 | ludoscopeModule(name, inputs, alphabetName, startingState, rules, [executeGrammar()]) 45 | } 46 | return artifact; 47 | } -------------------------------------------------------------------------------- /LL/src/parsing/languages/alphabet/AST.rsc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // The AST used for parsing .alp files. 4 | // @brief This file contains the data structure needed for imploding 5 | // a parsed .alp tree. 6 | // @contributor Quinten Heijn - samuel.heijn@gmail.com - UvA 7 | // @date 03-04-2018 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | module parsing::languages::alphabet::AST 12 | 13 | import parsing::languages::alphabet::Syntax; 14 | import ParseTree; 15 | 16 | ////////////////////////////////////////////////////////////////////////////// 17 | // APIs 18 | ////////////////////////////////////////////////////////////////////////////// 19 | 20 | public parsing::languages::alphabet::AST::Alphabet implodeAlphabet(Tree tree) 21 | = implode(#parsing::languages::alphabet::AST::Alphabet, tree); 22 | 23 | public parsing::languages::alphabet::AST::Alphabet parseAlphabetToAST(loc location) 24 | = implodeAlphabet(parseAlphabet(location)); 25 | 26 | anno loc Alphabet@location; 27 | anno loc MapType@location; 28 | anno loc SymbolInfo@location; 29 | 30 | ////////////////////////////////////////////////////////////////////////////// 31 | // AST 32 | ////////////////////////////////////////////////////////////////////////////// 33 | 34 | data Alphabet 35 | = alphabet(MapType mapType, list[SymbolInfo] symbols); 36 | 37 | data MapType 38 | = tileMap(int width, int height) 39 | | string() 40 | | graph() 41 | | shape(); 42 | 43 | data SymbolInfo 44 | = symbolInfo( 45 | str name, 46 | str color, 47 | str fill, 48 | str abbreviation, 49 | str shape); -------------------------------------------------------------------------------- /LL/src/parsing/DataStructures.rsc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // The data structures for a LL project 4 | // @brief This file contains the data structures needed for executing 5 | // the modules in a Ludoscope Light project. 6 | // @contributor Quinten Heijn - samuel.heijn@gmail.com - UvA 7 | // @date 05-04-2018 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | module parsing::DataStructures 12 | 13 | import errors::Parsing; 14 | import sanr::DataStructures; 15 | import sanr::language::AST; 16 | import parsing::languages::alphabet::AST; 17 | 18 | alias TileMap = list[list[Tile]]; 19 | alias Tile = str; 20 | 21 | alias AlphabetMap = map[str, Alphabet]; 22 | alias RuleMap = map[str, Rule]; 23 | alias Recipe = list[Instruction]; 24 | 25 | data TransformationArtifact 26 | = transformationArtifact(LudoscopeProject project, 27 | list[ParsingError] errors) 28 | | emptyArtifact(); 29 | 30 | data LudoscopeProject 31 | = ludoscopeProject(list[LudoscopeModule] modules, 32 | AlphabetMap alphabets, 33 | LevelSpecification specification) 34 | | undefinedProject(); 35 | 36 | data LudoscopeModule 37 | = ludoscopeModule(str name, 38 | list[str] inputs, 39 | str alphabetName, 40 | TileMap startingState, 41 | RuleMap rules, 42 | Recipe recipe) 43 | | undefinedModule(); 44 | 45 | data Rule 46 | = rule(Reflections reflections, 47 | TileMap leftHand, 48 | list[TileMap] rightHands); 49 | 50 | data Reflections 51 | = reflections(bool mirrorHorizontal, 52 | bool mirrorVertical, 53 | bool rotate); 54 | 55 | data Coordinates 56 | = coordinates(int x, int y); 57 | 58 | data Instruction 59 | = itterateRule(str ruleName) 60 | | executeRule(str ruleName, int itterations) 61 | | executeGrammar(); -------------------------------------------------------------------------------- /LL/src/visual/projects/v1/Symbols.alp: -------------------------------------------------------------------------------- 1 | TILEMAP 1 1 *(color=#B0B0B0, fill=#404040) space(color=#404040, fill=#000000, abbreviation="0") dirt(color=#404040, fill=#6A5400, abbreviation="1") brick(color=#404040, fill=#984B43, abbreviation="2") magic(color=#404040, fill=#8A7BCE, abbreviation="3") steel(color=#404040, fill=#636363, abbreviation="7") firefly(color=#404040, fill=#C37B75, abbreviation="8") boulder(color=#404040, fill=#8A8A8A, abbreviation="10") diamond(color=#404040, fill=#FFFFFF, abbreviation="14") butterfly(color=#404040, fill=#A3E599, abbreviation="30") rockford(color=#404040, fill=#F7F955, abbreviation="38") amoeba(color=#404040, fill=#9B6739, abbreviation="58") exit(color=#404040, fill=#000000, abbreviation="37") dirtOrSpace(color=#B0B0B0, fill=#AFFCFF, abbreviation="d?s") diamondOrBoulder(color=#B0B0B0, fill=#AFFCFF, abbreviation="D?b") dirtOrDiamond(color=#B0B0B0, fill=#AFFCFF, abbreviation="d?D") fireflyOrButterfly(color=#B0B0B0, fill=#AFFCFF, abbreviation="f?b") brickOrMagic(color=#B0B0B0, fill=#AFFCFF, abbreviation="b?m") dirtOrBoulder(color=#B0B0B0, fill=#AFFCFF, abbreviation="b?d") TemplateSpot(color=#404040, fill=#0404FF, abbreviation="T") Empty(color=#404040, fill=#DDDDDD, abbreviation="") TemplateStart(color=#404040, fill=#61BAFF, abbreviation="TS") TemplateEnd(color=#404040, fill=#61BAFF, abbreviation="TE") TemplateMonster(color=#404040, fill=#61BAFF, abbreviation="TM") TemplateReward(color=#404040, fill=#61BAFF, abbreviation="TR") TemplateBoulder(color=#404040, fill=#61BAFF, abbreviation="TB") TemplateTraversal(color=#404040, fill=#61BAFF, abbreviation="TT") TemplateMaze1(color=#404040, fill=#61BAFF, abbreviation="TM1") TemplateMaze2(color=#404040, fill=#61BAFF, abbreviation="TM2") TemplateMaze3(color=#404040, fill=#61BAFF, abbreviation="TM3") TemplateMaze4(color=#404040, fill=#61BAFF, abbreviation="TM4") TemplatePuzzle(color=#404040, fill=#61BAFF, abbreviation="TP") -------------------------------------------------------------------------------- /LL/src/visual/projects/v2/Symbols.alp: -------------------------------------------------------------------------------- 1 | TILEMAP 1 1 *(color=#B0B0B0, fill=#404040) space(color=#404040, fill=#000000, abbreviation="0") dirt(color=#404040, fill=#6A5400, abbreviation="1") brick(color=#404040, fill=#984B43, abbreviation="2") magic(color=#404040, fill=#8A7BCE, abbreviation="3") steel(color=#404040, fill=#636363, abbreviation="7") firefly(color=#404040, fill=#C37B75, abbreviation="8") boulder(color=#404040, fill=#8A8A8A, abbreviation="10") diamond(color=#404040, fill=#FFFFFF, abbreviation="14") butterfly(color=#404040, fill=#A3E599, abbreviation="30") rockford(color=#404040, fill=#F7F955, abbreviation="38") amoeba(color=#404040, fill=#9B6739, abbreviation="58") exit(color=#404040, fill=#000000, abbreviation="37") dirtOrSpace(color=#B0B0B0, fill=#AFFCFF, abbreviation="d?s") diamondOrBoulder(color=#B0B0B0, fill=#AFFCFF, abbreviation="D?b") dirtOrDiamond(color=#B0B0B0, fill=#AFFCFF, abbreviation="d?D") fireflyOrButterfly(color=#B0B0B0, fill=#AFFCFF, abbreviation="f?b") brickOrMagic(color=#B0B0B0, fill=#AFFCFF, abbreviation="b?m") dirtOrBoulder(color=#B0B0B0, fill=#AFFCFF, abbreviation="b?d") TemplateSpot(color=#404040, fill=#0404FF, abbreviation="T") Empty(color=#404040, fill=#DDDDDD, abbreviation="") TemplateStart(color=#404040, fill=#61BAFF, abbreviation="TS") TemplateEnd(color=#404040, fill=#61BAFF, abbreviation="TE") TemplateMonster(color=#404040, fill=#61BAFF, abbreviation="TM") TemplateReward(color=#404040, fill=#61BAFF, abbreviation="TR") TemplateBoulder(color=#404040, fill=#61BAFF, abbreviation="TB") TemplateTraversal(color=#404040, fill=#61BAFF, abbreviation="TT") TemplateMaze1(color=#404040, fill=#61BAFF, abbreviation="TM1") TemplateMaze2(color=#404040, fill=#61BAFF, abbreviation="TM2") TemplateMaze3(color=#404040, fill=#61BAFF, abbreviation="TM3") TemplateMaze4(color=#404040, fill=#61BAFF, abbreviation="TM4") TemplatePuzzle(color=#404040, fill=#61BAFF, abbreviation="TP") -------------------------------------------------------------------------------- /LL/src/visual/projects/v3/Symbols.alp: -------------------------------------------------------------------------------- 1 | TILEMAP 1 1 *(color=#B0B0B0, fill=#404040) space(color=#404040, fill=#000000, abbreviation="0") dirt(color=#404040, fill=#6A5400, abbreviation="1") brick(color=#404040, fill=#984B43, abbreviation="2") magic(color=#404040, fill=#8A7BCE, abbreviation="3") steel(color=#404040, fill=#636363, abbreviation="7") firefly(color=#404040, fill=#C37B75, abbreviation="8") boulder(color=#404040, fill=#8A8A8A, abbreviation="10") diamond(color=#404040, fill=#FFFFFF, abbreviation="14") butterfly(color=#404040, fill=#A3E599, abbreviation="30") rockford(color=#404040, fill=#F7F955, abbreviation="38") amoeba(color=#404040, fill=#9B6739, abbreviation="58") exit(color=#404040, fill=#000000, abbreviation="37") dirtOrSpace(color=#B0B0B0, fill=#AFFCFF, abbreviation="d?s") diamondOrBoulder(color=#B0B0B0, fill=#AFFC00, abbreviation="D?b") dirtOrDiamond(color=#B0B0B0, fill=#AFFC00, abbreviation="d?D") fireflyOrButterfly(color=#B0B0B0, fill=#AFFCFF, abbreviation="f?b") brickOrMagic(color=#B0B0B0, fill=#AFFCFF, abbreviation="b?m") dirtOrBoulder(color=#B0B0B0, fill=#AFFCFF, abbreviation="b?d") TemplateSpot(color=#404040, fill=#0404FF, abbreviation="T") Empty(color=#404040, fill=#DDDDDD, abbreviation="") TemplateStart(color=#404040, fill=#61BAFF, abbreviation="TS") TemplateEnd(color=#404040, fill=#61BAFF, abbreviation="TE") TemplateMonster(color=#404040, fill=#61BAFF, abbreviation="TM") TemplateReward(color=#404040, fill=#61BAFF, abbreviation="TR") TemplateBoulder(color=#404040, fill=#61BAFF, abbreviation="TB") TemplateTraversal(color=#404040, fill=#61BAFF, abbreviation="TT") TemplateMaze1(color=#404040, fill=#61BAFF, abbreviation="TM1") TemplateMaze2(color=#404040, fill=#61BAFF, abbreviation="TM2") TemplateMaze3(color=#404040, fill=#61BAFF, abbreviation="TM3") TemplateMaze4(color=#404040, fill=#61BAFF, abbreviation="TM4") TemplatePuzzle(color=#404040, fill=#61BAFF, abbreviation="TP") -------------------------------------------------------------------------------- /LL/src/visual/projects/v4/Symbols.alp: -------------------------------------------------------------------------------- 1 | TILEMAP 1 1 *(color=#B0B0B0, fill=#404040) space(color=#404040, fill=#000000, abbreviation="0") dirt(color=#404040, fill=#6A5400, abbreviation="1") brick(color=#404040, fill=#984B43, abbreviation="2") magic(color=#404040, fill=#8A7BCE, abbreviation="3") steel(color=#404040, fill=#636363, abbreviation="7") firefly(color=#404040, fill=#C37B75, abbreviation="8") boulder(color=#404040, fill=#8A8A8A, abbreviation="10") diamond(color=#404040, fill=#FFFFFF, abbreviation="14") butterfly(color=#404040, fill=#A3E599, abbreviation="30") rockford(color=#404040, fill=#F7F955, abbreviation="38") amoeba(color=#404040, fill=#9B6739, abbreviation="58") exit(color=#404040, fill=#000000, abbreviation="37") dirtOrSpace(color=#B0B0B0, fill=#AFFCFF, abbreviation="d?s") diamondOrBoulder(color=#B0B0B0, fill=#AFFC00, abbreviation="D?b") dirtOrDiamond(color=#B0B0B0, fill=#AFFC00, abbreviation="d?D") fireflyOrButterfly(color=#B0B0B0, fill=#AFFCFF, abbreviation="f?b") brickOrMagic(color=#B0B0B0, fill=#AFFCFF, abbreviation="b?m") dirtOrBoulder(color=#B0B0B0, fill=#AFFCFF, abbreviation="b?d") TemplateSpot(color=#404040, fill=#0404FF, abbreviation="T") Empty(color=#404040, fill=#DDDDDD, abbreviation="") TemplateStart(color=#404040, fill=#61BAFF, abbreviation="TS") TemplateEnd(color=#404040, fill=#61BAFF, abbreviation="TE") TemplateMonster(color=#404040, fill=#61BAFF, abbreviation="TM") TemplateReward(color=#404040, fill=#61BAFF, abbreviation="TR") TemplateBoulder(color=#404040, fill=#61BAFF, abbreviation="TB") TemplateTraversal(color=#404040, fill=#61BAFF, abbreviation="TT") TemplateMaze1(color=#404040, fill=#61BAFF, abbreviation="TM1") TemplateMaze2(color=#404040, fill=#61BAFF, abbreviation="TM2") TemplateMaze3(color=#404040, fill=#61BAFF, abbreviation="TM3") TemplateMaze4(color=#404040, fill=#61BAFF, abbreviation="TM4") TemplatePuzzle(color=#404040, fill=#61BAFF, abbreviation="TP") -------------------------------------------------------------------------------- /LL/src/experiments/MapSize.rsc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Functions for testing LL with differen map sizes. 4 | // @brief Functions for testing LL with differen map sizes. 5 | // @contributor Quinten Heijn - samuel.heijn@gmail.com - UvA 6 | // @date 17-05-2018 7 | // 8 | ////////////////////////////////////////////////////////////////////////////// 9 | 10 | module experiments::MapSize 11 | 12 | import List; 13 | import Map; 14 | import DateTime; 15 | import IO; 16 | 17 | import utility::Time; 18 | import execution::Execution; 19 | import parsing::DataStructures; 20 | import execution::DataStructures; 21 | 22 | int EXECUTIONS = 100; 23 | int MINSIZE = 2; 24 | int MAXSIZE = 10; 25 | RuleMap RULES = (0 : rule(reflections(false,false,false),[[0]],[[[1]]])); 26 | LudoscopeModule MODULE = ludoscopeModule(0, [], "", [[]], RULES, [executeGrammar()]); 27 | 28 | public void runAllExperiments() 29 | { 30 | list[tuple[int, int]] averageTime = []; 31 | for (int i <- [MINSIZE .. MAXSIZE + 1]) 32 | { 33 | averageTime += ; 34 | } 35 | iprintln(averageTime); 36 | } 37 | 38 | // TODO: use util version 39 | private list[list[int]] createTileMap(int width, int height) 40 | { 41 | return [[0 | int i <- [0 .. width]] | int j <- [0 .. height]]; 42 | } 43 | 44 | private int timedModuleExecution(LudoscopeModule ludoscopeModule, 45 | TileMap input, int executions) 46 | { 47 | ludoscopeModule.startingState = input; 48 | Duration totalTime = duration(0, 0, 0, 0, 0, 0, 0); 49 | 50 | for (int i <- [0 .. executions]) 51 | { 52 | datetime startTime = now(); 53 | executeModule(ludoscopeModule, ()); 54 | datetime endTime = now(); 55 | 56 | Duration executionDuration = (endTime - startTime); 57 | totalTime = addDuration(totalTime, (endTime - startTime)); 58 | } 59 | 60 | return durationToMilliseconds(totalTime)/executions; 61 | } -------------------------------------------------------------------------------- /LL/src/execution/ModuleHierarchy.rsc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Module Hierarchy 4 | // @brief This file contains functions that extract the order in which 5 | // modules should be executed. 6 | // @contributor Quinten Heijn - samuel.heijn@gmail.com - UvA 7 | // @date 12-05-2018 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | module execution::ModuleHierarchy 12 | 13 | import IO; 14 | import List; 15 | import errors::Execution; 16 | import parsing::DataStructures; 17 | import execution::DataStructures; 18 | 19 | public PreparationArtifact extractModuleHierarchy(LudoscopeProject project) 20 | { 21 | list[LudoscopeModule] modules = project.modules; 22 | list[str] checkedModules = []; 23 | PreparationArtifact artifact = preparationArtifact([], []); 24 | while (modules != []) 25 | { 26 | list[LudoscopeModule] readyModules = 27 | findReadyModules(modules, checkedModules); 28 | 29 | if (readyModules == []) 30 | { 31 | list[str] moduleNames = [m.name | LudoscopeModule m <- modules]; 32 | artifact.errors += [moduleConnection(moduleNames)]; 33 | return artifact; 34 | } 35 | 36 | artifact.hierarchy += [toSet(readyModules)]; 37 | checkedModules += [readyModule.name | LudoscopeModule readyModule <- readyModules]; 38 | modules -= readyModules; 39 | } 40 | return artifact; 41 | } 42 | 43 | private list[LudoscopeModule] findReadyModules 44 | ( 45 | list[LudoscopeModule] modules, 46 | list[str] checkedModules 47 | ) 48 | { 49 | list[LudoscopeModule] readyModules = [m | 50 | LudoscopeModule m <- modules, 51 | inputReady(m, checkedModules)]; 52 | return readyModules; 53 | } 54 | 55 | 56 | private bool inputReady(LudoscopeModule ludoscopeModule, list[str] checkedModules) 57 | { 58 | list[str] inputsRemaining = [n | 59 | n <- ludoscopeModule.inputs, 60 | n notin checkedModules]; 61 | return inputsRemaining == []; 62 | } -------------------------------------------------------------------------------- /LL/src/tests/execution/CompleteProjects.rsc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Tests for parsing & transforming complete projects 4 | // @brief Tests for parsing and transforming projects. If the parsing 5 | // fails, the transformation tests will also fail, because they 6 | // test the entire parsing pipeline (parsing + tranforming). 7 | // @contributor Quinten Heijn - samuel.heijn@gmail.com - UvA 8 | // @date 24-04-2018 9 | // 10 | ////////////////////////////////////////////////////////////////////////////// 11 | 12 | module tests::execution::CompleteProjects 13 | 14 | import IO; 15 | 16 | import execution::DataStructures; 17 | import execution::Execution; 18 | import parsing::DataStructures; 19 | import tests::parsing::Utility; 20 | import parsing::Interface; 21 | import utility::TileMap; 22 | 23 | import sanr::language::AST; 24 | import sanr::DataStructures; 25 | import analysis::sanrWrapper::PropertyHistory; 26 | 27 | public bool runAllTests() 28 | { 29 | return executeProject0(); 30 | } 31 | 32 | ////////////////////////////////////////////////////////////////////////////// 33 | // Tests for transformer. 34 | ////////////////////////////////////////////////////////////////////////////// 35 | 36 | // TODO: extract parsed project to module. 37 | // TOOD: generate tile maps. 38 | public test bool executeProject0() 39 | { 40 | /* Arrange */ 41 | AlphabetMap alphabetMap = (); 42 | LudoscopeModule module1 = 43 | ludoscopeModule("module1",[],"Alphabet", 44 | createTileMap("1", 5, 5), 45 | ("ruleName" : rule(reflections(false,false,false),[["1"]],[[["2"]]])), 46 | [executeRule("ruleName", 100)]); 47 | LudoscopeProject project = ludoscopeProject([module1], (), specification([])); 48 | 49 | TileMap expectedOutput = createTileMap("2", 5, 5); 50 | 51 | /* Act */ 52 | ExecutionArtifact result = executeProject(project); 53 | 54 | /* Assert */ 55 | return result.currentState == expectedOutput; 56 | } -------------------------------------------------------------------------------- /LL/src/visual/IDE/index.css: -------------------------------------------------------------------------------- 1 | html { 2 | position: relative; 3 | min-height: 100%; 4 | } 5 | body { 6 | /* Margin bottom by footer height */ 7 | margin-bottom: 60px; 8 | /* TODO: revert after presentation. */ 9 | font-size: 200%; 10 | } 11 | .footer { 12 | position: absolute; 13 | bottom: 0; 14 | width: 100%; 15 | /* Set the fixed height of the footer here */ 16 | height: 60px; 17 | line-height: 60px; /* Vertically center the text there */ 18 | background-color: #f5f5f5; 19 | } 20 | 21 | 22 | text { 23 | font-size: 150%; 24 | } 25 | 26 | .node rect { 27 | stroke: #999; 28 | fill: #fff; 29 | stroke-width: 1.5px; 30 | } 31 | 32 | .edgePath path { 33 | stroke: #333; 34 | stroke-width: 1.5px; 35 | } 36 | 37 | .optionOn { 38 | color: black; 39 | text-align: right; 40 | font-weight: bold; 41 | } 42 | 43 | .svgWrapper { 44 | position:relative; 45 | } 46 | 47 | svg { 48 | position:relative; 49 | } 50 | 51 | .optionOff { 52 | color: lightgray; 53 | text-align: right; 54 | font-weight: bold; 55 | } 56 | 57 | 58 | .negativeMAD { 59 | color: red; 60 | text-align: right; 61 | font-weight: bold; 62 | } 63 | 64 | .positiveMAD { 65 | color: black; 66 | text-align: right; 67 | font-weight: bold; 68 | } 69 | 70 | .scrollBox { 71 | height: 500px; 72 | overflow-y: auto; 73 | } 74 | 75 | .arrow { 76 | font-size:30px; 77 | } 78 | 79 | #pipeline { 80 | outline: 2px lightgray solid; 81 | } 82 | 83 | .CodeMirror { 84 | height: 500px; 85 | } 86 | 87 | .moduleLink { 88 | color: white; 89 | } 90 | 91 | .moduleLink:hover { 92 | color: lightgray; 93 | } 94 | 95 | .executionHistory { 96 | overflow-y: auto; 97 | height: 500px 98 | } 99 | 100 | .mapDisplay { 101 | height: 300px; 102 | } 103 | 104 | .ruleRow { 105 | padding-left: 50px; 106 | padding-right: 50px; 107 | } 108 | 109 | .saveButton { 110 | margin-top: 10px; 111 | } 112 | 113 | .analysisResults { 114 | margin-top: 10px; 115 | outline: 3px double gray; 116 | } 117 | 118 | .propertyList { 119 | overflow-y: auto; 120 | height: 500px 121 | } -------------------------------------------------------------------------------- /LL/src/tests/parsing/LevelSpecification.rsc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Parsing tests for .sanr files. 4 | // @brief This file contains unit tests for parsing .sanr files to an AST 5 | // @contributor Quinten Heijn - samuel.heijn@gmail.com - UvA 6 | // @date 06-04-2018 7 | // 8 | ////////////////////////////////////////////////////////////////////////////// 9 | 10 | module tests::parsing::LevelSpecification 11 | 12 | import parsing::DataStructures; 13 | import parsing::Parser; 14 | import tests::parsing::Utility; 15 | 16 | import sanr::language::AST; 17 | import sanr::DataStructures; 18 | 19 | SyntaxTree emptySyntaxTree = syntaxTree([], (), (), (), [], []); 20 | 21 | public bool runAllTests() 22 | { 23 | return tryParsingAdjacency() 24 | && tryParsingOccurrence() 25 | && tryParsingOccurrenceAndContainment(); 26 | } 27 | 28 | ////////////////////////////////////////////////////////////////////////////// 29 | // Tests for parser. 30 | ////////////////////////////////////////////////////////////////////////////// 31 | 32 | public test bool tryParsingAdjacency() 33 | { 34 | /* Arrange */ 35 | loc fileLocation = 36 | |project://LL/src/tests/correctTestData/isolatedLevelSpecifications/adjacency.sanr|; 37 | 38 | /* Act */ 39 | SyntaxTree syntaxTree = parseFile(fileLocation, emptySyntaxTree); 40 | 41 | /* Assert */ 42 | return checkErrors(syntaxTree); 43 | } 44 | 45 | public test bool tryParsingOccurrence() 46 | { 47 | /* Arrange */ 48 | loc fileLocation = 49 | |project://LL/src/tests/correctTestData/isolatedLevelSpecifications/occurrence.sanr|; 50 | 51 | /* Act */ 52 | SyntaxTree syntaxTree = parseFile(fileLocation, emptySyntaxTree); 53 | 54 | /* Assert */ 55 | return checkErrors(syntaxTree); 56 | } 57 | 58 | public test bool tryParsingOccurrenceAndContainment() 59 | { 60 | /* Arrange */ 61 | loc fileLocation = 62 | |project://LL/src/tests/correctTestData/isolatedLevelSpecifications/occurrenceAndContainment.sanr|; 63 | 64 | /* Act */ 65 | SyntaxTree syntaxTree = parseFile(fileLocation, emptySyntaxTree); 66 | 67 | /* Assert */ 68 | return checkErrors(syntaxTree); 69 | } 70 | -------------------------------------------------------------------------------- /LL/src/analysis/madWrapper/SymbolHierarchy.rsc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Extracting symbol hierarchy 4 | // @brief This file contains functions to extract the symbol hierarchy 5 | // from a project. 6 | // @contributor Quinten Heijn - samuel.heijn@gmail.com - UvA 7 | // @date 17-05-2018 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | module analysis::madWrapper::SymbolHierarchy 12 | 13 | import IO; 14 | import List; 15 | import parsing::DataStructures; 16 | import execution::DataStructures; 17 | 18 | alias SymbolHierarchy = list[SymbolGroup]; 19 | alias SymbolGroup = set[str]; 20 | 21 | public SymbolHierarchy extractSymbolHierarchy(ModuleHierarchy moduleHierarchy) 22 | { 23 | SymbolHierarchy symbolHierarchy = []; 24 | SymbolGroup allUsedSymbols = {}; 25 | SymbolGroup newSymbolGroup = {}; 26 | 27 | /* Begin with extract the symbols from the starting state (multiple starts possible). */ 28 | for (LudoscopeModule currentModule <- head(moduleHierarchy)) 29 | { 30 | newSymbolGroup += extractNewSymbols(symbolHierarchy, [currentModule.startingState]); 31 | } 32 | allUsedSymbols += newSymbolGroup; 33 | symbolHierarchy += [newSymbolGroup]; 34 | 35 | /* Extract the symbols from the right hands of rules. */ 36 | for (set[LudoscopeModule] moduleGroup <- moduleHierarchy) 37 | { 38 | newSymbolGroup = {}; 39 | visit(moduleGroup) 40 | { 41 | case rule 42 | ( 43 | Reflections reflections, 44 | TileMap leftHand, 45 | list[TileMap] rightHands 46 | ) : 47 | { 48 | newSymbolGroup += extractNewSymbols(symbolHierarchy, rightHands) - 49 | allUsedSymbols; 50 | } 51 | } 52 | if (newSymbolGroup != {}) 53 | { 54 | allUsedSymbols += newSymbolGroup; 55 | symbolHierarchy += [newSymbolGroup]; 56 | } 57 | } 58 | return symbolHierarchy; 59 | } 60 | 61 | private SymbolGroup extractNewSymbols 62 | ( 63 | SymbolHierarchy hierarchy, 64 | list[TileMap] maps 65 | ) 66 | { 67 | SymbolGroup usedSymbols = {}; 68 | visit (maps) 69 | { 70 | case str symbol: 71 | { 72 | usedSymbols += symbol; 73 | } 74 | } 75 | return usedSymbols; 76 | } -------------------------------------------------------------------------------- /LL/src/parsing/languages/recipe/AST.rsc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // The AST used for parsing .rcp files. 4 | // @brief This file contains the data structure needed for imploding 5 | // a parsed .rcp tree. 6 | // @contributor Quinten Heijn - samuel.heijn@gmail.com - UvA 7 | // @date 03-04-2018 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | module parsing::languages::recipe::AST 12 | 13 | import parsing::languages::recipe::Syntax; 14 | import ParseTree; 15 | 16 | ////////////////////////////////////////////////////////////////////////////// 17 | // APIs 18 | ////////////////////////////////////////////////////////////////////////////// 19 | 20 | public parsing::languages::recipe::AST::Recipe implodeRecipe(Tree tree) 21 | = implode(#parsing::languages::recipe::AST::Recipe, tree); 22 | 23 | public parsing::languages::recipe::AST::Recipe parseRecipeToAST(loc location) 24 | = implodeRecipe(parseRecipe(location)); 25 | 26 | ////////////////////////////////////////////////////////////////////////////// 27 | // AST 28 | ////////////////////////////////////////////////////////////////////////////// 29 | 30 | data Recipe 31 | = recipe(list[Instruction] instructions); 32 | 33 | data Instruction 34 | = setRegister(bool commented, str regsiterName, Expression newValue) 35 | | iterateRule(bool commented, str ruleName) 36 | | iterateFromRegister(bool commented, str registerName) 37 | | iterateRuleLSystem(bool commented, str ruleName) 38 | | iterateRuleCellular(bool commented, str ruleName) 39 | | executeFromRegister(bool commented, str ruleName, int executions) 40 | | executeRuleLSystem(bool commented, str ruleName, int executions) 41 | | executeRuleCellular(bool commented, str ruleName, int executions) 42 | | executeRule(bool commented, str ruleName, int executions) 43 | | replaceLabels(bool commented, str oldLabel, str newLabel) 44 | | splitTiles(bool commented, int width, int height) 45 | | createTileMapFromRegisters(bool commented, str registerWidth, str registerHeigth, str name) 46 | | createTileMapFromIntegers(bool commented, int mapWidth, int mapHeight, str name) 47 | | keepTopOfStack(bool commented) 48 | | transformSymbols(bool commented, str oldSymbol, str newSymbol); 49 | 50 | data Expression 51 | = expression(int newValue); -------------------------------------------------------------------------------- /LL/src/analysis/madWrapper/MADFramework.rsc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Framerwork for MAD (Metric of Added Detail) 4 | // @brief This file contains the data structures and the functions 5 | // needed to evaluate the amount of detail that is added by each 6 | // rule in a project using the MAD. 7 | // @contributor Quinten Heijn - samuel.heijn@gmail.com - UvA 8 | // @date 05-04-2018 9 | // 10 | ////////////////////////////////////////////////////////////////////////////// 11 | 12 | module analysis::madWrapper::MADFramework 13 | 14 | import List; 15 | import utility::Integer; 16 | import util::mad::Metric; 17 | 18 | import parsing::DataStructures; 19 | import execution::DataStructures; 20 | import execution::ModuleHierarchy; 21 | 22 | import analysis::madWrapper::SymbolHierarchy; 23 | import analysis::madWrapper::DataTransformation; 24 | 25 | alias ProjectScore = map[str, ModuleScore]; 26 | alias ModuleScore = map[str, list[RightHandScore]]; 27 | alias RightHandScore = tuple[int score, HeatMap heatmap]; 28 | alias HeatMap = list[list[int]]; 29 | 30 | public ProjectScore calculateMAD(LudoscopeProject project) 31 | { 32 | ModuleHierarchy moduleHierarchy = (extractModuleHierarchy(project)).hierarchy; 33 | SymbolHierarchy symbolHierarchy = extractSymbolHierarchy(moduleHierarchy); 34 | 35 | ProjectScore projectScore = (); 36 | 37 | for (LudoscopeModule ludoscopeModule <- project.modules) 38 | { 39 | projectScore += 40 | (ludoscopeModule.name : calculateModuleScore(ludoscopeModule, symbolHierarchy)); 41 | } 42 | 43 | return projectScore; 44 | } 45 | 46 | private ModuleScore calculateModuleScore 47 | ( 48 | LudoscopeModule ludoscopeModule, 49 | SymbolHierarchy symbolHierarchy 50 | ) 51 | { 52 | return (ruleName : calculateRuleScore(symbolHierarchy, ludoscopeModule.rules[ruleName]) 53 | | str ruleName <- ludoscopeModule.rules); 54 | } 55 | 56 | private list[RightHandScore] calculateRuleScore 57 | ( 58 | SymbolHierarchy symbolHierarchy, 59 | Rule rule 60 | ) 61 | { 62 | list[RightHandScore] rightHandScores = []; 63 | Detail detail = symbolHierarchyToDetail(symbolHierarchy); 64 | list[MadRuleMap] madRuleMaps = 65 | ludoscopeRuleToMadRuleMaps(rule); 66 | 67 | list[MadRuleScoreMap] madRuleScores = 68 | [ 69 | | MadRuleMap madRuleMap <- madRuleMaps]; 70 | 71 | return madRuleScoreMapToRightHandScores(madRuleScores); 72 | } -------------------------------------------------------------------------------- /LL/src/tests/parsing/Alphabet.rsc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Parsing tests for .alp files. 4 | // @brief This file contains unit tests for parsing .alp files to an AST 5 | // @contributor Quinten Heijn - samuel.heijn@gmail.com - UvA 6 | // @date 06-04-2018 7 | // 8 | ////////////////////////////////////////////////////////////////////////////// 9 | 10 | module tests::parsing::Alphabet 11 | 12 | import parsing::Parser; 13 | import tests::parsing::Utility; 14 | 15 | loc fileLocation = |project://LL/src/tests/correctTestData/isolatedAlphabets/notSet.txt|; 16 | SyntaxTree emptySyntaxTree = syntaxTree([], (), (), (), [], []); 17 | 18 | public bool runAllTests() 19 | { 20 | return tryParsingOnlyColors() 21 | && tryParsingColorsAndAbbreviation() 22 | && tryParsingCompleteSymbol() 23 | && tryParsingMixedSymbols(); 24 | } 25 | 26 | ////////////////////////////////////////////////////////////////////////////// 27 | // Tests for parser. 28 | ////////////////////////////////////////////////////////////////////////////// 29 | 30 | private test bool tryParsingOnlyColors() 31 | { 32 | /* Arrange */ 33 | fileLocation.file = "onlyColors.alp"; 34 | 35 | /* Act */ 36 | SyntaxTree syntaxTree = parseFile(fileLocation, emptySyntaxTree); 37 | 38 | /* Assert */ 39 | return checkErrors(syntaxTree); 40 | } 41 | 42 | private test bool tryParsingColorsAndAbbreviation() 43 | { 44 | /* Arrange */ 45 | fileLocation.file = "colorsAndAbbreviation.alp"; 46 | 47 | /* Act */ 48 | SyntaxTree syntaxTree = parseFile(fileLocation, emptySyntaxTree); 49 | 50 | /* Assert */ 51 | return checkErrors(syntaxTree); 52 | } 53 | 54 | private test bool tryParsingCompleteSymbol() 55 | { 56 | /* Arrange */ 57 | fileLocation.file = "completeSymbol.alp"; 58 | 59 | /* Act */ 60 | SyntaxTree syntaxTree = parseFile(fileLocation, emptySyntaxTree); 61 | 62 | /* Assert */ 63 | return checkErrors(syntaxTree); 64 | } 65 | 66 | private test bool tryParsingMixedSymbols() 67 | { 68 | /* Arrange */ 69 | fileLocation.file = "mixedSymbols.alp"; 70 | 71 | /* Act */ 72 | SyntaxTree syntaxTree = parseFile(fileLocation, emptySyntaxTree); 73 | 74 | /* Assert */ 75 | return checkErrors(syntaxTree); 76 | } 77 | 78 | private test bool tryParsingSymbolWithWildCard() 79 | { 80 | /* Arrange */ 81 | fileLocation.file = "symbolWithWildCard.alp"; 82 | 83 | /* Act */ 84 | SyntaxTree syntaxTree = parseFile(fileLocation, emptySyntaxTree); 85 | 86 | /* Assert */ 87 | return checkErrors(syntaxTree); 88 | } 89 | -------------------------------------------------------------------------------- /LL/src/parsing/languages/alphabet/Syntax.rsc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Syntax for .alp files. 4 | // @brief This files contains the syntax needed for parsing .alp files. 5 | // .alp files contain the symbols that are used in a module. 6 | // @contributor Quinten Heijn - samuel.heijn@gmail.com - UvA 7 | // @date 03-04-2018 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | module parsing::languages::alphabet::Syntax 12 | 13 | import ParseTree; 14 | 15 | ////////////////////////////////////////////////////////////////////////////// 16 | // Syntax 17 | ////////////////////////////////////////////////////////////////////////////// 18 | 19 | start syntax Alphabet 20 | = alphabet: MapType SymbolInfo*; 21 | 22 | syntax MapType 23 | = tileMap: "TILEMAP" INTEGER width INTEGER height 24 | | string: "STRING" 25 | | graph: "GRAPH" 26 | | shape: "SHAPE"; 27 | 28 | // TODO: use variable names (as in SAnR). 29 | syntax SymbolInfo 30 | = symbolInfo: NAME name "(" 31 | "color" COLORCODE color 32 | "fill" COLORCODE fill 33 | ("abbreviation" String abbreviation)? 34 | ("shape" INTEGER shape)? 35 | ")"; 36 | 37 | syntax String 38 | = @category="String" "\"" STRING "\""; 39 | 40 | ////////////////////////////////////////////////////////////////////////////// 41 | // Lexer Rules 42 | ////////////////////////////////////////////////////////////////////////////// 43 | 44 | lexical NAME 45 | = @category="Name" ([a-zA-Z_$] [a-zA-Z0-9_$]* !>> [a-zA-Z0-9_$]) \ Keyword 46 | | @category="Name" "*"; 47 | 48 | lexical COLORCODE 49 | = @category="ColorCode" "#" [0-9A-F] [0-9A-F] [0-9A-F] [0-9A-F] [0-9A-F] [0-9A-F]; 50 | 51 | lexical INTEGER 52 | = "-"?[0-9]+; 53 | 54 | lexical STRING 55 | = ![\"]*; 56 | 57 | ////////////////////////////////////////////////////////////////////////////// 58 | // Layout 59 | ////////////////////////////////////////////////////////////////////////////// 60 | 61 | layout LAYOUTLIST 62 | = LAYOUT* !>> [\t-\n \r \ : , =]; 63 | 64 | lexical LAYOUT 65 | = [\t-\n \r \ : , =]; 66 | 67 | keyword Keyword 68 | = "color" 69 | | "fill" 70 | | "abbreviation" 71 | | "shape" 72 | | "TILEMAP" 73 | | "STRING" 74 | | "GRAPH" 75 | | "SHAPE"; 76 | 77 | ////////////////////////////////////////////////////////////////////////////// 78 | // API 79 | ////////////////////////////////////////////////////////////////////////////// 80 | 81 | public start[Alphabet] parseAlphabet(loc file) = 82 | parse(#start[Alphabet], file); 83 | 84 | public start[Alphabet] parseAlphabet(str input, loc location) 85 | { 86 | return parse(#start[Alphabet], input, location); 87 | } -------------------------------------------------------------------------------- /LL/src/parsing/languages/project/AST.rsc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // The AST used for parsing .lsp files. 4 | // @brief This file contains the data structure needed for imploding 5 | // a parsed .lsp tree. 6 | // @contributor Quinten Heijn - samuel.heijn@gmail.com - UvA 7 | // @date 03-04-2018 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | module parsing::languages::project::AST 12 | 13 | import parsing::languages::project::Syntax; 14 | import ParseTree; 15 | 16 | ////////////////////////////////////////////////////////////////////////////// 17 | // APIs 18 | ////////////////////////////////////////////////////////////////////////////// 19 | 20 | public parsing::languages::project::AST::Project implodeProject(Tree tree) 21 | = implode(#parsing::languages::project::AST::Project, tree); 22 | 23 | public parsing::languages::project::AST::Project parseProjectToAST(loc location) 24 | = implodeProject(parseProject(location)); 25 | 26 | anno loc Project@location; 27 | anno loc Declaration@location; 28 | anno loc Alphabet@location; 29 | anno loc Module@location; 30 | anno loc Register@location; 31 | anno loc Option@location; 32 | anno loc Variable@location; 33 | anno loc Position@location; 34 | 35 | ////////////////////////////////////////////////////////////////////////////// 36 | // AST 37 | ////////////////////////////////////////////////////////////////////////////// 38 | 39 | data Project 40 | = project(str version, list[Declaration] declarations); 41 | 42 | data Declaration 43 | = declaredAlphabet(Alphabet declaredAlphabet) 44 | | declaredModule(Module declaredModule) 45 | | declaredOption(Option declaredOption) 46 | | declaredRegister(Register declaredRegister); 47 | 48 | data Alphabet 49 | = alphabet(str name, Position position); 50 | 51 | data Module 52 | = lspmodule(str name, 53 | str alphabet, 54 | str position, 55 | str moduleType, 56 | str fileName, 57 | str match, 58 | list[str] inputs, 59 | str maxIterations, 60 | str moduleFilter, 61 | str grammar, 62 | str executionType, 63 | str recipe, 64 | str showMembers, 65 | str alwaysStartWithToken); 66 | 67 | data Register 68 | = register(Variable registerContent); 69 | 70 | data Option 71 | = option(Variable optionContent); 72 | 73 | data Variable 74 | = variableInteger(str name, int integer) 75 | | variableFloat(str name, str float) 76 | | variableString(str name, str string) 77 | | variableList(str name, list[str] listOfVariable) 78 | | variableBoolean(str name, bool boolean) 79 | | variablePosition(str name, Position position) 80 | | variableName(str name, str variableName) 81 | | variableNull(str name); 82 | 83 | data Position 84 | = position(int x, int y); -------------------------------------------------------------------------------- /LL/src/tests/AllTests.rsc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Tests for all functionality of LL 4 | // @brief This file contains both unit tests and integration tests for 5 | // LudoscopeLight. They can all be run using ':test' in 6 | // the console. 7 | // @contributor Quinten Heijn - samuel.heijn@gmail.com - UvA 8 | // @date 06-04-2018 9 | // 10 | ////////////////////////////////////////////////////////////////////////////// 11 | 12 | module tests::AllTests 13 | 14 | import tests::parsing::Grammar; 15 | import tests::parsing::Alphabet; 16 | import tests::parsing::Recipe; 17 | import tests::parsing::Project; 18 | import tests::parsing::Checking; 19 | import tests::parsing::CompleteProjects; 20 | import tests::parsing::LevelSpecification; 21 | 22 | import tests::execution::Matching; 23 | import tests::execution::Instructions; 24 | import tests::execution::ModuleHierarchy; 25 | import tests::execution::CompleteProjects; 26 | 27 | import tests::metrics::MAD; 28 | 29 | public bool runAllTests() 30 | { 31 | return grammarTests() 32 | && alphabetTests() 33 | && recipeTests() 34 | && projectTests() 35 | && checkingTests() 36 | && completeProjectParsingTests() 37 | && matchingTests() 38 | && instructionsTests() 39 | && moduleHierarchyTests() 40 | && metricsTests() 41 | && levelSpecificationTests() 42 | && completeProjectsExecutionTests; 43 | } 44 | 45 | private test bool grammarTests() 46 | { 47 | return tests::parsing::Grammar::runAllTests(); 48 | } 49 | 50 | private test bool alphabetTests() 51 | { 52 | return tests::parsing::Alphabet::runAllTests(); 53 | } 54 | 55 | private test bool recipeTests() 56 | { 57 | return tests::parsing::Recipe::runAllTests(); 58 | } 59 | 60 | private test bool projectTests() 61 | { 62 | return tests::parsing::Project::runAllTests(); 63 | } 64 | 65 | private test bool checkingTests() 66 | { 67 | return tests::parsing::Checking::runAllTests(); 68 | } 69 | 70 | private test bool completeProjectParsingTests() 71 | { 72 | return tests::parsing::CompleteProjects::runAllTests(); 73 | } 74 | 75 | private test bool matchingTests() 76 | { 77 | return tests::execution::Matching::runAllTests(); 78 | } 79 | 80 | private test bool instructionsTests() 81 | { 82 | return tests::execution::Instructions::runAllTests(); 83 | } 84 | 85 | private test bool moduleHierarchyTests() 86 | { 87 | return tests::execution::ModuleHierarchy::runAllTests(); 88 | } 89 | 90 | private test bool metricsTests() 91 | { 92 | return tests::metrics::MAD::runAllTests(); 93 | } 94 | 95 | private test bool levelSpecificationTests() 96 | { 97 | return tests::parsing::LevelSpecification::runAllTests(); 98 | } 99 | 100 | private test bool completeProjectsExecutionTests() 101 | { 102 | return tests::execution::CompleteProjects::runAllTests(); 103 | } -------------------------------------------------------------------------------- /LL/src/tests/parsing/Recipe.rsc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Parsing tests for .rcp files. 4 | // @brief This file contains unit tests for parsing .rcp files to an AST 5 | // @contributor Quinten Heijn - samuel.heijn@gmail.com - UvA 6 | // @date 06-04-2018 7 | // 8 | ////////////////////////////////////////////////////////////////////////////// 9 | 10 | module tests::parsing::Recipe 11 | 12 | import parsing::Parser; 13 | import tests::parsing::Utility; 14 | 15 | loc fileLocation = |project://LL/src/tests/correctTestData/isolatedRecipes/notSet.txt|; 16 | SyntaxTree emptySyntaxTree = syntaxTree([], (), (), (), [], []); 17 | 18 | public bool runAllTests() 19 | { 20 | return tryParsingComment() 21 | && tryParsingSingleInstruction() 22 | && tryParsingBasicInstructions() 23 | && tryParsingAdvancedInstructions() 24 | && tryParsingAllInstructions(); 25 | } 26 | 27 | ////////////////////////////////////////////////////////////////////////////// 28 | // Tests for parser. 29 | ////////////////////////////////////////////////////////////////////////////// 30 | 31 | private test bool tryParsingComment() 32 | { 33 | /* Arrange */ 34 | fileLocation.file = "comment.rcp"; 35 | 36 | /* Act */ 37 | SyntaxTree syntaxTree = parseFile(fileLocation, emptySyntaxTree); 38 | 39 | /* Assert */ 40 | return checkErrors(syntaxTree); 41 | } 42 | 43 | private test bool tryParsingSingleInstruction() 44 | { 45 | /* Arrange */ 46 | fileLocation.file = "singleInstruction.rcp"; 47 | 48 | /* Act */ 49 | SyntaxTree syntaxTree = parseFile(fileLocation, emptySyntaxTree); 50 | 51 | /* Assert */ 52 | return checkErrors(syntaxTree); 53 | } 54 | 55 | // TODO: 56 | private test bool tryParsingDiceNotation() 57 | { 58 | /* Arrange */ 59 | fileLocation.file = "diceNotation.rcp"; 60 | 61 | /* Act */ 62 | SyntaxTree syntaxTree = parseFile(fileLocation, emptySyntaxTree); 63 | 64 | /* Assert */ 65 | return checkErrors(syntaxTree); 66 | } 67 | 68 | private test bool tryParsingBasicInstructions() 69 | { 70 | /* Arrange */ 71 | fileLocation.file = "basicInstructions.rcp"; 72 | 73 | /* Act */ 74 | SyntaxTree syntaxTree = parseFile(fileLocation, emptySyntaxTree); 75 | 76 | /* Assert */ 77 | return checkErrors(syntaxTree); 78 | } 79 | 80 | private test bool tryParsingAdvancedInstructions() 81 | { 82 | /* Arrange */ 83 | fileLocation.file = "advancedInstructions.rcp"; 84 | 85 | /* Act */ 86 | SyntaxTree syntaxTree = parseFile(fileLocation, emptySyntaxTree); 87 | 88 | /* Assert */ 89 | return checkErrors(syntaxTree); 90 | } 91 | 92 | private test bool tryParsingAllInstructions() 93 | { 94 | /* Arrange */ 95 | fileLocation.file = "allInstructions.rcp"; 96 | 97 | /* Act */ 98 | SyntaxTree syntaxTree = parseFile(fileLocation, emptySyntaxTree); 99 | 100 | /* Assert */ 101 | return checkErrors(syntaxTree); 102 | } -------------------------------------------------------------------------------- /LL/src/tests/parsing/Grammar.rsc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Parsing tests for .grm files. 4 | // @brief This file contains unit tests for parsing .grm files to an AST 5 | // @contributor Quinten Heijn - samuel.heijn@gmail.com - UvA 6 | // @date 06-04-2018 7 | // 8 | ////////////////////////////////////////////////////////////////////////////// 9 | 10 | module tests::parsing::Grammar 11 | 12 | import parsing::Parser; 13 | import tests::parsing::Utility; 14 | 15 | loc fileLocation = |project://LL/src/tests/correctTestData/isolatedGrammars/notSet.txt|; 16 | SyntaxTree emptySyntaxTree = syntaxTree([], (), (), (), [], []); 17 | 18 | public bool runAllTests() 19 | { 20 | return tryParsingAllOptions() 21 | && tryParsingAllRuleSettings() 22 | && tryParsingOnlyStart() 23 | && tryParsingAllMemberTypes() 24 | && tryParsingRuleWithMultipleRightHands() 25 | && tryParsingSimpleRule(); 26 | } 27 | 28 | ////////////////////////////////////////////////////////////////////////////// 29 | // Tests for parser. 30 | ////////////////////////////////////////////////////////////////////////////// 31 | 32 | private test bool tryParsingAllOptions() 33 | { 34 | /* Arrange */ 35 | fileLocation.file = "allOptions.grm"; 36 | 37 | /* Act */ 38 | SyntaxTree syntaxTree = parseFile(fileLocation, emptySyntaxTree); 39 | 40 | /* Assert */ 41 | return checkErrors(syntaxTree); 42 | } 43 | 44 | private test bool tryParsingAllRuleSettings() 45 | { 46 | /* Arrange */ 47 | fileLocation.file = "allRuleSettings.grm"; 48 | 49 | /* Act */ 50 | SyntaxTree syntaxTree = parseFile(fileLocation, emptySyntaxTree); 51 | 52 | /* Assert */ 53 | return checkErrors(syntaxTree); 54 | } 55 | 56 | private test bool tryParsingOnlyStart() 57 | { 58 | /* Arrange */ 59 | fileLocation.file = "onlyStart.grm"; 60 | 61 | /* Act */ 62 | SyntaxTree syntaxTree = parseFile(fileLocation, emptySyntaxTree); 63 | 64 | /* Assert */ 65 | return checkErrors(syntaxTree); 66 | } 67 | 68 | public test bool tryParsingAllMemberTypes() 69 | { 70 | /* Arrange */ 71 | fileLocation.file = "allMemberTypes.grm"; 72 | 73 | /* Act */ 74 | SyntaxTree syntaxTree = parseFile(fileLocation, emptySyntaxTree); 75 | 76 | /* Assert */ 77 | return checkErrors(syntaxTree); 78 | } 79 | 80 | private test bool tryParsingRuleWithMultipleRightHands() 81 | { 82 | /* Arrange */ 83 | fileLocation.file = "ruleWithMultipleRightHands.grm"; 84 | 85 | /* Act */ 86 | SyntaxTree syntaxTree = parseFile(fileLocation, emptySyntaxTree); 87 | 88 | /* Assert */ 89 | return checkErrors(syntaxTree); 90 | } 91 | 92 | 93 | private test bool tryParsingSimpleRule() 94 | { 95 | /* Arrange */ 96 | fileLocation.file = "simpleRule.grm"; 97 | 98 | /* Act */ 99 | SyntaxTree syntaxTree = parseFile(fileLocation, emptySyntaxTree); 100 | 101 | /* Assert */ 102 | return checkErrors(syntaxTree); 103 | } -------------------------------------------------------------------------------- /LL/src/tests/correctTestData/isolatedProjects/complexProject.lsp: -------------------------------------------------------------------------------- 1 | version: 0.6f 2 | alphabet: 3 | name: "MapTiles" 4 | position: (-181,-124) 5 | 6 | module: 7 | name: "Start" 8 | alphabet: "MapTiles" 9 | position: (-237,38) 10 | type: Recipe 11 | match: None 12 | grammar: true 13 | recipe: true 14 | showMembers: true 15 | 16 | module: 17 | name: "AddRequests" 18 | alphabet: "MapTiles" 19 | position: (-149,38) 20 | type: Recipe 21 | match: None 22 | inputs: "Start" 23 | grammar: true 24 | recipe: true 25 | showMembers: true 26 | 27 | module: 28 | name: "DoDecoration" 29 | alphabet: "MapTiles" 30 | position: (142,42) 31 | type: Recipe 32 | match: None 33 | inputs: "CombineTerrain" 34 | grammar: true 35 | executionType: Cellular 36 | recipe: true 37 | showMembers: true 38 | 39 | module: 40 | name: "Enlarge" 41 | alphabet: "MapTiles" 42 | position: (-37,40) 43 | type: Recipe 44 | match: None 45 | inputs: "AddRequests" 46 | maxIterations: 2 47 | grammar: true 48 | executionType: LSystem 49 | recipe: true 50 | showMembers: true 51 | 52 | module: 53 | name: "CombineTerrain" 54 | alphabet: "MapTiles" 55 | position: (73,36) 56 | type: Recipe 57 | match: StackTiles 58 | inputs: "Enlarge" "SeedTerrain" 59 | grammar: true 60 | executionType: LSystem 61 | recipe: true 62 | showMembers: true 63 | 64 | module: 65 | name: "SeedTerrain" 66 | alphabet: "MapTiles" 67 | position: (7,-26) 68 | type: Recipe 69 | match: None 70 | inputs: "Enlarge" 71 | grammar: true 72 | executionType: Cellular 73 | recipe: true 74 | showMembers: true 75 | 76 | module: 77 | name: "DoGround" 78 | alphabet: "MapTiles" 79 | position: (145,-30) 80 | type: Recipe 81 | match: None 82 | inputs: "CombineTerrain" 83 | grammar: true 84 | executionType: LSystem 85 | recipe: true 86 | showMembers: true 87 | 88 | module: 89 | name: "Recombine" 90 | alphabet: "MapTiles" 91 | position: (237,56) 92 | type: Recipe 93 | match: StackTiles 94 | inputs: "DoGround" "DoDecoration" "SetSpawnLocations" 95 | maxIterations: 5 96 | grammar: true 97 | recipe: true 98 | showMembers: true 99 | 100 | module: 101 | name: "SetSpawnLocations" 102 | alphabet: "MapTiles" 103 | position: (144,124) 104 | type: Recipe 105 | match: None 106 | inputs: "CombineTerrain" 107 | maxIterations: 5 108 | grammar: true 109 | executionType: LSystem 110 | recipe: true 111 | showMembers: true 112 | 113 | register: width 9 114 | register: height 5 115 | register: requests ["moonlight", "flowstone", "bigLeaves"] 116 | register: setRequests false 117 | register: terrainA "high" 118 | register: terrainB "bushes" 119 | register: terrainC "bushes" 120 | register: terrainD "shallowWater" 121 | register: terrainE "bushes" 122 | register: terrainF "bushes" 123 | register: elevation 12 124 | register: entrance "west" 125 | register: barrierX null 126 | option: Width 9 127 | option: Height 5 128 | option: Tile "undefined" 129 | option: Register "requests" 130 | option: Find "blocked" 131 | option: Replace "undefined" 132 | option: SplitX 5 133 | option: SplitY 5 134 | -------------------------------------------------------------------------------- /LL/src/tests/execution/ModuleHierarchy.rsc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Tests for extracting module hierarchy 4 | // @brief This file contains test functions to check if the module 5 | // hierarchy if extracted correctly. 6 | // @contributor Quinten Heijn - samuel.heijn@gmail.com - UvA 7 | // @date 17-05-2018 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | module tests::execution::ModuleHierarchy 12 | 13 | import List; 14 | import sanr::language::AST; 15 | import parsing::DataStructures; 16 | import execution::DataStructures; 17 | import execution::ModuleHierarchy; 18 | 19 | public bool runAllTests() 20 | { 21 | return simpleHierarchy() 22 | && complexHierarchy() 23 | && incorrectHierarchy(); 24 | } 25 | 26 | private test bool simpleHierarchy() 27 | { 28 | /* Arrange */ 29 | LudoscopeModule module1 = ludoscopeModule("module1", [], "", [[]], (), []); 30 | LudoscopeModule module2 = ludoscopeModule("module2", ["module1"], "", [[]], (), []); 31 | LudoscopeModule module3 = ludoscopeModule("module3", ["module2"], "", [[]], (), []); 32 | LudoscopeProject project = ludoscopeProject([module1, module2, module3], (), specification([])); 33 | 34 | ModuleHierarchy expectedOutput = [{module1}, {module2}, {module3}]; 35 | 36 | /* Act */ 37 | PreparationArtifact artifact = extractModuleHierarchy(project); 38 | 39 | /* Assert */ 40 | return artifact.errors == [] 41 | && artifact.hierarchy == expectedOutput; 42 | } 43 | 44 | private test bool complexHierarchy() 45 | { 46 | /* Arrange */ 47 | LudoscopeModule module1 = ludoscopeModule("module1", [], "", [[]], (), []); 48 | LudoscopeModule module2 = ludoscopeModule("module2", ["module1"], "", [[]], (), []); 49 | LudoscopeModule module3 = ludoscopeModule("module3", ["module1"], "", [[]], (), []); 50 | LudoscopeModule module4 = ludoscopeModule("module4", ["module2", "module3"], "", [[]], (), []); 51 | LudoscopeProject project = ludoscopeProject([module1, module2, module3, module4], (), specification([])); 52 | 53 | ModuleHierarchy expectedOutput = [{module1}, {module2, module3}, {module4}]; 54 | 55 | /* Act */ 56 | PreparationArtifact artifact = extractModuleHierarchy(project); 57 | 58 | /* Assert */ 59 | return artifact.errors == [] && artifact.hierarchy == expectedOutput; 60 | } 61 | 62 | public test bool incorrectHierarchy() 63 | { 64 | /* Arrange */ 65 | LudoscopeModule module1 = ludoscopeModule("module1", [], "", [[]], (), []); 66 | LudoscopeModule module2 = ludoscopeModule("module2", ["module2"], "", [[]], (), []); 67 | LudoscopeModule module3 = ludoscopeModule("module3", ["module3"], "", [[]], (), []); 68 | LudoscopeProject project = ludoscopeProject([module1, module2, module3], (), specification([])); 69 | 70 | ModuleHierarchy expectedOutput = [{module1}]; 71 | 72 | /* Act */ 73 | PreparationArtifact artifact = extractModuleHierarchy(project); 74 | 75 | /* Assert */ 76 | return size(artifact.errors) == 1 && artifact.hierarchy == expectedOutput; 77 | } -------------------------------------------------------------------------------- /LL/src/tests/execution/History.rsc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Tests for execution history. 4 | // @brief This file contains all creating an history of the execution. 5 | // @contributor Quinten Heijn - samuel.heijn@gmail.com - UvA 6 | // @date 20-04-2018 7 | // 8 | ////////////////////////////////////////////////////////////////////////////// 9 | 10 | module tests::execution::History 11 | 12 | import IO; 13 | import execution::Execution; 14 | import execution::DataStructures; 15 | import execution::instructions::Instructions; 16 | import parsing::DataStructures; 17 | import sanr::language::AST; 18 | 19 | public bool runAllTests() 20 | { 21 | return checkHistorySingleModule() 22 | && checkHistoryMultipleModules(); 23 | } 24 | 25 | private test bool checkHistorySingleModule() 26 | { 27 | /* Arrange */ 28 | RuleMap rules = ("rule1" : rule(reflections(false,false,false),[["1"]],[[["2"]]]), 29 | "rule2" : rule(reflections(false,false,false),[["2"]],[[["3"]]])); 30 | TileMap startingMap = [["1"]]; 31 | LudoscopeModule module1 = 32 | ludoscopeModule("module1", [], "alphabet", startingMap, rules, [executeGrammar()]); 33 | LudoscopeProject project = ludoscopeProject([module1], (), specification([])); 34 | 35 | Step step1 = step([["2"]], "module1", itterateRule("rule1"), "rule1", 0, coordinates(0,0)); 36 | Step step2 = step([["3"]], "module1", itterateRule("rule2"), "rule2", 0, coordinates(0,0)); 37 | 38 | ExecutionHistory expectedResult = [step1, step2]; 39 | 40 | /* Act */ 41 | ExecutionArtifact result = executeProject(project); 42 | 43 | /* Assert */ 44 | return expectedResult == result.history; 45 | } 46 | 47 | public test bool checkHistoryMultipleModules() 48 | { 49 | /* Arrange */ 50 | RuleMap rules1 = ("rule1" : rule(reflections(false,false,false),[["1"]],[[["2"]]]), 51 | "rule2" : rule(reflections(false,false,false),[["2"]],[[["3"]]])); 52 | RuleMap rules2 = ("rule1" : rule(reflections(false,false,false),[["3"]],[[["2"]]]), 53 | "rule2" : rule(reflections(false,false,false),[["2"]],[[["1"]]])); 54 | TileMap startingMap = [["1"]]; 55 | LudoscopeModule module1 = 56 | ludoscopeModule("module1", [], "alphabet", startingMap, rules1, [executeGrammar()]); 57 | LudoscopeModule module2 = 58 | ludoscopeModule("module2", ["module1"], "alphabet", startingMap, rules2, [executeGrammar()]); 59 | LudoscopeProject project = ludoscopeProject([module1, module2], (), specification([])); 60 | 61 | Step step1 = step([["2"]], "module1", itterateRule("rule1"), "rule1", 0, coordinates(0,0)); 62 | Step step2 = step([["3"]], "module1", itterateRule("rule2"), "rule2", 0, coordinates(0,0)); 63 | Step step3 = step([["2"]], "module2", itterateRule("rule1"), "rule1", 0, coordinates(0,0)); 64 | Step step4 = step([["1"]], "module2", itterateRule("rule2"), "rule2", 0, coordinates(0,0)); 65 | 66 | ExecutionHistory expectedResult = [step1, step2, step3, step4]; 67 | 68 | /* Act */ 69 | ExecutionArtifact result = executeProject(project); 70 | 71 | /* Assert */ 72 | return expectedResult == result.history; 73 | } -------------------------------------------------------------------------------- /LL/src/analysis/sanrWrapper/PropertyHistory.rsc: -------------------------------------------------------------------------------- 1 | module analysis::sanrWrapper::PropertyHistory 2 | 3 | import List; 4 | import utility::TileMap; 5 | import parsing::DataStructures; 6 | import execution::DataStructures; 7 | import execution::history::DataStructures; 8 | 9 | import sanr::PropertyValidation; 10 | import sanr::DataStructures; 11 | import sanr::language::AST; 12 | 13 | ////////////////////////////////////////////////////////////////////////////// 14 | // Initialize property report. 15 | ////////////////////////////////////////////////////////////////////////////// 16 | 17 | public PropertyReport initializeReport 18 | ( 19 | int width, 20 | int height, 21 | LevelSpecification specification 22 | ) 23 | { 24 | ExtendedTileMaps maps = generateSartingMaps(width, height); 25 | PropertyStates propertyStates = 26 | [false | Property property <- specification.properties]; 27 | 28 | return propertyReport(specification, [reportState(maps, propertyStates)]); 29 | } 30 | 31 | /* 'ALL' is used in the history, so SAnR can use a filter that matches every tile. */ 32 | public ExtendedTileMaps generateSartingMaps 33 | ( 34 | int width, 35 | int height 36 | ) 37 | { 38 | Map currentSymbolMap = createTileMap(ALL, width, height); 39 | Map currentRuleMap = createTileMap(ALL, width, height); 40 | return extendedTileMaps(currentSymbolMap, currentRuleMap); 41 | } 42 | 43 | ////////////////////////////////////////////////////////////////////////////// 44 | // Update report. 45 | ////////////////////////////////////////////////////////////////////////////// 46 | 47 | public PropertyReport updatePropertyReport(ExecutionArtifact artifact) 48 | { 49 | ExtendedTileMaps maps = extractExtendedTileMaps(artifact); 50 | PropertyStates propertyStates = 51 | [checkProperty(property, artifact.propertyReport.history, maps.tileMap) 52 | | Property property <- artifact.propertyReport.specification.properties]; 53 | artifact.propertyReport.history += [reportState(maps, propertyStates)]; 54 | return artifact.propertyReport; 55 | } 56 | 57 | public ExtendedTileMaps extractExtendedTileMaps 58 | ( 59 | ExecutionArtifact artifact 60 | ) 61 | { 62 | /* Retrieve information from the generation history. */ 63 | Step step = artifact.history[0]; 64 | str ruleName = step.ruleName; 65 | ReportState previousState = last(artifact.propertyReport.history); 66 | Map previousSymbolMap = previousState.mapStates.tileMap; 67 | 68 | /* Generate maps for the current state. */ 69 | Map currentSymbolMap = artifact.currentState; 70 | Map currentRuleMap = updateMap(previousState.mapStates.ruleMap, 71 | previousSymbolMap, 72 | currentSymbolMap, 73 | ruleName); 74 | return extendedTileMaps(currentSymbolMap, currentRuleMap); 75 | } 76 | 77 | private Map updateMap 78 | ( 79 | Map toBeUpdated, 80 | Map previousState, 81 | Map currentState, 82 | str structureName 83 | ) 84 | { 85 | for (int y <- [0 .. size(previousState)]) 86 | { 87 | for (int x <- [0 .. size(previousState[0])]) 88 | { 89 | if (previousState[y][x] != currentState[y][x]) 90 | { 91 | toBeUpdated[y][x] = structureName; 92 | } 93 | } 94 | } 95 | return toBeUpdated; 96 | } -------------------------------------------------------------------------------- /LL/src/parsing/check/Maps.rsc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Check maps 4 | // @brief Functions that check for three different errors in maps. 5 | // - Check if the map type is supported. 6 | // - Check if the map size matches the number of symbols. 7 | // - Check if the dimensions of the left hand match 8 | // the dimensions of the right hands. 9 | // @contributor Quinten Heijn - samuel.heijn@gmail.com - UvA 10 | // @date 24-04-2018 11 | // 12 | ////////////////////////////////////////////////////////////////////////////// 13 | 14 | module parsing::check::Maps 15 | 16 | import parsing::languages::grammar::AST; 17 | 18 | import List; 19 | import parsing::Parser; 20 | import errors::Parsing; 21 | 22 | alias AbstractGrammar = parsing::languages::grammar::AST::Grammar; 23 | 24 | public SyntaxTree checkMapTypes(SyntaxTree syntaxTree) 25 | { 26 | for (str grammarName <- syntaxTree.grammars) 27 | { 28 | visit(syntaxTree.grammars[grammarName]) 29 | { 30 | case MapType abstractMap: 31 | { 32 | switch(abstractMap) 33 | { 34 | case string() : syntaxTree.errors += 35 | [mapType("string", abstractMap@location)]; 36 | case graph() : syntaxTree.errors += 37 | [mapType("graph", abstractMap@location)]; 38 | case shape() : syntaxTree.errors += 39 | [mapType("shape", abstractMap@location)]; 40 | } 41 | } 42 | } 43 | } 44 | return syntaxTree; 45 | } 46 | 47 | public SyntaxTree checkMapSize(SyntaxTree syntaxTree) 48 | { 49 | for (str grammarName <- syntaxTree.grammars) 50 | { 51 | visit(syntaxTree.grammars[grammarName]) 52 | { 53 | case expression(MapType mapType, list[Symbol] symbols) : 54 | { 55 | if (mapType.width * mapType.height != size(symbols)) 56 | { 57 | syntaxTree.errors += [mapSize(mapType.width * mapType.height, 58 | size(symbols), mapType@location)]; 59 | } 60 | } 61 | case leftHandExpression(MapType mapType, list[MatchingSymbol] symbols) : 62 | { 63 | if (mapType.width * mapType.height != size(symbols)) 64 | { 65 | syntaxTree.errors += [mapSize(mapType.width * mapType.height, 66 | size(symbols), mapType@location)]; 67 | } 68 | } 69 | } 70 | } 71 | return syntaxTree; 72 | } 73 | 74 | public SyntaxTree compareLeftAndRightHandSize(SyntaxTree syntaxTree) 75 | { 76 | for (str grammarName <- syntaxTree.grammars) 77 | { 78 | visit(syntaxTree.grammars[grammarName]) 79 | { 80 | case rule(str name, list[RuleSetting] settings, LeftHandExpression leftHand, 81 | list[RightHandExpression] rightHands) : 82 | { 83 | MapType leftHandMap = leftHand.mapType; 84 | for (RightHandExpression rightHand <- rightHands) 85 | { 86 | MapType rightHandMap = rightHand.expression.mapType; 87 | if (rightHandMap !:= leftHandMap) 88 | { 89 | syntaxTree.errors += [rightAndLeftHandSize(leftHandMap.width, 90 | leftHandMap.height, 91 | rightHandMap.width, 92 | rightHandMap.height, 93 | rightHandMap@location)]; 94 | } 95 | } 96 | } 97 | } 98 | } 99 | return syntaxTree; 100 | } -------------------------------------------------------------------------------- /LL/src/tests/parsing/Project.rsc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Parsing tests for .lsp files. 4 | // @brief This file contains unit tests for parsing .lsp files to an AST 5 | // @contributor Quinten Heijn - samuel.heijn@gmail.com - UvA 6 | // @date 06-04-2018 7 | // 8 | ////////////////////////////////////////////////////////////////////////////// 9 | 10 | module tests::parsing::Project 11 | 12 | import parsing::Parser; 13 | import tests::parsing::Utility; 14 | 15 | loc fileLocation = |project://LL/src/tests/correctTestData/isolatedProjects/notSet.txt|; 16 | SyntaxTree emptySyntaxTree = syntaxTree([], (), (), (), [], []); 17 | 18 | public bool runAllTests() 19 | { 20 | return tryParsingOnlyAlphabet() 21 | && tryParsingOptions() 22 | && tryParsingRegisters() 23 | && tryParsingSingleModule() 24 | && tryParsingMultipleModulesWithAlphabet() 25 | && tryParsingCompleteModule() 26 | && tryParsingComplexProject(); 27 | } 28 | 29 | ////////////////////////////////////////////////////////////////////////////// 30 | // Tests for parser. 31 | ////////////////////////////////////////////////////////////////////////////// 32 | 33 | private test bool tryParsingOnlyAlphabet() 34 | { 35 | /* Arrange */ 36 | fileLocation.file = "onlyAlphabet.lsp"; 37 | 38 | /* Act */ 39 | SyntaxTree syntaxTree = parseFile(fileLocation, emptySyntaxTree); 40 | 41 | /* Assert */ 42 | return checkErrors(syntaxTree); 43 | } 44 | 45 | private test bool tryParsingOptions() 46 | { 47 | /* Arrange */ 48 | fileLocation.file = "options.lsp"; 49 | 50 | /* Act */ 51 | SyntaxTree syntaxTree = parseFile(fileLocation, emptySyntaxTree); 52 | 53 | /* Assert */ 54 | return checkErrors(syntaxTree); 55 | } 56 | 57 | private test bool tryParsingRegisters() 58 | { 59 | /* Arrange */ 60 | fileLocation.file = "registers.lsp"; 61 | 62 | /* Act */ 63 | SyntaxTree syntaxTree = parseFile(fileLocation, emptySyntaxTree); 64 | 65 | /* Assert */ 66 | return checkErrors(syntaxTree); 67 | } 68 | 69 | private test bool tryParsingSingleModule() 70 | { 71 | /* Arrange */ 72 | fileLocation.file = "singleModule.lsp"; 73 | 74 | /* Act */ 75 | SyntaxTree syntaxTree = parseFile(fileLocation, emptySyntaxTree); 76 | 77 | /* Assert */ 78 | return checkErrors(syntaxTree); 79 | } 80 | 81 | private test bool tryParsingMultipleModulesWithAlphabet() 82 | { 83 | /* Arrange */ 84 | fileLocation.file = "multipleModulesWithAlphabet.lsp"; 85 | 86 | /* Act */ 87 | SyntaxTree syntaxTree = parseFile(fileLocation, emptySyntaxTree); 88 | 89 | /* Assert */ 90 | return checkErrors(syntaxTree); 91 | } 92 | 93 | private test bool tryParsingCompleteModule() 94 | { 95 | /* Arrange */ 96 | fileLocation.file = "completeModule.lsp"; 97 | 98 | /* Act */ 99 | SyntaxTree syntaxTree = parseFile(fileLocation, emptySyntaxTree); 100 | 101 | /* Assert */ 102 | return checkErrors(syntaxTree); 103 | } 104 | 105 | private test bool tryParsingComplexProject() 106 | { 107 | /* Arrange */ 108 | fileLocation.file = "complexProject.lsp"; 109 | 110 | /* Act */ 111 | SyntaxTree syntaxTree = parseFile(fileLocation, emptySyntaxTree); 112 | 113 | /* Assert */ 114 | return checkErrors(syntaxTree); 115 | } -------------------------------------------------------------------------------- /LL/src/parsing/check/Names.rsc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Check Property Names 4 | // @brief This file contains the functions to check if a propety name 5 | // refers to the right data structure in the project. 6 | // @contributor Quinten Heijn - samuel.heijn@gmail.com - UvA 7 | // @date 28-05-2018 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | module parsing::check::Names 12 | 13 | import errors::Parsing; 14 | import parsing::DataStructures; 15 | import sanr::language::AST; 16 | import parsing::languages::alphabet::AST; 17 | 18 | data Name 19 | = tileName() 20 | | ruleName() 21 | | moduleName() 22 | | undefinedName(); 23 | 24 | public TransformationArtifact checkPropertyNames 25 | ( 26 | TransformationArtifact artifact 27 | ) 28 | { 29 | for (Property property <- artifact.project.specification.properties) 30 | { 31 | visit (property) 32 | { 33 | case tileSet(str tileName, FilterNow filterNow, FilterWhere filterWhere) : 34 | { 35 | artifact = checkTileName(artifact, tileName, property@location); 36 | } 37 | case nowAdjacent(str tileName) : 38 | { 39 | artifact = checkTileName(artifact, tileName, property@location); 40 | } 41 | case everRule(str ruleName) : 42 | { 43 | artifact = checkRuleName(artifact, ruleName, property@location); 44 | } 45 | } 46 | } 47 | return artifact; 48 | } 49 | 50 | private TransformationArtifact checkTileName 51 | ( 52 | TransformationArtifact artifact, 53 | str tileName, 54 | loc propertyLocation 55 | ) 56 | { 57 | Name name = findName(artifact, tileName); 58 | switch(name) 59 | { 60 | case undefinedName() : 61 | { 62 | artifact.errors = [propertyName(tileName, propertyLocation)]; 63 | } 64 | case ruleName() : 65 | { 66 | artifact.errors = [nameType("tile", "rule", propertyLocation)]; 67 | } 68 | case moduleName() : 69 | { 70 | artifact.errors = [nameType("tile", "module", propertyLocation)]; 71 | } 72 | } 73 | return artifact; 74 | } 75 | 76 | private TransformationArtifact checkRuleName 77 | ( 78 | TransformationArtifact artifact, 79 | str ruleName, 80 | loc propertyLocation 81 | ) 82 | { 83 | Name name = findName(artifact, ruleName); 84 | switch(name) 85 | { 86 | case undefinedName() : 87 | { 88 | artifact.errors = [propertyName(ruleName, propertyLocation)]; 89 | } 90 | case tileName() : 91 | { 92 | artifact.errors = [nameType("rule", "tile", propertyLocation)]; 93 | } 94 | case moduleName() : 95 | { 96 | artifact.errors = [nameType("rule", "module", propertyLocation)]; 97 | } 98 | } 99 | return artifact; 100 | } 101 | 102 | public Name findName 103 | ( 104 | TransformationArtifact artifact, 105 | str name 106 | ) 107 | { 108 | visit(artifact) 109 | { 110 | case symbolInfo(str symbolName, str color, str fill, str abbreviation, str shape) : 111 | { 112 | if (symbolName == name) 113 | { 114 | return tileName(); 115 | } 116 | } 117 | case ludoscopeModule(str moduleName, 118 | list[str] inputs, 119 | str alphabetName, 120 | TileMap startingState, 121 | RuleMap rules, 122 | Recipe recipe) : 123 | { 124 | if (name in rules) 125 | { 126 | return ruleName(); 127 | } 128 | if (moduleName == name) 129 | { 130 | return moduleName(); 131 | } 132 | } 133 | } 134 | return undefinedName(); 135 | } -------------------------------------------------------------------------------- /LL/src/ide/Registration.rsc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Language Registration 4 | // @brief This file contains functions that register the languages, 5 | // add syntax high ligths and menu items. 6 | // @contributor Quinten Heijn - samuel.heijn@gmail.com - UvA 7 | // @date 02-05-2018 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | module ide::Registration 12 | 13 | import util::IDE; 14 | import ParseTree; 15 | import vis::Figure; 16 | 17 | import ide::MenuFunctions; 18 | 19 | import parsing::languages::alphabet::Syntax; 20 | import parsing::languages::project::Syntax; 21 | import parsing::languages::grammar::Syntax; 22 | import parsing::languages::recipe::Syntax; 23 | import sanr::language::Syntax; 24 | 25 | str ALPHABETNAME = "Ludoscope Alphabet"; 26 | str PROJECTNAME = "Ludoscope Project"; 27 | str GRAMMARNAME = "Ludoscope Grammar"; 28 | str RECIPENAME = "Ludoscope Recipe"; 29 | str PROPERTIESNAME = "Ludoscope Properties"; 30 | 31 | str ALPHABETABBREVIATION = "alp"; 32 | str PROJECTABBREVIATION = "lsp"; 33 | str GRAMMARABBREVIATION = "grm"; 34 | str RECIPENABBREVIATION = "rcp"; 35 | str PROPERTIESABBREVIATTION = "sanr"; 36 | 37 | Contribution STYLE = 38 | categories 39 | ( 40 | ( 41 | "String" : {foregroundColor(color("purple"))}, 42 | "Name" : {bold()}, 43 | "ColorCode" : {foregroundColor(color("Violet"))}, 44 | "Boolean" : {foregroundColor(color("Black")), bold()} 45 | ) 46 | ); 47 | 48 | public void registerLanguages() 49 | { 50 | registerLanguage(ALPHABETNAME, ALPHABETABBREVIATION, parseAlphabet); 51 | registerLanguage(PROJECTNAME, PROJECTABBREVIATION, parsing::languages::project::Syntax::parseProject); 52 | registerLanguage(GRAMMARNAME, GRAMMARABBREVIATION, parseGrammar); 53 | registerLanguage(RECIPENAME, RECIPENABBREVIATION, parseRecipe); 54 | registerLanguage(PROPERTIESNAME, PROPERTIESABBREVIATTION, parseSAnR); 55 | } 56 | 57 | public void addSyntaxHighLights() 58 | { 59 | set[Contribution] styleContributions = 60 | { 61 | STYLE 62 | }; 63 | 64 | registerContributions(ALPHABETNAME, styleContributions); 65 | registerContributions(PROJECTNAME, styleContributions); 66 | registerContributions(GRAMMARNAME, styleContributions); 67 | registerContributions(RECIPENAME, styleContributions); 68 | registerContributions(PROPERTIESNAME, styleContributions); 69 | } 70 | 71 | public void addMenuItems() 72 | { 73 | set[Contribution] menuItems = 74 | { 75 | STYLE, 76 | popup 77 | ( 78 | menu 79 | ( 80 | "LL: basic functions", 81 | [ 82 | action("Parse and transform", parseAndTransform), 83 | action("Execute project", executeProject), 84 | action("Execute and save result", executeProjectToFile) 85 | ] 86 | ) 87 | ), 88 | popup 89 | ( 90 | menu 91 | ( 92 | "SAnR", 93 | [ 94 | action("SAnR report to file", sanrReportToFile) 95 | ] 96 | ) 97 | ), 98 | popup 99 | ( 100 | menu 101 | ( 102 | "LL: Timed execution", 103 | [ 104 | action("1x", timeExecution1x), 105 | action("100x", timeExecution100x), 106 | action("10000x", timeExecution10000x) 107 | ] 108 | ) 109 | ) 110 | }; 111 | 112 | registerContributions(PROJECTNAME, menuItems); 113 | } -------------------------------------------------------------------------------- /LL/src/execution/Execution.rsc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Project execution 4 | // @brief This file contains functions that execute a parsed LL project. 5 | // @contributor Quinten Heijn - samuel.heijn@gmail.com - UvA 6 | // @date 01-05-2018 7 | // 8 | ////////////////////////////////////////////////////////////////////////////// 9 | 10 | module execution::Execution 11 | 12 | import IO; 13 | import List; 14 | import Set; 15 | 16 | import errors::Execution; 17 | 18 | import parsing::Interface; 19 | import parsing::DataStructures; 20 | 21 | import execution::instructions::Instructions; 22 | import execution::DataStructures; 23 | import execution::ModuleHierarchy; 24 | 25 | import analysis::sanrWrapper::PropertyHistory; 26 | import sanr::DataStructures; 27 | 28 | public ExecutionArtifact executeProject(LudoscopeProject project) 29 | { 30 | list[LudoscopeModule] modules = project.modules; 31 | PreparationArtifact preparationArtifact = extractModuleHierarchy(project); 32 | 33 | if (preparationArtifact.errors != []) 34 | { 35 | artifact.errors = preparationArtifact.errors; 36 | return artifact; 37 | } 38 | 39 | /* Initiliaze Property Report */ 40 | LudoscopeModule ludoscopeModule = getOneFrom(preparationArtifact.hierarchy[0]); 41 | int width = size(ludoscopeModule.startingState[0]); 42 | int height = size(ludoscopeModule.startingState); 43 | PropertyReport propertyReport = 44 | initializeReport(width, height, project.specification); 45 | 46 | ExecutionArtifact artifact = executionArtifact((), [], [], propertyReport, []); 47 | 48 | /* Execute all modules. */ 49 | for (set[LudoscopeModule] moduleGroup <- preparationArtifact.hierarchy) 50 | { 51 | for (LudoscopeModule currentModule <- moduleGroup) 52 | { 53 | artifact = executeModule(artifact, currentModule); 54 | } 55 | } 56 | artifact.history = reverse(artifact.history); 57 | return artifact; 58 | } 59 | 60 | public ExecutionArtifact executeModule 61 | ( 62 | ExecutionArtifact artifact, 63 | LudoscopeModule ludoscopeModule 64 | ) 65 | { 66 | switch (size(ludoscopeModule.inputs)) 67 | { 68 | case 0 : 69 | { 70 | artifact.currentState = ludoscopeModule.startingState; 71 | artifact = executeRecipe(artifact, ludoscopeModule); 72 | } 73 | case 1 : 74 | { 75 | artifact.currentState = artifact.output[head(ludoscopeModule.inputs)]; 76 | artifact = executeRecipe(artifact, ludoscopeModule); 77 | } 78 | default : 79 | { 80 | break; 81 | // TODO: add merge functions. 82 | } 83 | 84 | } 85 | artifact.output = (ludoscopeModule.name : artifact.currentState); 86 | return artifact; 87 | } 88 | 89 | public ExecutionArtifact executeRecipe 90 | ( 91 | ExecutionArtifact artifact, 92 | LudoscopeModule \module 93 | ) 94 | { 95 | Recipe recipe = \module.recipe; 96 | for (Instruction instruction <- recipe) 97 | { 98 | artifact = executeInstruction(artifact, \module, instruction); 99 | } 100 | return artifact; 101 | } 102 | 103 | ////////////////////////////////////////////////////////////////////////////// 104 | // Utility functions. 105 | ////////////////////////////////////////////////////////////////////////////// 106 | 107 | //private ExecutionHistory reverseHistory(ExecutionHistory history) 108 | //{ 109 | // history = visit (history) 110 | // { 111 | // case list[ModuleExecution] timeline => reverse(timeline) 112 | // case list[InstructionExecution] timeline => reverse(timeline) 113 | // case list[RuleExecution] timeline => reverse(timeline) 114 | // }; 115 | // return history; 116 | //} -------------------------------------------------------------------------------- /LL/src/execution/instructions/Instructions.rsc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Instructions that apply rules to the map. 4 | // @brief This file contains the functions for the instructions 5 | // that apply rules. 6 | // @contributor Quinten Heijn - samuel.heijn@gmail.com - UvA 7 | // @date 20-04-2018 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | module execution::instructions::Instructions 12 | 13 | import IO; 14 | import List; 15 | import Map; 16 | 17 | import utility::TileMap; 18 | 19 | import parsing::DataStructures; 20 | import execution::DataStructures; 21 | import execution::instructions::Matching; 22 | 23 | import analysis::sanrWrapper::PropertyHistory; 24 | import sanr::DataStructures; 25 | 26 | // TODO: replace itterateRule with something that stops when tileMap doesn't change. 27 | public ExecutionArtifact executeInstruction 28 | ( 29 | ExecutionArtifact artifact, 30 | LudoscopeModule \module, 31 | executeRule(str ruleName, int itterations)) 32 | { 33 | for (int i <- [0 .. itterations]) 34 | { 35 | artifact = executeInstruction(artifact, \module, itterateRule(ruleName)); 36 | } 37 | return artifact; 38 | } 39 | 40 | public ExecutionArtifact executeInstruction 41 | ( 42 | ExecutionArtifact artifact, 43 | LudoscopeModule \module, 44 | itterateRule(str ruleName) 45 | ) 46 | { 47 | RuleMap rules = \module.rules; 48 | Rule rule = rules[ruleName]; 49 | lrel[Coordinates, Transformations] matches = 50 | findPatternWithTransformations(artifact.currentState, rule); 51 | 52 | if (size(matches) > 0) 53 | { 54 | tuple[Coordinates c, Transformations t] match = getOneFrom(matches); 55 | TileMap replacement = getOneFrom(rule.rightHands); 56 | replacement = applyTransformation(match.t, replacement); 57 | 58 | int patternWidth = size(replacement[0]); 59 | int patternHeight = size(replacement); 60 | 61 | for (int i <- [0 .. patternWidth]) 62 | { 63 | for (int j <- [0 .. patternHeight]) 64 | { 65 | artifact.currentState[j + match.c.y][i + match.c.x] = 66 | replacement[j][i]; 67 | } 68 | } 69 | 70 | Step newStep = 71 | step(artifact.currentState, 72 | \module.name, 73 | itterateRule(ruleName), // TODO: Add actual instruction. 74 | ruleName, 75 | indexOf(rule.rightHands, replacement), 76 | match.c); 77 | artifact.history = push(newStep, artifact.history); 78 | 79 | /* Update property report. */ 80 | artifact.propertyReport = updatePropertyReport(artifact); 81 | } 82 | return artifact; 83 | } 84 | 85 | public ExecutionArtifact executeInstruction 86 | ( 87 | ExecutionArtifact artifact, 88 | LudoscopeModule \module, 89 | executeGrammar() 90 | ) 91 | { 92 | RuleMap rules = \module.rules; 93 | RuleMap currentRules = rules; 94 | if (size(currentRules) > 0) 95 | { 96 | /* Loop stops after 300 instructions of after no matches are left. */ 97 | // TODO: Read maxIterations from module. 98 | int i = 0; 99 | while (i < 500) 100 | { 101 | str ruleName = getOneFrom(currentRules); 102 | TileMap oldTileMap = artifact.currentState; 103 | artifact = executeInstruction(artifact, \module, itterateRule(ruleName)); 104 | if (oldTileMap == artifact.currentState) 105 | { 106 | currentRules = delete(currentRules, ruleName); 107 | } 108 | else 109 | { 110 | currentRules = rules; 111 | i += 1; 112 | } 113 | 114 | if (currentRules == ()) 115 | { 116 | break; 117 | } 118 | } 119 | } 120 | return artifact; 121 | } 122 | 123 | -------------------------------------------------------------------------------- /LL/src/analysis/madWrapper/DataTransformation.rsc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Transform to MAD data structures. 4 | // @brief This file contains functions that transform the LL data 5 | // structures to and from the data structures used in the MAD. 6 | // @contributor Quinten Heijn - samuel.heijn@gmail.com - UvA 7 | // @date 18-04-2018 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | module analysis::madWrapper::DataTransformation 12 | 13 | import List; 14 | import util::mad::Metric; 15 | import util::mad::AST; 16 | 17 | import analysis::madWrapper::MADFramework; 18 | import analysis::madWrapper::SymbolHierarchy; 19 | 20 | import parsing::DataStructures; 21 | 22 | alias MadRuleMap = tuple[int width, MadRule rule]; 23 | alias MadRuleScoreMap = tuple[int width, MadRuleScore ruleScore]; 24 | alias CleanRule = tuple[TileMap leftHand, TileMap rightHand]; 25 | 26 | public list[MadRuleMap] ludoscopeRuleToMadRuleMaps(Rule ludoscopeRule) 27 | { 28 | list[CleanRule] cleanRules = ludoscopeRuleToCleanRules(ludoscopeRule); 29 | return [cleanRuleToMadRuleMap(cleanRule) | CleanRule cleanRule <- cleanRules]; 30 | } 31 | 32 | public list[RightHandScore] madRuleScoreMapToRightHandScores 33 | ( 34 | list[MadRuleScoreMap] madRuleScores 35 | ) 36 | { 37 | return [ 38 | | MadRuleScoreMap rule <- madRuleScores]; 39 | } 40 | 41 | public Detail symbolHierarchyToDetail 42 | ( 43 | SymbolHierarchy symbolHierarchy 44 | ) 45 | { 46 | Detail detail = {}; 47 | for (SymbolGroup symbolGroup <- symbolHierarchy) 48 | { 49 | SymbolGroup lowerSymbols = getLowerSymbols(symbolHierarchy, symbolGroup); 50 | detail += SymbolGroupToDetail(symbolGroup, lowerSymbols); 51 | } 52 | return detail; 53 | } 54 | 55 | private list[CleanRule] ludoscopeRuleToCleanRules 56 | ( 57 | Rule ludoscopeRule 58 | ) 59 | { 60 | return [ 61 | | TileMap rightHand <- ludoscopeRule.rightHands]; 62 | } 63 | 64 | private HeatMap madRuleScoreToTileMap 65 | ( 66 | MadRuleScoreMap madRuleScore 67 | ) 68 | { 69 | HeatMap heatMap = []; 70 | list[int] row = []; 71 | 72 | for (int score <- madRuleScore.ruleScore.score) 73 | { 74 | row += [score]; 75 | if (size(row) == madRuleScore.width) 76 | { 77 | heatMap += [row]; 78 | row = []; 79 | } 80 | } 81 | 82 | return heatMap; 83 | } 84 | 85 | private MadRuleMap cleanRuleToMadRuleMap 86 | ( 87 | CleanRule rule 88 | ) 89 | { 90 | MadRule madRule = []; 91 | for (int y <- [0 .. size(rule.leftHand)]) 92 | { 93 | for (int x <- [0 .. size(head(rule.leftHand))]) 94 | { 95 | madRule += [<"", "">]; 96 | } 97 | } 98 | return ; 99 | } 100 | 101 | private Detail SymbolGroupToDetail 102 | ( 103 | set[str] symbols, 104 | set[str] lowerSymbols 105 | ) 106 | { 107 | return {<"", ""> | 108 | str symbol <- symbols, 109 | str lowerSymbol <- lowerSymbols}; 110 | } 111 | 112 | private set[str] getLowerSymbols 113 | ( 114 | SymbolHierarchy symbolHierarchy, 115 | SymbolGroup symbols 116 | ) 117 | { 118 | set[str] lowerSymbols = {}; 119 | SymbolGroup currentSymbols = head(symbolHierarchy); 120 | symbolHierarchy = tail(symbolHierarchy); 121 | while (currentSymbols != symbols) 122 | { 123 | lowerSymbols += currentSymbols; 124 | currentSymbols = head(symbolHierarchy); 125 | symbolHierarchy = tail(symbolHierarchy); 126 | } 127 | 128 | return lowerSymbols; 129 | } -------------------------------------------------------------------------------- /LL/src/errors/Parsing.rsc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Parsing errors 4 | // @brief This file contains data types for parsing errors. 5 | // @contributor Quinten Heijn - samuel.heijn@gmail.com - UvA 6 | // @date 05-04-2018 7 | // 8 | ////////////////////////////////////////////////////////////////////////////// 9 | 10 | module errors::Parsing 11 | 12 | data ParsingError 13 | = imploding(loc fileLocation) 14 | | version(str version) 15 | | fileNotFound(loc fileLocation) 16 | | parsing(loc fileLocation) 17 | | ambiguity(loc fileLocation, str usedSyntax) 18 | | extension(loc fileLocation) 19 | | mapType(str mapType, loc fileLocation) 20 | | mapSize(int size, int symbols, loc fileLocation) 21 | | rightAndLeftHandSize(int leftWidth, int leftHeight, 22 | int rightWidth, int rightHeight, loc fileLocation) 23 | | propertyName(str propertyName, loc fileLocation) 24 | | nameType(str expectedType, str foundType, loc fileLocation); 25 | 26 | str errorToString(parsing(loc fileLocation)) 27 | { 28 | return "Parsing error: 29 | File: 30 | Line: "; 31 | } 32 | 33 | str errorToString(ambiguity(loc fileLocation, str usedSyntax)) 34 | { 35 | return "Parsing error: ambiguity found while parsing. 36 | Syntax: 37 | File: 38 | Line: "; 39 | } 40 | 41 | str errorToString(imploding(loc location)) 42 | { 43 | return "Parsing error: could not implode the parsing tree to 44 | the AST. 45 | File: "; 46 | } 47 | 48 | str errorToString(version(str version)) 49 | { 50 | return "Version error: LL was build for version 0.6f of Ludoscope. 51 | Version of input: "; 52 | } 53 | 54 | str errorToString(fileNotFound(loc fileLocation)) 55 | { 56 | return "Input error: could not find the following file: 57 | "; 58 | } 59 | 60 | str errorToString(extension(loc fileLocation)) 61 | { 62 | return "Input error: could not parse , because 63 | the extension \".\" is not supported by LL."; 64 | } 65 | 66 | str errorToString(mapType(str mapType, loc fileLocation)) 67 | { 68 | return "Type error: \'\' maps are not supported by LL 69 | File: 70 | Line: "; 71 | } 72 | 73 | str errorToString(mapSize(int size, int symbols, loc fileLocation)) 74 | { 75 | return "Error: the declared size of the map () does not match with 76 | the amount of symbols that follow (). 77 | File: 78 | Line: "; 79 | } 80 | 81 | str errorToString(rightAndLeftHandSize(int leftWidth, int leftHeight, 82 | int rightWidth, int rightHeight, loc fileLocation)) 83 | { 84 | return "Error: the dimensions of the left hand (, ) 85 | do not match with the dimensions of the right hand (, ). 86 | File: 87 | Line: "; 88 | } 89 | 90 | str errorToString(propertyName(str propertyName, loc fileLocation)) 91 | { 92 | return "Error: the identifier \"\" used in defining a property 93 | cannot be located in the syntax Tree. 94 | File: 95 | Line: "; 96 | } 97 | 98 | str errorToString(nameType(str expectedType, str foundType, loc fileLocation)) 99 | { 100 | return "Error: A name referenced to a , while a name was expected. 101 | File: 102 | Line: "; 103 | } 104 | 105 | -------------------------------------------------------------------------------- /LL/src/parsing/languages/grammar/AST.rsc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // The AST used for parsing .grm files. 4 | // @brief This file contains the data structure needed for imploding 5 | // a parsed .grm tree. 6 | // @contributor Quinten Heijn - samuel.heijn@gmail.com - UvA 7 | // @date 03-04-2018 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | module parsing::languages::grammar::AST 12 | 13 | import parsing::languages::grammar::Syntax; 14 | import ParseTree; 15 | 16 | ////////////////////////////////////////////////////////////////////////////// 17 | // APIs 18 | ////////////////////////////////////////////////////////////////////////////// 19 | 20 | public parsing::languages::grammar::AST::Grammar implodeGrammar(Tree tree) 21 | = implode(#parsing::languages::grammar::AST::Grammar, tree); 22 | 23 | public parsing::languages::grammar::AST::Grammar parseGrammarToAST(loc location) 24 | = implodeGrammar(parseGrammar(location)); 25 | 26 | ////////////////////////////////////////////////////////////////////////////// 27 | // AST 28 | ////////////////////////////////////////////////////////////////////////////// 29 | 30 | anno loc MapType@location; 31 | 32 | data Grammar 33 | = grammar 34 | ( 35 | str version, 36 | StartInput startInput, 37 | list[Rule] rules, 38 | Options options 39 | ); 40 | 41 | data StartInput 42 | = startInput(Expression expression); 43 | 44 | data Rule 45 | = rule 46 | ( 47 | str name, 48 | list[RuleSetting] settings, 49 | LeftHandExpression leftHand, 50 | list[RightHandExpression] rightHands 51 | ); 52 | 53 | data Expression 54 | = expression 55 | ( 56 | MapType mapType, 57 | list[Symbol] symbols 58 | ); 59 | 60 | data LeftHandExpression 61 | = leftHandExpression 62 | ( 63 | MapType mapType, 64 | list[MatchingSymbol] symbols 65 | ); 66 | 67 | data RightHandExpression 68 | = rightHandExpression 69 | ( 70 | int id, 71 | Expression expression 72 | ); 73 | 74 | data MapType 75 | = tileMap 76 | ( 77 | int width, 78 | int height 79 | ) 80 | | string() 81 | | graph() 82 | | shape(); 83 | 84 | data Symbol 85 | = symbol 86 | ( 87 | int id, 88 | str name, 89 | list[MemberStatement] members 90 | ); 91 | 92 | data MatchingSymbol 93 | = matchingSymbol 94 | ( 95 | int id, 96 | str name, 97 | list[MemberExpression] members 98 | ); 99 | 100 | data Options 101 | = options 102 | ( 103 | bool checkCollisions, 104 | bool stayWithinBounds, 105 | bool trackNonTerminals, 106 | bool findOnlyOneOption 107 | ); 108 | 109 | data RuleSetting 110 | = ruleWidth(int width) 111 | | ruleHeight(int height) 112 | | ruleReflections(int reflections); 113 | 114 | data MemberStatement 115 | = memberStatement 116 | ( 117 | str identifier, 118 | Value memberValue 119 | ); 120 | 121 | data MemberExpression 122 | = memberExpression 123 | ( 124 | str identifier, 125 | Value memberValue 126 | ); 127 | 128 | data Value 129 | = integerValue(int integer) 130 | | floatValue(str float) 131 | | stringValue(str string) 132 | | booleanValue(bool boolean) 133 | | colorValue(str color) 134 | | vectorValue(Vector vector) 135 | | listValue(list[Value] memberList); 136 | 137 | data Vector 138 | = vector2d 139 | ( 140 | int x, 141 | int y 142 | ) 143 | | vector3d 144 | ( 145 | int x, 146 | int y, 147 | int z 148 | ) 149 | | vecotr4d 150 | ( 151 | int x, 152 | int y, 153 | int z, 154 | int a 155 | ); -------------------------------------------------------------------------------- /LL/src/parsing/languages/recipe/Syntax.rsc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Syntax for .rcp files. 4 | // @brief This files contains the syntax needed for parsing .rcp files. 5 | // .rcp files contain the recipe that is used to execute a grammar. 6 | // @contributor Quinten Heijn - samuel.heijn@gmail.com - UvA 7 | // @date 03-04-2018 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | module parsing::languages::recipe::Syntax 12 | 13 | import ParseTree; 14 | 15 | ////////////////////////////////////////////////////////////////////////////// 16 | // Parser Rules 17 | ////////////////////////////////////////////////////////////////////////////// 18 | 19 | start syntax Recipe 20 | = recipe: Commands*; 21 | 22 | syntax Commands 23 | = setRegister: COMMENTED? "SetRegister" "(" String Expression ")" // TODO: registers can hold mutiple values, including expressions. 24 | | iterateRule: COMMENTED? "IterateRule" "(" String ")" 25 | | iterateFromRegister: COMMENTED? "IterateFromRegister" "(" String ")" 26 | | iterateRuleLSystem: COMMENTED? "IterateRuleLSystem" "(" String ")" 27 | | iterateRuleCellular: COMMENTED? "IterateRuleCellular" "(" String ")" 28 | | executeFromRegister: COMMENTED? "ExecuteFromRegister" "(" String INTEGER ")" // TODO: executions can also use the dice notation. (for example 'D2') 29 | | executeRuleLSystem: COMMENTED? "ExecuteRuleLSystem" "(" String INTEGER ")" 30 | | executeRuleCellular: COMMENTED? "ExecuteRuleCellular" "(" String INTEGER ")" 31 | | executeRule: COMMENTED? "ExecuteRule" "(" String INTEGER ")" 32 | | splitTiles: COMMENTED? "SplitTiles" "(" INTEGER INTEGER ")" 33 | | replaceLabels: COMMENTED? "ReplaceLabels" "(" String String")" 34 | | keepTopOfStack: COMMENTED? "KeepTopOfStack" 35 | | createTileMapFromRegisters: COMMENTED? "CreateTileMap" "(" NAME NAME String ")" 36 | | createTileMapFromIntegers: COMMENTED? "CreateTileMap" "(" INTEGER INTEGER String ")" 37 | | transformSymbols: COMMENTED? "TransformSymbols" "(" String String ")"; 38 | 39 | syntax String 40 | = @category="String" "\"" STRING "\""; 41 | 42 | syntax Expression 43 | = expression: INTEGER; // TODO: what is allowed to be in registers? 44 | 45 | // TODO: Add dice notation. 46 | 47 | ////////////////////////////////////////////////////////////////////////////// 48 | // Lexer Rules 49 | ////////////////////////////////////////////////////////////////////////////// 50 | 51 | lexical NAME 52 | = @category="Name" ([a-zA-Z_$*] [a-zA-Z0-9_$*]* !>> [a-zA-Z0-9_$*]) \ Keyword; 53 | 54 | lexical INTEGER 55 | = ("-"?[0-9]+); 56 | 57 | lexical STRING 58 | = ![\"]*; 59 | 60 | lexical COMMENTED 61 | = "//"; 62 | 63 | ////////////////////////////////////////////////////////////////////////////// 64 | // Layout 65 | ////////////////////////////////////////////////////////////////////////////// 66 | 67 | layout LAYOUTLIST 68 | = LAYOUT* !>> [\t-\n \r \ : ,]; 69 | 70 | lexical LAYOUT 71 | = [\t-\n \r \ : ,]; 72 | 73 | // TODO: refactor comments. 74 | //lexical Comment 75 | // = @category="Comment" "//" ![\n]* [\n]; 76 | 77 | keyword Keyword 78 | = "SetRegister" 79 | | "IterateRule" 80 | | "IterateFromRegister" 81 | | "IterateRuleLSystem" 82 | | "IterateRuleCellular" 83 | | "ExecuteFromRegister" 84 | | "ExecuteRuleLSystem" 85 | | "ExecuteRuleCellular" 86 | | "ExecuteRule" 87 | | "ReplaceLabels" 88 | | "SplitTiles" 89 | | "TransformSymbols" 90 | | "CreateTileMap" 91 | | "KeepTopOfStack"; 92 | 93 | ////////////////////////////////////////////////////////////////////////////// 94 | // API 95 | ////////////////////////////////////////////////////////////////////////////// 96 | 97 | public start[Recipe] parseRecipe(loc file) = 98 | parse(#start[Recipe], file); 99 | 100 | public start[Recipe] parseRecipe(str input, loc location) 101 | { 102 | return parse(#start[Recipe], input, location); 103 | } -------------------------------------------------------------------------------- /LL/src/parsing/languages/project/Syntax.rsc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Syntax for .lsp files. 4 | // @brief This files contains the syntax needed for parsing .lsp files. 5 | // .lsp files contain the structure of a ludoscope project. 6 | // @contributor Quinten Heijn - samuel.heijn@gmail.com - UvA 7 | // @date 03-04-2018 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | module parsing::languages::project::Syntax 12 | 13 | import ParseTree; 14 | 15 | ////////////////////////////////////////////////////////////////////////////// 16 | // Parser Rules 17 | ////////////////////////////////////////////////////////////////////////////// 18 | 19 | start syntax Project 20 | = project: "version" FLOAT version 21 | Declaration* declarations; 22 | 23 | syntax Declaration 24 | = declaredAlphabet: Alphabet declaredAlphabet 25 | | declaredModule: Module declaredModule 26 | | declaredOption: Option declaredOption 27 | | declaredRegister: Register declaredRegister; 28 | 29 | syntax Alphabet 30 | = alphabet: "alphabet" 31 | "name" String name 32 | "position" Position position; 33 | 34 | syntax Module 35 | = lspmodule: "module" 36 | ("name" String name)? 37 | ("alphabet" String alphabet)? 38 | ("position" Position moduleType)? 39 | ("type" NAME moduleType)? 40 | ("fileName" String fileName)? 41 | ("match" NAME match)? 42 | ("inputs" String* inputs)? 43 | ("maxIterations" INTEGER maxIterations)? 44 | ("filter" String moduleFilter)? 45 | ("grammar" BOOLEAN grammar)? 46 | ("executionType" NAME executionType)? 47 | ("recipe" BOOLEAN recipe)? 48 | ("showMembers" BOOLEAN showMembers)? 49 | ("alwaysStartWithToken" BOOLEAN alwaysStartWithToken)?; 50 | 51 | syntax Register 52 | = register: "register" Variable registerContent; 53 | 54 | syntax Option 55 | = option: "option" Variable optionContent; 56 | 57 | syntax Variable 58 | = variableInteger: NAME name INTEGER integer 59 | | variableFloat: NAME name FLOAT float 60 | | variableString: NAME name String string 61 | | variableList: NAME name "[" String* "]" listOfVariable 62 | | variableBoolean: NAME name BOOLEAN boolean 63 | | variablePosition: NAME name Position position 64 | | variableName: NAME name NAME variableName 65 | | variableNull: NAME name "null"; 66 | 67 | syntax String 68 | = @category="String" "\"" STRING "\""; 69 | 70 | syntax Position 71 | = position: "(" INTEGER x INTEGER y ")"; 72 | 73 | ////////////////////////////////////////////////////////////////////////////// 74 | // Lexer Rules 75 | ////////////////////////////////////////////////////////////////////////////// 76 | 77 | lexical BOOLEAN 78 | = @category="Boolean" "true" | "false"; 79 | 80 | lexical FLOAT 81 | = INTEGER ([.][0-9]+?)? "f"; 82 | 83 | lexical INTEGER 84 | = ("-"?[0-9]+); 85 | 86 | lexical NAME 87 | = @category="Name" ([a-zA-Z_$] [a-zA-Z0-9_$]* !>> [a-zA-Z0-9_$]) \ Keyword; 88 | 89 | lexical STRING 90 | = ![\"]*; 91 | 92 | ////////////////////////////////////////////////////////////////////////////// 93 | // Layout 94 | ////////////////////////////////////////////////////////////////////////////// 95 | 96 | layout LAYOUTLIST 97 | = LAYOUT* !>> [\t-\n \r \ : ,]; 98 | 99 | lexical LAYOUT 100 | = [\t-\n \r \ : ,]; 101 | 102 | keyword Keyword 103 | = "version" 104 | | "alphabet" 105 | | "module" 106 | | "register" 107 | | "option" 108 | | "true" 109 | | "false" 110 | | "null" 111 | | "name" 112 | | "alphabet" 113 | | "position" 114 | | "type" 115 | | "fileName" 116 | | "match" 117 | | "inputs" 118 | | "maxIterations" 119 | | "filter" 120 | | "grammar" 121 | | "executionType" 122 | | "recipe" 123 | | "showMembers" 124 | | "alwaysStartWithToken"; 125 | 126 | ////////////////////////////////////////////////////////////////////////////// 127 | // API 128 | ////////////////////////////////////////////////////////////////////////////// 129 | 130 | public start[Project] parseProject(loc file) = 131 | parse(#start[Project], file); 132 | 133 | public start[Project] parseProject(str input, loc location) 134 | { 135 | return parse(#start[Project], input, location); 136 | } -------------------------------------------------------------------------------- /LL/src/parsing/Parser.rsc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Parser for LL projects 4 | // @brief This file contains the public interface for parsing 5 | // a Ludoscope project. 6 | // @contributor Quinten Heijn - samuel.heijn@gmail.com - UvA 7 | // @date 17-04-2018 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | module parsing::Parser 12 | 13 | import IO; 14 | import Exception; 15 | import List; 16 | 17 | import parsing::languages::project::AST; 18 | import parsing::languages::alphabet::AST; 19 | import parsing::languages::recipe::AST; 20 | import parsing::languages::grammar::AST; 21 | 22 | import sanr::language::AST; 23 | 24 | import parsing::DataStructures; 25 | import errors::Parsing; 26 | import utility::String; 27 | 28 | alias AbstractProjectList = list[parsing::languages::project::AST::Project]; 29 | alias AbstractGrammarMap = map[str, parsing::languages::grammar::AST::Grammar] ; 30 | alias AbstractAlphabetMap = map[str, parsing::languages::alphabet::AST::Alphabet]; 31 | alias AbstractRecipeMap = map[str, parsing::languages::recipe::AST::Recipe]; 32 | alias AbstractPropertyList = list[sanr::language::AST::LevelSpecification]; 33 | 34 | data SyntaxTree 35 | = syntaxTree(AbstractProjectList project, 36 | AbstractGrammarMap grammars, 37 | AbstractAlphabetMap alphabets, 38 | AbstractRecipeMap recipes, 39 | AbstractPropertyList properties, 40 | list[ParsingError] errors); 41 | 42 | public SyntaxTree parseFile(loc file, SyntaxTree syntaxTree) 43 | { 44 | if (exists(file)) 45 | { 46 | try 47 | { 48 | switch (file.extension) 49 | { 50 | case "lsp" : syntaxTree.project += [parseProjectToAST(file)]; 51 | case "grm" : syntaxTree.grammars += (fileName(file) : parseGrammarToAST(file)); 52 | case "alp" : syntaxTree.alphabets += (fileName(file) : parseAlphabetToAST(file)); 53 | case "rcp" : syntaxTree.recipes += (fileName(file) : parseRecipeToAST(file)); 54 | case "sanr" : syntaxTree.properties += [parseSAnRToAST(file)]; 55 | default : syntaxTree.errors += [errors::Parsing::extension(file)]; 56 | } 57 | } 58 | catch ParseError(loc errorLocation): 59 | { 60 | syntaxTree.errors += [errors::Parsing::parsing(errorLocation)]; 61 | } 62 | catch Ambiguity(loc errorLocation, str usedSyntax, str parsedText): 63 | { 64 | syntaxTree.errors += [errors::Parsing::ambiguity(errorLocation, usedSyntax)]; 65 | } 66 | catch IllegalArgument(value v, str message): 67 | { 68 | syntaxTree.errors += [errors::Parsing::imploding(file)]; 69 | } 70 | } 71 | else 72 | { 73 | syntaxTree.errors += [errors::Parsing::fileNotFound(file)]; 74 | } 75 | return syntaxTree; 76 | } 77 | 78 | public SyntaxTree parseCompleteProject(loc projectFile) 79 | { 80 | SyntaxTree syntaxTree = syntaxTree([], (), (), (), [], []); 81 | 82 | syntaxTree = parseFile(projectFile, syntaxTree); 83 | 84 | list[loc] fileLocations = 85 | gatherFileLocations(syntaxTree, projectFile); 86 | 87 | for (loc file <- fileLocations) 88 | { 89 | syntaxTree = parseFile(file, syntaxTree); 90 | } 91 | 92 | return syntaxTree; 93 | } 94 | 95 | public list[loc] gatherFileLocations(SyntaxTree syntaxTree, loc projectFile) 96 | { 97 | list[loc] fileLocations = []; 98 | 99 | visit(syntaxTree) 100 | { 101 | case lspmodule(str name, str alphabet, str position, str moduleType, str fileName, 102 | str match, list[str] inputs, str maxIterations, str moduleFilter, str grammar, 103 | str executionType, str recipe, str showMembers, str alwaysStartWithToken) : 104 | { 105 | fileLocations += [fileLocation(projectFile, cleanGrammarName(name), ".grm")]; 106 | if (cleanRecipeBool(recipe) == "true") 107 | { 108 | fileLocations += [fileLocation(projectFile, cleanGrammarName(name), ".rcp")]; 109 | } 110 | } 111 | case alphabet(str name, Position position) : 112 | { 113 | fileLocations += [fileLocation(projectFile, removeQuotes(name), ".alp")]; 114 | } 115 | } 116 | 117 | loc propertiesFile = fileLocation(projectFile, fileName(projectFile), ".sanr"); 118 | if (exists(propertiesFile)) 119 | { 120 | fileLocations += [propertiesFile]; 121 | } 122 | 123 | return fileLocations; 124 | } -------------------------------------------------------------------------------- /LL/src/parsing/transformations/Grammar.rsc: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Transform Grammars 4 | // @brief Functions that move the relevant content from the AST to 5 | // a new ADT declared in DataStructures.rsc. 6 | // @contributor Quinten Heijn - samuel.heijn@gmail.com - UvA 7 | // @date 23-04-2018 8 | // 9 | ////////////////////////////////////////////////////////////////////////////// 10 | 11 | module parsing::transformations::Grammar 12 | 13 | import parsing::languages::grammar::AST; 14 | import parsing::Parser; 15 | import parsing::DataStructures; 16 | import parsing::transformations::Utility; 17 | 18 | alias AbstractGrammar = parsing::languages::grammar::AST::Grammar; 19 | alias AbstractRule = parsing::languages::grammar::AST::Rule; 20 | 21 | public TransformationArtifact transformGrammars(TransformationArtifact artifact, 22 | SyntaxTree syntaxTree) 23 | { 24 | for (str grammarName <- syntaxTree.grammars) 25 | { 26 | int moduleIndex = findModuleIndex(grammarName, artifact); 27 | AbstractGrammar abstractGrammar = syntaxTree.grammars[grammarName]; 28 | 29 | artifact.project.modules[moduleIndex].startingState = parseExpression(artifact, 30 | abstractGrammar.startInput.expression.symbols, 31 | abstractGrammar.startInput.expression.mapType, 32 | moduleIndex); 33 | 34 | artifact = 35 | parseRules(artifact, syntaxTree.grammars[grammarName].rules, moduleIndex); 36 | } 37 | 38 | return artifact; 39 | } 40 | 41 | private TransformationArtifact parseRules(TransformationArtifact artifact, 42 | list[AbstractRule] rules, int moduleIndex) 43 | { 44 | RuleMap transformedRules = (); 45 | for (AbstractRule abstractRule <- rules) 46 | { 47 | Reflections reflections = parseSettings(abstractRule.settings); 48 | 49 | TileMap leftHand = parseExpression(artifact, 50 | abstractRule.leftHand.symbols, 51 | abstractRule.leftHand.mapType, 52 | moduleIndex); 53 | 54 | list[TileMap] rightHands = parseRightHands(artifact, 55 | abstractRule.rightHands, moduleIndex); 56 | 57 | Rule newRule = parsing::DataStructures::rule(reflections, leftHand, rightHands); 58 | 59 | transformedRules += (abstractRule.name : newRule); 60 | } 61 | artifact.project.modules[moduleIndex].rules = transformedRules; 62 | return artifact; 63 | } 64 | 65 | private list[TileMap] parseRightHands(TransformationArtifact artifact, 66 | list[RightHandExpression] abstractRightHands, int moduleIndex) 67 | { 68 | list[TileMap] rightHands = []; 69 | for (RightHandExpression rightHand <- abstractRightHands) 70 | { 71 | rightHands += [parseExpression(artifact, rightHand.expression.symbols, 72 | rightHand.expression.mapType, moduleIndex)]; 73 | } 74 | return rightHands; 75 | } 76 | 77 | private Reflections parseSettings(list[RuleSetting] settings) 78 | { 79 | list[bool] bitList = [false, false, false]; 80 | for (RuleSetting setting <- settings) 81 | { 82 | switch (setting) 83 | { 84 | case ruleReflections(int reflections) : 85 | { 86 | bitList = parseBitFlag(reflections, 3); 87 | } 88 | } 89 | } 90 | return reflections(bitList[0], bitList[1], bitList[2]); 91 | } 92 | 93 | private TileMap parseExpression(TransformationArtifact artifact, 94 | list[Symbol] symbols, tileMap(int width, int height), int moduleIndex) 95 | { 96 | TileMap newTileMap = []; 97 | str alphabetName = artifact.project.modules[moduleIndex].alphabetName; 98 | 99 | int i = 0; 100 | list[Tile] row = []; 101 | for (Symbol symbol <- symbols) 102 | { 103 | row += [symbol.name]; 104 | i += 1; 105 | if (i == width) 106 | { 107 | newTileMap += [row]; 108 | row = []; 109 | i = 0; 110 | } 111 | } 112 | 113 | return newTileMap; 114 | } 115 | 116 | // TODO: remove duplicate function. 117 | private TileMap parseExpression(TransformationArtifact artifact, 118 | list[MatchingSymbol] symbols, tileMap(int width, int height), int moduleIndex) 119 | { 120 | TileMap newTileMap = []; 121 | str alphabetName = artifact.project.modules[moduleIndex].alphabetName; 122 | 123 | int i = 0; 124 | list[Tile] row = []; 125 | for (MatchingSymbol symbol <- symbols) 126 | { 127 | row += symbol.name; 128 | i += 1; 129 | if (i == width) 130 | { 131 | newTileMap += [row]; 132 | row = []; 133 | i = 0; 134 | } 135 | } 136 | 137 | return newTileMap; 138 | } -------------------------------------------------------------------------------- /LL/src/analysis/sanrWrapper/Report.rsc: -------------------------------------------------------------------------------- 1 | module analysis::sanrWrapper::Report 2 | 3 | import IO; 4 | import List; 5 | import Map; 6 | import Set; 7 | import utility::Time; 8 | import DateTime; 9 | import execution::Execution; 10 | import execution::DataStructures; 11 | import parsing::Interface; 12 | import parsing::DataStructures; 13 | 14 | import sanr::DataStructures; 15 | import sanr::language::AST; 16 | 17 | private loc reportFile = |project://LL/src/visual/outputs/sanr.output|; 18 | 19 | alias OutputCount = map[TileMap, int]; 20 | alias BugTypeCount = set[BugType]; 21 | alias BugMap = map[BugType, list[Bug]]; 22 | 23 | data Report 24 | = report(OutputCount outputs, int brokenOutputs, BugTypeCount bugTypes, BugMap bugs) 25 | | emptyReport(); 26 | 27 | data BugType 28 | = bugType(str rule, Property property) | emptyBugType(); 29 | 30 | data Bug 31 | = bug(str rule, Property property, ExecutionArtifact execution, int executionNumber, int step); 32 | 33 | public Report analyseProject(LudoscopeProject project, int itterations) 34 | { 35 | list[ExecutionArtifact] executions = []; 36 | OutputCount outputs = (); 37 | int brokenOutputs = 0; 38 | BugTypeCount bugTypes = {}; 39 | BugMap bugMap = (); 40 | 41 | for (int i <- [0 .. itterations]) 42 | { 43 | datetime startTime = now(); 44 | ExecutionArtifact artifact = executeProject(project); 45 | datetime endTime = now(); 46 | println(durationToString(endTime - startTime)); 47 | 48 | executions += artifact; 49 | outputs[artifact.currentState] ? 0 += 1; 50 | 51 | PropertyStates finalPropertyStates = last(artifact.propertyReport.history).propertyStates; 52 | if (false in finalPropertyStates) 53 | { 54 | brokenOutputs += 1; 55 | } 56 | 57 | for (Bug bug <- findBugs(artifact)) 58 | { 59 | bug.executionNumber = i; 60 | BugType bugType = bugType(bug.rule, bug.property); 61 | bugTypes += bugType; 62 | if (bugType in bugMap) 63 | { 64 | bugMap[bugType] += [bug]; 65 | } 66 | else 67 | { 68 | bugMap += (bugType : [bug]); 69 | } 70 | } 71 | println("SAnR analysis: /"); 72 | updateReportFile(executions, outputs, brokenOutputs, bugTypes, bugMap); 73 | } 74 | 75 | return report(outputs, brokenOutputs, bugTypes, bugMap); 76 | } 77 | 78 | public list[Bug] findBugs(ExecutionArtifact artifact) 79 | { 80 | list[ReportState] history = artifact.propertyReport.history; 81 | list[Bug] bugs = []; 82 | 83 | for (int i <- [0 .. size(last(history).propertyStates)]) 84 | { 85 | if (!last(history).propertyStates[i]) 86 | { 87 | Property property = artifact.propertyReport.specification.properties[i]; 88 | 89 | int step = getStep(i, artifact); 90 | str ruleName = ""; 91 | if (step == 0) 92 | { 93 | ruleName == "n/a"; 94 | } else 95 | { 96 | ruleName = artifact.history[step].ruleName; 97 | } 98 | bugs += bug(ruleName, property, artifact, -1, step); 99 | } 100 | } 101 | 102 | return bugs; 103 | } 104 | 105 | public int getStep(int property, ExecutionArtifact artifact) 106 | { 107 | list[ReportState] history = artifact.propertyReport.history; 108 | int steps = size(history); 109 | 110 | for (int i <- [steps-1 .. -1]) 111 | { 112 | if (history[i].propertyStates[property]) 113 | { 114 | return i; 115 | } 116 | } 117 | return 0; 118 | } 119 | 120 | private void updateReportFile 121 | ( 122 | list[ExecutionArtifact] executions, 123 | OutputCount outputs, 124 | int brokenOutputs, 125 | BugTypeCount bugTypes, 126 | BugMap bugMap 127 | ) 128 | { 129 | writeFile(reportFile, "BUG REPORT\n__________________\n"); 130 | appendToFile(reportFile, "Number of executions: \n"); 131 | appendToFile(reportFile, "Number of unique outputs: \n"); 132 | appendToFile(reportFile, "Number of bad maps: \n"); 133 | appendToFile(reportFile, "Number of bug types: \n"); 134 | appendToFile(reportFile,"\nBugs: \n -----------------"); 135 | for (BugType bugType <- bugTypes) 136 | { 137 | appendToFile(reportFile,"\n\nProperty: "); 138 | appendToFile(reportFile, readFileLines(bugType.property@location)[0]); 139 | appendToFile(reportFile,"\nBroken by: "); 140 | appendToFile(reportFile, bugType.rule); 141 | appendToFile(reportFile,"\nCount: "); 142 | appendToFile(reportFile, size(bugMap[bugType])); 143 | } 144 | } --------------------------------------------------------------------------------