Skip to content

Commit

Permalink
finalize in_state:, out_state:, state: ; add state keyword to state d…
Browse files Browse the repository at this point in the history
…eclarations
  • Loading branch information
StoneCypher committed Jan 9, 2020
1 parent 6bc16b6 commit ae2b2fc
Show file tree
Hide file tree
Showing 14 changed files with 1,568 additions and 693 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
@@ -1,6 +1,13 @@
* [[`6bc16b6cff`](https://github.com/StoneCypher/jssm/commit/6bc16b6cff)] - merge and fix resulting eslint mess (John Haugeland)
* [[`9f9d02d228`](https://github.com/StoneCypher/jssm/commit/9f9d02d228)] - Added state, in\_state, out\_state top level properties w/ vat; repaired shape w/ vat; tests (John Haugeland)
* [[`f99017834d`](https://github.com/StoneCypher/jssm/commit/f99017834d)] - Added state, in\_state, out\_state top level properties w/ vat; repaired shape w/ vat; tests (John Haugeland)
* [[`134c186389`](https://github.com/StoneCypher/jssm/commit/134c186389)] - extensive repair node shape -\> state shape w/ vat (John Haugeland)
* [[`dce8174435`](https://github.com/StoneCypher/jssm/commit/dce8174435)] - Update README.md (John Haugeland)
* [[`3fb6134b80`](https://github.com/StoneCypher/jssm/commit/3fb6134b80)] - update eslint (John Haugeland)
* [[`7845b0f62c`](https://github.com/StoneCypher/jssm/commit/7845b0f62c)] - roll back opencollective image thing (John Haugeland)
* [[`afbd96094e`](https://github.com/StoneCypher/jssm/commit/afbd96094e)] - Update README.md (John Haugeland)
* [[`b45738cea7`](https://github.com/StoneCypher/jssm/commit/b45738cea7)] - support for module field and thus importing from es6 version, should improve tree shaking significantly (John Haugeland)
* [[`71148158e1`](https://github.com/StoneCypher/jssm/commit/71148158e1)] - bump nyc over security issue (John Haugeland)
* [[`c39ec14c04`](https://github.com/StoneCypher/jssm/commit/c39ec14c04)] - rebuild and bump to .16 prior to publish (John Haugeland)
* [[`5ba3f22440`](https://github.com/StoneCypher/jssm/commit/5ba3f22440)] - right, coverage is outside build in the ci action, so, make one for gh (John Haugeland)
* [[`518be0962d`](https://github.com/StoneCypher/jssm/commit/518be0962d)] - node 13 and 14 may not exist (John Haugeland)
Expand Down
723 changes: 505 additions & 218 deletions dist/jssm.es5.cjs.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/jssm.es5.cjs.js.map

Large diffs are not rendered by default.

723 changes: 505 additions & 218 deletions dist/jssm.es6.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/jssm.es6.js.map

Large diffs are not rendered by default.

723 changes: 505 additions & 218 deletions dist/jssm.iife.js

Large diffs are not rendered by default.

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.18.1 | Documentation</title>
<title>jssm 5.19.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.18.1</code></div>
<div class='mb1'><code>5.19.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.18.1",
"version": "5.19.0",
"engines": {
"node": ">=6.0.0"
},
Expand Down
21 changes: 13 additions & 8 deletions src/js/jssm-dot.peg
Expand Up @@ -600,7 +600,7 @@ StateItemShapeKey
= "shape"

StateItemShape
= WS? "shape" WS? ":" WS? value:GvizShape WS? ";" WS? { return {key:key, value:value}; }
= WS? "shape" WS? ":" WS? value:GvizShape WS? ";" WS? { return {key:"shape", value:value}; }

StateItem
= StateItemShape
Expand All @@ -610,19 +610,24 @@ StateItems

ConfigState
= WS? "state" WS? ":" WS? "{" WS? state_items:StateItems? WS? "};" WS? {
return { config_kind: "state", config_items: state_items || [] };
return { key: "state_config", value: { config_kind: "state", config_items: state_items || [] } };
}

ConfigInState
= WS? "instate" WS? ":" WS? "{" WS? state_items:StateItems? WS? "};" WS? {
return { config_kind: "state", config_items: state_items || [] };
= WS? "in_state" WS? ":" WS? "{" WS? state_items:StateItems? WS? "};" WS? {
return { key: "state_config", value: { config_kind: "in_state", config_items: state_items || [] } };
}

ConfigOutState
= WS? "outstate" WS? ":" WS? "{" WS? state_items:StateItems? WS? "};" WS? {
return { config_kind: "state", config_items: state_items || [] };
= WS? "out_state" WS? ":" WS? "{" WS? state_items:StateItems? WS? "};" WS? {
return { key: "state_config", value: { config_kind: "out_state", config_items: state_items || [] } };
}

ConfigAnyState
= ConfigState
/ ConfigInState
/ ConfigOutState



ActionKey
Expand Down Expand Up @@ -683,7 +688,7 @@ Config "configuration"
/ ConfigEndNodes
/ ConfigTransition
/ ConfigAction
/ ConfigState
/ ConfigAnyState
/ ConfigValidation
/ ConfigGraphBgColor

Expand Down Expand Up @@ -764,7 +769,7 @@ StateDeclarationDesc
= "{" WS? items:StateDeclarationItems* WS? "}" { return items; }

StateDeclaration
= WS? state_name:Label WS? ":" WS? decl_desc:StateDeclarationDesc WS? ";" WS? { return {key:'state_declaration', name: state_name, value:decl_desc}; }
= WS? "state" WS state_name:Label WS? ":" WS? decl_desc:StateDeclarationDesc WS? ";" WS? { return {key:'state_declaration', name: state_name, value:decl_desc}; }



Expand Down
6 changes: 4 additions & 2 deletions src/js/jssm.ts
Expand Up @@ -275,7 +275,7 @@ function compile_rule_handler(rule: JssmCompileSeStart): JssmCompileRule { // to
const tautologies : Array<string> = [
'graph_layout', 'start_states', 'end_states', 'machine_name', 'machine_version',
'machine_comment', 'machine_author', 'machine_contributor', 'machine_definition',
'machine_reference', 'machine_license', 'fsl_version'
'machine_reference', 'machine_license', 'fsl_version', 'state_config'
];

if (tautologies.includes(rule.key)) {
Expand All @@ -297,6 +297,7 @@ function compile<mDT>(tree: JssmParseTree): JssmGenericConfig<mDT> { // todo fl
transition : Array< JssmTransition<mDT> >,
start_states : Array< string >,
end_states : Array< string >,
state_config : Array< any >, // todo comeback no any
state_declaration : Array< string >,
fsl_version : Array< string >,
machine_author : Array< string >,
Expand All @@ -313,6 +314,7 @@ function compile<mDT>(tree: JssmParseTree): JssmGenericConfig<mDT> { // todo fl
transition : [],
start_states : [],
end_states : [],
state_config : [],
state_declaration : [],
fsl_version : [],
machine_author : [],
Expand All @@ -330,7 +332,7 @@ function compile<mDT>(tree: JssmParseTree): JssmGenericConfig<mDT> { // todo fl

const rule : JssmCompileRule = compile_rule_handler(tr),
agg_as : string = rule.agg_as,
val : any = rule.val; // TODO FIXME no any
val : any = rule.val; // TODO FIXME no any

results[agg_as] = results[agg_as].concat(val);

Expand Down
28 changes: 14 additions & 14 deletions src/js/tests/nominated states.js
Expand Up @@ -13,21 +13,21 @@ describe('simple naming', async _it => {

describe('parse', async it => {

it('trans then node', t => t.notThrows(() => { jp('a -> b; a: { color: orange; };'); }) );
it('node then trans', t => t.notThrows(() => { jp('a: { color: orange; }; a -> b;'); }) );
it('cycle node named', t => t.notThrows(() => { jp('[a b] -> +1; a: { color: red; }; &b: [a c e];'); }) );
it('trans then node', t => t.notThrows(() => { jp('a -> b; state a: { color: orange; };'); }) );
it('node then trans', t => t.notThrows(() => { jp('state a: { color: orange; }; a -> b;'); }) );
it('cycle node named', t => t.notThrows(() => { jp('[a b] -> +1; state a: { color: red; }; &b: [a c e];'); }) );

it('two properties', t => t.notThrows(() => { jp('a -> b; a: { color: orange; shape: circle; };'); }) );
it('two properties', t => t.notThrows(() => { jp('a -> b; state a: { color: orange; shape: circle; };'); }) );

});

describe('sm tag', async it => {

it('trans then node', t => t.notThrows(() => { sm`a -> b; a: { color: orange; };`; }) );
it('node then trans', t => t.notThrows(() => { sm`a: { color: orange; }; a -> b;`; }) );
// it('cycle node named', t => t.notThrows(() => { sm`[a b] -> +1; a: { color: red; }; &b: [a c e];`; }) );
it('trans then node', t => t.notThrows(() => { sm`a -> b; state a: { color: orange; };`; }) );
it('node then trans', t => t.notThrows(() => { sm`state a: { color: orange; }; a -> b;`; }) );
// it('cycle node named', t => t.notThrows(() => { sm`[a b] -> +1; state a: { color: red; }; &b: [a c e];`; }) );

it('two properties', t => t.notThrows(() => { sm`a -> b; a: { color: orange; shape: circle; };`; }) );
it('two properties', t => t.notThrows(() => { sm`a -> b; state a: { color: orange; shape: circle; };`; }) );

});

Expand All @@ -39,11 +39,11 @@ describe('simple naming', async _it => {

describe('spacing variants', async it => {

it('tight', t => t.notThrows(() => { jp('a -> b; a:{color:orange;};'); }) );
it('framed', t => t.notThrows(() => { jp('a -> b; a:{ color:orange; };'); }) );
it('sentence', t => t.notThrows(() => { jp('a -> b; a:{ color: orange; };'); }) );
it('fully', t => t.notThrows(() => { jp('a -> b; a:{ color : orange; };'); }) );
it('mars', t => t.notThrows(() => { jp('a -> b; a:{color : orange;};'); }) );
it('tight', t => t.notThrows(() => { jp('a -> b; state a:{color:orange;};'); }) );
it('framed', t => t.notThrows(() => { jp('a -> b; state a:{ color:orange; };'); }) );
it('sentence', t => t.notThrows(() => { jp('a -> b; state a:{ color: orange; };'); }) );
it('fully', t => t.notThrows(() => { jp('a -> b; state a:{ color : orange; };'); }) );
it('mars', t => t.notThrows(() => { jp('a -> b; state a:{color : orange;};'); }) );

});

Expand All @@ -55,7 +55,7 @@ describe('properties', async it => {

it('color', t => t.deepEqual(
{state:'a', color:'#ffa500ff', declarations:[{key: "color", value: "#ffa500ff"}]},
sm`a -> b; a:{color:orange;};`.raw_state_declarations()[0]
sm`a -> b; state a:{color:orange;};`.raw_state_declarations()[0]
));

});
Expand Down
4 changes: 2 additions & 2 deletions src/js/tests/shapes.js
Expand Up @@ -20,10 +20,10 @@ describe('GraphViz Shapes', async it => {

Shapes.map(shape =>
it(`Shape "${shape}" parses as a shape`, t =>
t.notThrows( () => { const _foo = sm`c: { shape: ${shape}; }; a -> b;`; }) ) );
t.notThrows( () => { const _foo = sm`state c: { shape: ${shape}; }; a -> b;`; }) ) );

// misspelling the last character of restrictionsite gets parser coverage
it('handles parse end', t =>
t.throws( () => { const _foo = sm`c: { shape: restrictionsitz; }; a -> b;`; }) );
t.throws( () => { const _foo = sm`state c: { shape: restrictionsitz; }; a -> b;`; }) );

});
14 changes: 7 additions & 7 deletions src/js/tests/state_declaration.js
Expand Up @@ -12,9 +12,9 @@ const jssm = require('../../../build/jssm.es5.cjs.js'),

describe("doesn't throw", async it => {

it('with no attributes', t => t.notThrows(() => { const _foo = sm`c: {}; a -> b;`; }) );
it('with just whitespace', t => t.notThrows(() => { const _foo = sm`c: { }; a -> b;`; }) );
it('with just node color', t => t.notThrows(() => { const _foo = sm`c: { color: red; }; a -> b;`; }) );
it('with no attributes', t => t.notThrows(() => { const _foo = sm`state c: {}; a -> b;`; }) );
it('with just whitespace', t => t.notThrows(() => { const _foo = sm`state c: { }; a -> b;`; }) );
it('with just node color', t => t.notThrows(() => { const _foo = sm`state c: { color: red; }; a -> b;`; }) );

});

Expand All @@ -24,9 +24,9 @@ describe("doesn't throw", async it => {

describe('can read declaration', async _it => {

const mach0 = sm`c: { }; a -> b;`;
const mach1 = sm`c: { color: red; }; a -> b;`;
const mach2 = sm`c: { color: red; shape: circle; }; a -> b;`;
const mach0 = sm`state c: { }; a -> b;`;
const mach1 = sm`state c: { color: red; }; a -> b;`;
const mach2 = sm`state c: { color: red; shape: circle; }; a -> b;`;
// const machT = sm`c: { color: red; }; d: { shape: circle; }; a -> b;`;

// const machP = sm`
Expand Down Expand Up @@ -85,7 +85,7 @@ describe('error catchery', async _parse_it => {

describe('repeated declaration', async it => {
it('throws', t => t.throws( () => {
const _mach1 = sm`c: { color: red; }; c: { color: red; }; a -> b;`; // eslint-disable-line no-unused-vars
const _mach1 = sm`state c: { color: red; }; c: { color: red; }; a -> b;`; // eslint-disable-line no-unused-vars
} ));
});

Expand Down

0 comments on commit ae2b2fc

Please sign in to comment.