Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andydevs/jump
An experiment in writing interpreted languages in C++
https://github.com/andydevs/jump
programming-language state-machine
Last synced: 9 days ago
JSON representation
An experiment in writing interpreted languages in C++
- Host: GitHub
- URL: https://github.com/andydevs/jump
- Owner: andydevs
- License: gpl-3.0
- Created: 2016-09-28T17:56:52.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-10-24T16:58:03.000Z (about 7 years ago)
- Last Synced: 2024-11-08T21:33:52.164Z (2 months ago)
- Topics: programming-language, state-machine
- Language: C++
- Homepage:
- Size: 204 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Jump
Jump is the first programming language that follows the state machine paradigm. State machines have a wide variety of applications including robotics programming, web design, game design, and app development. Jump is an easy, intuitive language for writing state machines for whatever projects you may be working on.
## Table of Contents
- [The State Machine Paradigm](#the-state-machine-paradigm)
- [The Jump Language](#the-jump-language)
- [States](#states)
- [Statements](#statements)
- [Print Statement](#print-statement)
- [Prompt Statement](#prompt-statement)
- [Read Statement](#read-statement)
- [To Statement](#to-statement)
- [Loop Statement](#loop-statement)
- [End Statement](#end-statement)## The State Machine Paradigm
The state machine paradigm consists of designing stackless algorithms as a series of states which transition to each other.
A state machine language should have these fundamental components:
- A way to define states
- A conditional transition command that transfers to a given state if a given condition is true
- A defined entry state that is transitioned to at the start of the program
- A defined exit state that is transitioned to to end the program
- A defined default state that is transitioned to by default when a state block reaches end of execution (usually the exit state)
- Global tables of variables, constants, and IO streams that are referenced by all states
- Read and print statements which input and output data
- Data types like strings, numerical values, booleans, etc
- Expressions which operate on data and assign that data to variablesA simple state machine program can be written in pseudocode as follows:
global constant VALUE = 2
global variable difference = 0
global variable inputglobal input stream stdin
state start
prompt "Input value"
read stdin into input
transition to otherstate other
print "I am dog"
difference = value - input
transition to final_a if difference > 1
transition to final_b if difference == 1
transition to final_c otherwisestate final_a
print "Difference is greater than 1"state final_b
print "Difference is 1"state final_c
print "Difference is less than 1"## The Jump Language
### States
state
A state is defined using the `state` keyword, followed by a name for the state. After which, each line until the next declaration or the end of file is a statement declaration.
### Statements
#### Print Statement
print [-> ]
The `print` statement prints the given string (along with a newline character) to the output stream. Print statements are defined as follows:
##### Prompt Statement
prompt [-> ]
A derivative of the `print` statement, the `prompt` statement prints a space instead of a newline after the string. This can be used for prompts to get inputs from the user.
#### Read Statement
read [ ->]
The `read` statement reads a value from the input stream into the given variable.
#### To Statement
to [if | otherwise]
The `to` statement defines transitions. The `if` clause is an optional condition specifier which will only let the transition execute if the condition is true. The `otherwise` clause always evaluates to true and serves as a decorator for transition blocks.
##### Loop Statement
loop [if | otherwise]
The `loop` statement is shorthand for a transition to the beginning of the current state.
##### End Statement
end [if | otherwise]
The `end` statement is shorthand for a transition to the end state