Skip to content

Commit

Permalink
dot prelude in compiler, grammar, parser, tests
Browse files Browse the repository at this point in the history
  • Loading branch information
StoneCypher committed Jan 26, 2020
1 parent eb3669a commit 76422f5
Show file tree
Hide file tree
Showing 13 changed files with 81 additions and 28 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
@@ -1,3 +1,4 @@
* [[`eb3669a237`](https://github.com/StoneCypher/jssm/commit/eb3669a237)] - rebuild and bump (John Haugeland)
* [[`3b73089555`](https://github.com/StoneCypher/jssm/commit/3b73089555)] - constants tie-up (John Haugeland)
* [[`de88e4d647`](https://github.com/StoneCypher/jssm/commit/de88e4d647)] - last several added flow, closes #278 and thus closes #286 (John Haugeland)
* [[`920c8622c2`](https://github.com/StoneCypher/jssm/commit/920c8622c2)] - add flow direction to parser; tests (John Haugeland)
Expand Down
17 changes: 11 additions & 6 deletions dist/jssm.es5.cjs.js
Expand Up @@ -13315,7 +13315,7 @@ function peg$parse(input, options) {
return s0;
}

function peg$parseDotPrelude() {
function peg$parseDotPreamble() {
var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9;

s0 = peg$currPos;
Expand Down Expand Up @@ -13437,7 +13437,7 @@ function peg$parse(input, options) {
if (s0 === peg$FAILED) {
s0 = peg$parseMachineTheme();
if (s0 === peg$FAILED) {
s0 = peg$parseDotPrelude();
s0 = peg$parseDotPreamble();
if (s0 === peg$FAILED) {
s0 = peg$parseMachineFlow();
}
Expand Down Expand Up @@ -14024,7 +14024,7 @@ var jssmDot = {
var jssmDot_1 = jssmDot.parse;

// whargarbl lots of these return arrays could/should be sets
var version = '5.21.1'; // replaced from package.js in build // TODO FIXME currently broken
var version = '5.22.0'; // replaced from package.js in build // TODO FIXME currently broken
/* eslint-disable complexity */
function arrow_direction(arrow) {
switch (String(arrow)) {
Expand Down Expand Up @@ -14235,7 +14235,7 @@ function compile_rule_handler(rule) {
'graph_layout', 'start_states', 'end_states', 'machine_name', 'machine_version',
'machine_comment', 'machine_author', 'machine_contributor', 'machine_definition',
'machine_reference', 'machine_license', 'fsl_version', 'state_config', 'theme',
'flow'
'flow', 'dot_preamble'
];
if (tautologies.includes(rule.key)) {
return { agg_as: rule.key, val: rule.value };
Expand All @@ -14261,6 +14261,7 @@ function compile(tree) {
machine_reference: [],
theme: [],
flow: [],
dot_preamble: [],
machine_version: []
};
tree.map(function (tr) {
Expand All @@ -14274,7 +14275,7 @@ function compile(tree) {
};
var oneOnlyKeys = [
'graph_layout', 'machine_name', 'machine_version', 'machine_comment', 'fsl_version', 'machine_license',
'machine_definition', 'machine_language', 'theme', 'flow'
'machine_definition', 'machine_language', 'theme', 'flow', 'dot_preamble'
];
oneOnlyKeys.map(function (oneOnlyKey) {
if (results[oneOnlyKey].length > 1) {
Expand Down Expand Up @@ -14314,7 +14315,7 @@ var Machine = /** @class */ (function () {
// whargarbl this badly needs to be broken up, monolith master
function Machine(_a) {
var _this = this;
var start_states = _a.start_states, _b = _a.complete, complete = _b === void 0 ? [] : _b, transitions = _a.transitions, machine_author = _a.machine_author, machine_comment = _a.machine_comment, machine_contributor = _a.machine_contributor, machine_definition = _a.machine_definition, machine_language = _a.machine_language, machine_license = _a.machine_license, machine_name = _a.machine_name, machine_version = _a.machine_version, state_declaration = _a.state_declaration, fsl_version = _a.fsl_version, _c = _a.theme, theme = _c === void 0 ? 'default' : _c, _d = _a.flow, flow = _d === void 0 ? 'down' : _d, _e = _a.graph_layout, graph_layout = _e === void 0 ? 'dot' : _e;
var start_states = _a.start_states, _b = _a.complete, complete = _b === void 0 ? [] : _b, transitions = _a.transitions, machine_author = _a.machine_author, machine_comment = _a.machine_comment, machine_contributor = _a.machine_contributor, machine_definition = _a.machine_definition, machine_language = _a.machine_language, machine_license = _a.machine_license, machine_name = _a.machine_name, machine_version = _a.machine_version, state_declaration = _a.state_declaration, fsl_version = _a.fsl_version, _c = _a.dot_preamble, dot_preamble = _c === void 0 ? undefined : _c, _d = _a.theme, theme = _d === void 0 ? 'default' : _d, _e = _a.flow, flow = _e === void 0 ? 'down' : _e, _f = _a.graph_layout, graph_layout = _f === void 0 ? 'dot' : _f;
this._state = start_states[0];
this._states = new Map();
this._state_declarations = new Map();
Expand All @@ -14334,6 +14335,7 @@ var Machine = /** @class */ (function () {
this._machine_version = machine_version;
this._raw_state_declaration = state_declaration || [];
this._fsl_version = fsl_version;
this._dot_preamble = dot_preamble;
this._theme = theme;
this._flow = flow;
this._graph_layout = graph_layout;
Expand Down Expand Up @@ -14460,6 +14462,9 @@ var Machine = /** @class */ (function () {
Machine.prototype.graph_layout = function () {
return this._graph_layout;
};
Machine.prototype.dot_preamble = function () {
return this._dot_preamble;
};
Machine.prototype.machine_author = function () {
return this._machine_author;
};
Expand Down
2 changes: 1 addition & 1 deletion dist/jssm.es5.cjs.js.map

Large diffs are not rendered by default.

17 changes: 11 additions & 6 deletions dist/jssm.es6.js
Expand Up @@ -13311,7 +13311,7 @@ function peg$parse(input, options) {
return s0;
}

function peg$parseDotPrelude() {
function peg$parseDotPreamble() {
var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9;

s0 = peg$currPos;
Expand Down Expand Up @@ -13433,7 +13433,7 @@ function peg$parse(input, options) {
if (s0 === peg$FAILED) {
s0 = peg$parseMachineTheme();
if (s0 === peg$FAILED) {
s0 = peg$parseDotPrelude();
s0 = peg$parseDotPreamble();
if (s0 === peg$FAILED) {
s0 = peg$parseMachineFlow();
}
Expand Down Expand Up @@ -14020,7 +14020,7 @@ var jssmDot = {
var jssmDot_1 = jssmDot.parse;

// whargarbl lots of these return arrays could/should be sets
var version = '5.21.1'; // replaced from package.js in build // TODO FIXME currently broken
var version = '5.22.0'; // replaced from package.js in build // TODO FIXME currently broken
/* eslint-disable complexity */
function arrow_direction(arrow) {
switch (String(arrow)) {
Expand Down Expand Up @@ -14231,7 +14231,7 @@ function compile_rule_handler(rule) {
'graph_layout', 'start_states', 'end_states', 'machine_name', 'machine_version',
'machine_comment', 'machine_author', 'machine_contributor', 'machine_definition',
'machine_reference', 'machine_license', 'fsl_version', 'state_config', 'theme',
'flow'
'flow', 'dot_preamble'
];
if (tautologies.includes(rule.key)) {
return { agg_as: rule.key, val: rule.value };
Expand All @@ -14257,6 +14257,7 @@ function compile(tree) {
machine_reference: [],
theme: [],
flow: [],
dot_preamble: [],
machine_version: []
};
tree.map(function (tr) {
Expand All @@ -14270,7 +14271,7 @@ function compile(tree) {
};
var oneOnlyKeys = [
'graph_layout', 'machine_name', 'machine_version', 'machine_comment', 'fsl_version', 'machine_license',
'machine_definition', 'machine_language', 'theme', 'flow'
'machine_definition', 'machine_language', 'theme', 'flow', 'dot_preamble'
];
oneOnlyKeys.map(function (oneOnlyKey) {
if (results[oneOnlyKey].length > 1) {
Expand Down Expand Up @@ -14310,7 +14311,7 @@ var Machine = /** @class */ (function () {
// whargarbl this badly needs to be broken up, monolith master
function Machine(_a) {
var _this = this;
var start_states = _a.start_states, _b = _a.complete, complete = _b === void 0 ? [] : _b, transitions = _a.transitions, machine_author = _a.machine_author, machine_comment = _a.machine_comment, machine_contributor = _a.machine_contributor, machine_definition = _a.machine_definition, machine_language = _a.machine_language, machine_license = _a.machine_license, machine_name = _a.machine_name, machine_version = _a.machine_version, state_declaration = _a.state_declaration, fsl_version = _a.fsl_version, _c = _a.theme, theme = _c === void 0 ? 'default' : _c, _d = _a.flow, flow = _d === void 0 ? 'down' : _d, _e = _a.graph_layout, graph_layout = _e === void 0 ? 'dot' : _e;
var start_states = _a.start_states, _b = _a.complete, complete = _b === void 0 ? [] : _b, transitions = _a.transitions, machine_author = _a.machine_author, machine_comment = _a.machine_comment, machine_contributor = _a.machine_contributor, machine_definition = _a.machine_definition, machine_language = _a.machine_language, machine_license = _a.machine_license, machine_name = _a.machine_name, machine_version = _a.machine_version, state_declaration = _a.state_declaration, fsl_version = _a.fsl_version, _c = _a.dot_preamble, dot_preamble = _c === void 0 ? undefined : _c, _d = _a.theme, theme = _d === void 0 ? 'default' : _d, _e = _a.flow, flow = _e === void 0 ? 'down' : _e, _f = _a.graph_layout, graph_layout = _f === void 0 ? 'dot' : _f;
this._state = start_states[0];
this._states = new Map();
this._state_declarations = new Map();
Expand All @@ -14330,6 +14331,7 @@ var Machine = /** @class */ (function () {
this._machine_version = machine_version;
this._raw_state_declaration = state_declaration || [];
this._fsl_version = fsl_version;
this._dot_preamble = dot_preamble;
this._theme = theme;
this._flow = flow;
this._graph_layout = graph_layout;
Expand Down Expand Up @@ -14456,6 +14458,9 @@ var Machine = /** @class */ (function () {
Machine.prototype.graph_layout = function () {
return this._graph_layout;
};
Machine.prototype.dot_preamble = function () {
return this._dot_preamble;
};
Machine.prototype.machine_author = function () {
return this._machine_author;
};
Expand Down
2 changes: 1 addition & 1 deletion dist/jssm.es6.js.map

Large diffs are not rendered by default.

17 changes: 11 additions & 6 deletions dist/jssm.iife.js
Expand Up @@ -13314,7 +13314,7 @@ var jssm = (function (exports) {
return s0;
}

function peg$parseDotPrelude() {
function peg$parseDotPreamble() {
var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9;

s0 = peg$currPos;
Expand Down Expand Up @@ -13436,7 +13436,7 @@ var jssm = (function (exports) {
if (s0 === peg$FAILED) {
s0 = peg$parseMachineTheme();
if (s0 === peg$FAILED) {
s0 = peg$parseDotPrelude();
s0 = peg$parseDotPreamble();
if (s0 === peg$FAILED) {
s0 = peg$parseMachineFlow();
}
Expand Down Expand Up @@ -14023,7 +14023,7 @@ var jssm = (function (exports) {
var jssmDot_1 = jssmDot.parse;

// whargarbl lots of these return arrays could/should be sets
var version = '5.21.1'; // replaced from package.js in build // TODO FIXME currently broken
var version = '5.22.0'; // replaced from package.js in build // TODO FIXME currently broken
/* eslint-disable complexity */
function arrow_direction(arrow) {
switch (String(arrow)) {
Expand Down Expand Up @@ -14234,7 +14234,7 @@ var jssm = (function (exports) {
'graph_layout', 'start_states', 'end_states', 'machine_name', 'machine_version',
'machine_comment', 'machine_author', 'machine_contributor', 'machine_definition',
'machine_reference', 'machine_license', 'fsl_version', 'state_config', 'theme',
'flow'
'flow', 'dot_preamble'
];
if (tautologies.includes(rule.key)) {
return { agg_as: rule.key, val: rule.value };
Expand All @@ -14260,6 +14260,7 @@ var jssm = (function (exports) {
machine_reference: [],
theme: [],
flow: [],
dot_preamble: [],
machine_version: []
};
tree.map(function (tr) {
Expand All @@ -14273,7 +14274,7 @@ var jssm = (function (exports) {
};
var oneOnlyKeys = [
'graph_layout', 'machine_name', 'machine_version', 'machine_comment', 'fsl_version', 'machine_license',
'machine_definition', 'machine_language', 'theme', 'flow'
'machine_definition', 'machine_language', 'theme', 'flow', 'dot_preamble'
];
oneOnlyKeys.map(function (oneOnlyKey) {
if (results[oneOnlyKey].length > 1) {
Expand Down Expand Up @@ -14313,7 +14314,7 @@ var jssm = (function (exports) {
// whargarbl this badly needs to be broken up, monolith master
function Machine(_a) {
var _this = this;
var start_states = _a.start_states, _b = _a.complete, complete = _b === void 0 ? [] : _b, transitions = _a.transitions, machine_author = _a.machine_author, machine_comment = _a.machine_comment, machine_contributor = _a.machine_contributor, machine_definition = _a.machine_definition, machine_language = _a.machine_language, machine_license = _a.machine_license, machine_name = _a.machine_name, machine_version = _a.machine_version, state_declaration = _a.state_declaration, fsl_version = _a.fsl_version, _c = _a.theme, theme = _c === void 0 ? 'default' : _c, _d = _a.flow, flow = _d === void 0 ? 'down' : _d, _e = _a.graph_layout, graph_layout = _e === void 0 ? 'dot' : _e;
var start_states = _a.start_states, _b = _a.complete, complete = _b === void 0 ? [] : _b, transitions = _a.transitions, machine_author = _a.machine_author, machine_comment = _a.machine_comment, machine_contributor = _a.machine_contributor, machine_definition = _a.machine_definition, machine_language = _a.machine_language, machine_license = _a.machine_license, machine_name = _a.machine_name, machine_version = _a.machine_version, state_declaration = _a.state_declaration, fsl_version = _a.fsl_version, _c = _a.dot_preamble, dot_preamble = _c === void 0 ? undefined : _c, _d = _a.theme, theme = _d === void 0 ? 'default' : _d, _e = _a.flow, flow = _e === void 0 ? 'down' : _e, _f = _a.graph_layout, graph_layout = _f === void 0 ? 'dot' : _f;
this._state = start_states[0];
this._states = new Map();
this._state_declarations = new Map();
Expand All @@ -14333,6 +14334,7 @@ var jssm = (function (exports) {
this._machine_version = machine_version;
this._raw_state_declaration = state_declaration || [];
this._fsl_version = fsl_version;
this._dot_preamble = dot_preamble;
this._theme = theme;
this._flow = flow;
this._graph_layout = graph_layout;
Expand Down Expand Up @@ -14459,6 +14461,9 @@ var jssm = (function (exports) {
Machine.prototype.graph_layout = function () {
return this._graph_layout;
};
Machine.prototype.dot_preamble = function () {
return this._dot_preamble;
};
Machine.prototype.machine_author = function () {
return this._machine_author;
};
Expand Down
2 changes: 1 addition & 1 deletion dist/jssm.iife.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/lib/index.html
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<meta charset='utf-8'>
<title>jssm 5.21.1 | Documentation</title>
<title>jssm 5.22.0 | Documentation</title>
<meta name='description' content='A Javascript finite state machine (FSM) with a terse DSL and a simple API. Well tested, and typed with Flowtype. MIT License.'>
<meta name='viewport' content='width=device-width,initial-scale=1'>
<link href='assets/bass.css' rel='stylesheet'>
Expand All @@ -15,7 +15,7 @@
<div id='split-left' class='overflow-auto fs0 height-viewport-100'>
<div class='py1 px2'>
<h3 class='mb0 no-anchor'>jssm</h3>
<div class='mb1'><code>5.21.1</code></div>
<div class='mb1'><code>5.22.0</code></div>
<input
placeholder='Filter'
id='filter-input'
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "jssm",
"version": "5.21.1",
"version": "5.23.0",
"engines": {
"node": ">=6.0.0"
},
Expand Down
6 changes: 4 additions & 2 deletions src/js/jssm-dot.peg
Expand Up @@ -763,7 +763,7 @@ MachineTheme
MachineFlow
= WS? "flow" WS? ":" WS? value:Direction WS? ";" WS? { return { key: "flow", value }; }

DotPrelude
DotPreamble
= WS? "dot_preamble" WS? ":" WS? value:String WS? ";" WS? { return { key: "dot_preamble", value }; }

MachineAttribute "machine attribute"
Expand All @@ -777,7 +777,7 @@ MachineAttribute "machine attribute"
/ MachineLicense
/ MachineLanguage
/ MachineTheme
/ DotPrelude
/ DotPreamble
/ MachineFlow


Expand All @@ -801,6 +801,8 @@ StateDeclaration





NamedList
= WS? "&" WS? name:Label WS? ":" WS? value:LabelOrLabelList WS? ";" WS? { return { key:'named_list', name, value }; }

Expand Down
13 changes: 11 additions & 2 deletions src/js/jssm.ts
Expand Up @@ -277,7 +277,7 @@ function compile_rule_handler(rule: JssmCompileSeStart): JssmCompileRule { // to
'graph_layout', 'start_states', 'end_states', 'machine_name', 'machine_version',
'machine_comment', 'machine_author', 'machine_contributor', 'machine_definition',
'machine_reference', 'machine_license', 'fsl_version', 'state_config', 'theme',
'flow'
'flow', 'dot_preamble'
];

if (tautologies.includes(rule.key)) {
Expand Down Expand Up @@ -312,6 +312,7 @@ function compile<mDT>(tree: JssmParseTree): JssmGenericConfig<mDT> { // todo fl
machine_reference : Array< string >,
theme : Array< string >,
flow : Array< string >,
dot_preamble : Array< string >,
machine_version : Array< string > // semver
} = {
graph_layout : [],
Expand All @@ -331,6 +332,7 @@ function compile<mDT>(tree: JssmParseTree): JssmGenericConfig<mDT> { // todo fl
machine_reference : [],
theme : [],
flow : [],
dot_preamble : [],
machine_version : []
};

Expand All @@ -353,7 +355,7 @@ function compile<mDT>(tree: JssmParseTree): JssmGenericConfig<mDT> { // todo fl

const oneOnlyKeys : Array<string> = [
'graph_layout', 'machine_name', 'machine_version', 'machine_comment', 'fsl_version', 'machine_license',
'machine_definition', 'machine_language', 'theme', 'flow'
'machine_definition', 'machine_language', 'theme', 'flow', 'dot_preamble'
];

oneOnlyKeys.map( (oneOnlyKey : string) => {
Expand Down Expand Up @@ -434,6 +436,7 @@ class Machine<mDT> {
_state_declarations : Map<StateType, JssmStateDeclaration>;

_graph_layout : JssmLayout;
_dot_preamble : string;

_theme : FslTheme;
_flow : FslDirection;
Expand All @@ -454,6 +457,7 @@ class Machine<mDT> {
machine_version,
state_declaration,
fsl_version,
dot_preamble = undefined,
theme = 'default',
flow = 'down',
graph_layout = 'dot'
Expand All @@ -480,6 +484,7 @@ class Machine<mDT> {
this._raw_state_declaration = state_declaration || [];
this._fsl_version = fsl_version;

this._dot_preamble = dot_preamble;
this._theme = theme;
this._flow = flow;
this._graph_layout = graph_layout;
Expand Down Expand Up @@ -643,6 +648,10 @@ class Machine<mDT> {
return this._graph_layout;
}

dot_preamble(): string {
return this._dot_preamble;
}



machine_author(): Array<string> {
Expand Down
2 changes: 2 additions & 0 deletions src/js/jssm_types.ts
Expand Up @@ -200,6 +200,8 @@ type JssmGenericConfig<DataType> = {

simplify_bidi? : boolean,

dot_preamble? : string,

start_states : Array<StateType>,
end_states? : Array<StateType>,

Expand Down

0 comments on commit 76422f5

Please sign in to comment.