updated format pattern...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2018-09-26 02:08:46 +03:00
parent a55474c51f
commit c57b42cfd1
2 changed files with 30 additions and 25 deletions

View File

@ -719,6 +719,7 @@ object.makeConstructor('IN', Object.assign(Object.create(LogicType.prototype), {
// cmp(X, {'moo', 333}) // cmp(X, {'moo', 333})
// ...this would also break on checking a recursive structure against // ...this would also break on checking a recursive structure against
// a recursive pattern... // a recursive pattern...
// XXX should this also check inherited keys???
// XXX support Maps, ... // XXX support Maps, ...
var AT = var AT =
module.AT = module.AT =

View File

@ -22,6 +22,16 @@ var {
} = diff } = diff
/*********************************************************************/
// helpers...
// OPT(key, value) -> true if key matches value or does not exist...
var OPT = function(key, value){
return OR(
NOT(AT(key)),
AT(key, value)) }
/*********************************************************************/ /*********************************************************************/
// //
@ -41,24 +51,14 @@ module.VALUE = OR(
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Change A/B side values...
var SIDE_VALUES =
module.SIDE_VALUES = OR(
// A and B...
AND(
AT('A', VALUE),
AT('B', VALUE)),
// only A...
AT('A', VALUE),
// only B...
AT('B', VALUE))
// Basic change... // Basic change...
var CHANGE = var CHANGE =
module.CHANGE = AND( module.CHANGE = AND(
AT('path', L), AT('path', L),
AT('type', OR(S, undefined)), OPT('type', S),
SIDE_VALUES) // NOTE: this matches if one or both of A and B exist and if they
// do the match VALUE...
AT(OR('A', 'B'), VALUE))
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -77,7 +77,7 @@ module.DIFF_FLAT = OR(
var BASIC_CHANGE = var BASIC_CHANGE =
module.BASIC_CHANGE = AND( module.BASIC_CHANGE = AND(
AT('type', 'Basic'), AT('type', 'Basic'),
SIDE_VALUES) AT(OR('A', 'B'), VALUE))
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -144,7 +144,20 @@ module.DIFF_TREE = OR(
//--------------------------------------------------------------------- //---------------------------------------------------------------------
// Diff -- the root data structure... // Diff -- the root data structure...
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Options...
var OPTIONS =
module.OPTIONS = AND(
OPT('tree_diff', B),
OPT('keep_none', B),
OPT('min_text_length', N),
OPT('no_attributes', B),
OPT('NONE', ANY),
OPT('EMPTY', ANY),
OPT('no_length', B),
OPT('cmp', F) )
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
var DIFF_OBJECT = var DIFF_OBJECT =
module.DIFF_OBJECT = AND( module.DIFF_OBJECT = AND(
// format metadata... // format metadata...
@ -153,16 +166,7 @@ module.DIFF_OBJECT = AND(
AT('version', diff.FORMAT_VERSION), AT('version', diff.FORMAT_VERSION),
// instance metadata... // instance metadata...
AT('options', AT('options', OPTIONS),
AND(
AT('tree_diff', OR(B, NULL)),
AT('keep_none', OR(B, NULL)),
AT('min_text_length', OR(N, NULL)),
AT('no_attributes', OR(B, NULL)),
AT('NONE', OR(ANY, NULL)),
AT('EMPTY', OR(ANY, NULL)),
AT('no_length', OR(B, NULL)),
AT('cmp', OR(F, NULL)) )),
AT('placeholders', AT('placeholders',
AND( AND(
AT('NONE', AT('NONE',