STP - State Transition Parser

STP is a parsing system that allows for the creation of Doman Specific Languages (DSL).  This is available from GitHub.  It consists of the following elements: 

Grammar

 The grammar is what drives the parser. It defines the DSL commands and how they are to be actioned. Internally a grammer consists of named States with ways to transition between the states, There is an initial state that sets the starting point for the parser. Each State has a name, and an ordered list of transitions. If the next token matches one of the transititions the parser will jump to that names transition. 

The grammar can be created in a number of ways: 

  1. It can be read from a JSON file. 
  2. It can be created calling the Grammar Builder. Though fast, this is the least flexible method.
  3. Grammar specification file. This is the simplest and easiest to use, but this itself has to be parsed on startup.

Tokenizer

The Tokenizer converts the input string in to individual tokens that will be parsed, according to the grammar rules. It is passed the string, or file, with the commands to be parsed. Standard tokenizers are provided, but these can be replaced or supplemented by specialist tokenizers. 
 

Parser

The parser is the tool that accepts the grammar and the list of tokens. It will read the tokens and match them to the transitions. If a token matches it can call back to the calling program, passing the token as a parameter. It will then move to the next state specified on the transition and repeat this with the next token. If no transition matches, the parse is said to have failed, and the parser raises an exception. 
 
STP was originally created for the "C" language, but this version is no longer supplied. The libraries are made available in JAVA, with a road map to also create a RUST version. 
STP is offered free of charge under GPL 3.