Logo3d
A compiler for the Logo programming language featuring language extensions for navigations in three-dimensional space. The compiler takes a logo3d program string and outputs a collection of colored lines defined in terms of their X, Y, & Z coordinates.
The compiler is provided as 'headless' - it is hoped that developers with UI expertise can provide application front ends and GL acceleration appropriate for each target platform. However, to demonstrate the power of Logo3d the project does contain a simple DemoVisualizer along with three predefined programs:
GRID_SPHERE
SPIRAL_SHELL
RECURSIVE_TREE
Prerequisites
The following dependencies are needed to build the project and run the demo application.
- Java, version 11+
- Maven
Running the demo application
The demo application is run from the downloaded/cloned project directory, i.e. the directory containing pom.xml
.
To compile & run the demo application:
mvn compile exec:java
The demo application runs GRID_SPHERE from the predefined programs. An alternative program, or custom program string, can be specified here.
Running the tests
The project contains unit tests, static analysis tests (SpotBugs), code coverage tests (JaCoCo) and code style tests (Checkstyle). To run all, specify:
mvn verify
Verification will fail if any test(s) fail. Code coverage thresholds are set at 90% for both line and branch coverage. The code coverage report is written to target/site/jacoco/index.html
Checkstyle is used to enforce the Sun coding conventions, see: checkstyle.xml
Key implementation classes
Class | Responsibility |
---|---|
Tokenizer | Splits a Logo3d program defined as a single string into its constituent tokens, e.g. "make x=x+1" becomes ["make", "x", "=", "x", "+", "1"]. |
Instruction | Operations that can be performed as part of a Logo3d program, e.g. MoveForward, TurnLeft, SetColor, Make and Repeat. |
Parameter | An input to a Logo3d Instruction. Example parameters are simple (e.g. NumericConstant), dynamic (e.g. Pick), compound (e.g. Expression) or variable (e.g. VariableReference). |
Result | The realtime value of a Parameter when evaluated at runtime. Results may either be of type NumericResult or ColorResult, both of which can be combined with results of the same type using mathematical operators. |
Program | The representation of all the Instructions and their bound Parameters that constitute a Logo3d program. |
Procedure | A named sub-program defined within a Logo3d program. |
State | A store for recording the current value of any VariableReference parameters. The state observes correct scoping rules, i.e. variables defined within a Procedure or Repeat body exist independently of variables of the same name defined in the wider Program. |
Turtle | An entity which is manipulated within three dimensional space while recording the positions of traversed lines. |
LogoCompiler | The process orchestrator. Constructs all entities and runs a built Program with a fresh State and Turtle. |
Author
Concept, design & implementation by Noel Evans
License
This project is licensed under the MIT License - see the LICENSE.txt file for details.
Acknowledgments
- Thanks to Benoit for code reviews.
- Dan Mellinger for collaboration on the earlier iOS implementation.
- PurpleBooth, for this README template.