@gram-data/gram-ast
Advanced tools
Comparing version 0.1.7 to 0.1.8
@@ -211,3 +211,3 @@ 'use strict'; | ||
var isGramEdge = function isGramEdge(o) { | ||
return 'type' in o && 'direction' in o && o.type === 'edge'; | ||
return 'type' in o && 'relation' in o && o.type === 'edge'; | ||
}; | ||
@@ -214,0 +214,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=(e=require("base-x"))&&"object"==typeof e&&"default"in e?e.default:e,r=/[0-9a-zA-Z_@]+\b@*/,n={__proto__:null,boolean:/true|false|TRUE|FALSE\b(?!@)/,hexadecimal:/-?0x(?:[0-9a-fA-F]+)\b(?!@)/,octal:/-?0(?:[0-7]+)\b(?!@)/,measurement:/-?(?:[0-9]|[1-9][0-9]+)(?:\.[0-9]+)?[a-zA-Z]+\b(?!@)/,decimal:/-?(?:[0-9]|[1-9][0-9]+)\.[0-9]+(?:[eE][-+]?[0-9]+)?\b(?!@)/,integer:/-?(?:[0-9]|[1-9][0-9]+)(?:[eE][-+]?[0-9]+)?\b(?!@)/,taggedString:/[a-zA-Z][0-9a-zA-Z_@]*`(?:\\[`bfnrt/\\]|\\u[a-fA-F0-9]{4}|[^`\\])*`/,doubleQuotedString:/"(?:\\["bfnrt/\\]|\\u[a-fA-F0-9]{4}|[^"\\])*"/,singleQuotedString:/'(?:\\['bfnrt/\\]|\\u[a-fA-F0-9]{4}|[^'\\])*'/,tickedString:/`(?:\\[`bfnrt/\\]|\\u[a-fA-F0-9]{4}|[^`\\])*`/,symbol:/[a-zA-Z_][0-9a-zA-Z_]*\b(?!@)/,identifier:r},a=require("shortid"),i={base2:"01",base8:"01234567",base10:"0123456789",base11:"0123456789a",base16:"0123456789abcdef",base32:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",zBase32:"ybndrfg8ejkmcpqxot1uwisza345h769",crock32:"0123456789ABCDEFGHJKMNPQRSTVWXYZ",base32Hex:"0123456789ABCDEFGHIJKLMNOPQRSTUV",base36:"0123456789abcdefghijklmnopqrstuvwxyz",base58:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ",base62:"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",base64:"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_@"};a.characters(i.base64);var o=new RegExp("^"+r.source+"$"),u=o.test.bind(o),s=function(e){var r=t(i.base10);if(e>Number.MAX_SAFE_INTEGER)throw Error("Value cannot exceed Number.MAX_SAFE_INTEGER.");return r.decode(e.toFixed(0))},p=function(e,r){return"_"+t(e).encode(t(i.base10).decode(r))},c=a.generate,l=function(e){return"_"+e.toString(36)},d=function(e){return"number"===e?function(e){return""+e}:"shortid"===e?function(e){return c()}:"base36"===e?l:function(e){return""}},f=function(e){return void 0===e?"":u(e)?e:e.replace(/[\s.,'"]/gi,"_").replace(/[^_0-9a-zA-Z]/gi,"@")},b={__proto__:null,alphabets:i,isValidIdentifier:u,decodeInteger:s,integerToBase:function(e,r){return t(e).encode(s(r))},integerToBaseID:function(e,r){return"_"+t(e).encode(s(r))},integerLiteralToBaseID:p,shortID:c,base36ID:l,idFunctionNamed:d,idEncoder:f,default:{alphabets:i,isValidIdentifier:u,shortID:c,base36ID:l,idFunctionNamed:d,idEncoder:f,integerLiteralToBaseID:p}},y=function(e){return!!e.type&&"unit"===e.type},g=function(e){return!!e.type&&"node"===e.type},x=function(e){return"type"in e&&"direction"in e&&"edge"===e.type},m=function(e){return!!e.type&&"path"===e.type},_=function(e){return!!e.type&&"seq"===e.type};exports.UNIT_ID="0",exports.identity=b,exports.isBooleanLiteral=function(e){return!!e.type&&!!e.value&&"boolean"===e.type},exports.isDateLiteral=function(e){return!!e.type&&!!e.value&&!!e.tag&&"tagged"===e.type&&"date"===e.tag},exports.isDecimalLiteral=function(e){return!!e.type&&!!e.value&&"decimal"===e.type},exports.isGeospatialLiteral=function(e){return!!e.type&&!!e.value&&!!e.tag&&"tagged"===e.type&&"geo"===e.tag},exports.isGramEdge=x,exports.isGramNode=g,exports.isGramPath=m,exports.isGramPathSequence=_,exports.isGramPathlike=function(e){return y(e)||g(e)||x(e)||m(e)||_(e)},exports.isGramProperty=function(e){return!!e.type&&"property"===e.type},exports.isGramUnit=y,exports.isHexadecimalLiteral=function(e){return!!e.type&&!!e.value&&"hexadecimal"===e.type},exports.isIntegerLiteral=function(e){return!!e.type&&!!e.value&&"integer"===e.type},exports.isLiteral=function(e){return!!e.type&&!!e.value},exports.isMeasurementLiteral=function(e){return!!e.type&&!!e.value&&!!e.unit&&"measurement"===e.type},exports.isOctalLiteral=function(e){return!!e.type&&!!e.value&&"octal"===e.type},exports.isStringLiteral=function(e){return!!e.type&&!!e.value&&"string"===e.type},exports.isTaggedLiteral=function(e){return!!e.type&&!!e.value&&!!e.tag&&"tagged"===e.type},exports.tokens=n; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=(e=require("base-x"))&&"object"==typeof e&&"default"in e?e.default:e,r=/[0-9a-zA-Z_@]+\b@*/,n={__proto__:null,boolean:/true|false|TRUE|FALSE\b(?!@)/,hexadecimal:/-?0x(?:[0-9a-fA-F]+)\b(?!@)/,octal:/-?0(?:[0-7]+)\b(?!@)/,measurement:/-?(?:[0-9]|[1-9][0-9]+)(?:\.[0-9]+)?[a-zA-Z]+\b(?!@)/,decimal:/-?(?:[0-9]|[1-9][0-9]+)\.[0-9]+(?:[eE][-+]?[0-9]+)?\b(?!@)/,integer:/-?(?:[0-9]|[1-9][0-9]+)(?:[eE][-+]?[0-9]+)?\b(?!@)/,taggedString:/[a-zA-Z][0-9a-zA-Z_@]*`(?:\\[`bfnrt/\\]|\\u[a-fA-F0-9]{4}|[^`\\])*`/,doubleQuotedString:/"(?:\\["bfnrt/\\]|\\u[a-fA-F0-9]{4}|[^"\\])*"/,singleQuotedString:/'(?:\\['bfnrt/\\]|\\u[a-fA-F0-9]{4}|[^'\\])*'/,tickedString:/`(?:\\[`bfnrt/\\]|\\u[a-fA-F0-9]{4}|[^`\\])*`/,symbol:/[a-zA-Z_][0-9a-zA-Z_]*\b(?!@)/,identifier:r},a=require("shortid"),i={base2:"01",base8:"01234567",base10:"0123456789",base11:"0123456789a",base16:"0123456789abcdef",base32:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",zBase32:"ybndrfg8ejkmcpqxot1uwisza345h769",crock32:"0123456789ABCDEFGHJKMNPQRSTVWXYZ",base32Hex:"0123456789ABCDEFGHIJKLMNOPQRSTUV",base36:"0123456789abcdefghijklmnopqrstuvwxyz",base58:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ",base62:"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",base64:"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_@"};a.characters(i.base64);var o=new RegExp("^"+r.source+"$"),u=o.test.bind(o),s=function(e){var r=t(i.base10);if(e>Number.MAX_SAFE_INTEGER)throw Error("Value cannot exceed Number.MAX_SAFE_INTEGER.");return r.decode(e.toFixed(0))},p=function(e,r){return"_"+t(e).encode(t(i.base10).decode(r))},c=a.generate,l=function(e){return"_"+e.toString(36)},d=function(e){return"number"===e?function(e){return""+e}:"shortid"===e?function(e){return c()}:"base36"===e?l:function(e){return""}},f=function(e){return void 0===e?"":u(e)?e:e.replace(/[\s.,'"]/gi,"_").replace(/[^_0-9a-zA-Z]/gi,"@")},b={__proto__:null,alphabets:i,isValidIdentifier:u,decodeInteger:s,integerToBase:function(e,r){return t(e).encode(s(r))},integerToBaseID:function(e,r){return"_"+t(e).encode(s(r))},integerLiteralToBaseID:p,shortID:c,base36ID:l,idFunctionNamed:d,idEncoder:f,default:{alphabets:i,isValidIdentifier:u,shortID:c,base36ID:l,idFunctionNamed:d,idEncoder:f,integerLiteralToBaseID:p}},y=function(e){return!!e.type&&"unit"===e.type},g=function(e){return!!e.type&&"node"===e.type},x=function(e){return"type"in e&&"relation"in e&&"edge"===e.type},m=function(e){return!!e.type&&"path"===e.type},_=function(e){return!!e.type&&"seq"===e.type};exports.UNIT_ID="0",exports.identity=b,exports.isBooleanLiteral=function(e){return!!e.type&&!!e.value&&"boolean"===e.type},exports.isDateLiteral=function(e){return!!e.type&&!!e.value&&!!e.tag&&"tagged"===e.type&&"date"===e.tag},exports.isDecimalLiteral=function(e){return!!e.type&&!!e.value&&"decimal"===e.type},exports.isGeospatialLiteral=function(e){return!!e.type&&!!e.value&&!!e.tag&&"tagged"===e.type&&"geo"===e.tag},exports.isGramEdge=x,exports.isGramNode=g,exports.isGramPath=m,exports.isGramPathSequence=_,exports.isGramPathlike=function(e){return y(e)||g(e)||x(e)||m(e)||_(e)},exports.isGramProperty=function(e){return!!e.type&&"property"===e.type},exports.isGramUnit=y,exports.isHexadecimalLiteral=function(e){return!!e.type&&!!e.value&&"hexadecimal"===e.type},exports.isIntegerLiteral=function(e){return!!e.type&&!!e.value&&"integer"===e.type},exports.isLiteral=function(e){return!!e.type&&!!e.value},exports.isMeasurementLiteral=function(e){return!!e.type&&!!e.value&&!!e.unit&&"measurement"===e.type},exports.isOctalLiteral=function(e){return!!e.type&&!!e.value&&"octal"===e.type},exports.isStringLiteral=function(e){return!!e.type&&!!e.value&&"string"===e.type},exports.isTaggedLiteral=function(e){return!!e.type&&!!e.value&&!!e.tag&&"tagged"===e.type},exports.tokens=n; | ||
//# sourceMappingURL=gram-ast.cjs.production.min.js.map |
@@ -205,3 +205,3 @@ import baseX from 'base-x'; | ||
var isGramEdge = function isGramEdge(o) { | ||
return 'type' in o && 'direction' in o && o.type === 'edge'; | ||
return 'type' in o && 'relation' in o && o.type === 'edge'; | ||
}; | ||
@@ -208,0 +208,0 @@ /** |
@@ -20,4 +20,4 @@ /** | ||
* The ast is a tree of GramNodes and GramEdges. | ||
* The direction of a Path is always left to right | ||
* regardless of the internal directions of any | ||
* The relation of a Path is always left to right | ||
* regardless of the internal relations of any | ||
* contained Edges. | ||
@@ -36,3 +36,3 @@ * The leftmost syntactic Node is the head, which | ||
*/ | ||
export interface GramPathlikeBase extends UnistParent { | ||
export interface GramPathlikeAttributes extends UnistParent { | ||
/** | ||
@@ -74,3 +74,3 @@ * A type-scoped unique identifier. | ||
*/ | ||
export interface GramUnit extends GramPathlikeBase { | ||
export interface GramUnit extends GramPathlikeAttributes { | ||
/** | ||
@@ -104,3 +104,3 @@ * Type discriminator for this AST element, always 'unit'. | ||
*/ | ||
export interface GramNode extends GramPathlikeBase { | ||
export interface GramNode extends GramPathlikeAttributes { | ||
/** | ||
@@ -122,3 +122,6 @@ * Type discriminator for this AST element, always 'node'. | ||
/** | ||
* RelationshipOperator composes path expressions. | ||
* Navigable relations to compose path expressions. | ||
* Gram includes one extra relation that is not | ||
* navigable, the ',' pair relation used only in | ||
* path composition and not allowed in Edge definition. | ||
* | ||
@@ -132,3 +135,4 @@ * One of: | ||
*/ | ||
export declare type RelationshipOperator = 'left' | 'right' | 'either' | 'pair'; | ||
export declare type Navigation = 'left' | 'right' | 'either'; | ||
export declare type Relation = Navigation | 'pair'; | ||
/** | ||
@@ -143,3 +147,3 @@ * GramEdge is: | ||
*/ | ||
export interface GramEdge extends GramPathlikeBase { | ||
export interface GramEdge extends GramPathlikeAttributes { | ||
/** | ||
@@ -150,7 +154,8 @@ * Type discriminator for this AST element, always 'edge'. | ||
/** | ||
* The direction within a path. | ||
* A missing direction is assumed to be 'either'. | ||
* The relationship between the nodes. | ||
*/ | ||
direction?: RelationshipOperator; | ||
relation?: Navigation; | ||
/** | ||
* The operands of the Edge, known as "children" in the AST. | ||
* | ||
* children[0] is the 'left' child | ||
@@ -181,3 +186,3 @@ * children[1] is the 'right' child | ||
*/ | ||
export interface GramPath extends GramPathlikeBase { | ||
export interface GramPath extends GramPathlikeAttributes { | ||
/** | ||
@@ -191,3 +196,3 @@ * Type discriminator for this AST element, always 'path'. | ||
*/ | ||
direction?: RelationshipOperator | 'pair'; | ||
relation?: Relation; | ||
/** | ||
@@ -210,3 +215,3 @@ * Either a single child that is nested within this path, | ||
*/ | ||
export interface GramPathSeq extends GramPathlikeBase { | ||
export interface GramPathSeq extends GramPathlikeAttributes { | ||
/** | ||
@@ -213,0 +218,0 @@ * Type discriminator for this AST element, aways 'seq'. |
{ | ||
"name": "@gram-data/gram-ast", | ||
"version": "0.1.7", | ||
"version": "0.1.8", | ||
"license": "MIT", | ||
@@ -51,3 +51,3 @@ "main": "dist/index.js", | ||
}, | ||
"gitHead": "465acfabcb817c9806d048c47f29afa65107899c", | ||
"gitHead": "767922021318156135c4fc0e755bdaa888f7a057", | ||
"publishConfig": { | ||
@@ -54,0 +54,0 @@ "access": "public" |
@@ -28,4 +28,4 @@ /** | ||
* The ast is a tree of GramNodes and GramEdges. | ||
* The direction of a Path is always left to right | ||
* regardless of the internal directions of any | ||
* The relation of a Path is always left to right | ||
* regardless of the internal relations of any | ||
* contained Edges. | ||
@@ -48,3 +48,3 @@ * The leftmost syntactic Node is the head, which | ||
*/ | ||
export interface GramPathlikeBase extends UnistParent { | ||
export interface GramPathlikeAttributes extends UnistParent { | ||
/** | ||
@@ -94,3 +94,3 @@ * A type-scoped unique identifier. | ||
*/ | ||
export interface GramUnit extends GramPathlikeBase { | ||
export interface GramUnit extends GramPathlikeAttributes { | ||
/** | ||
@@ -131,3 +131,3 @@ * Type discriminator for this AST element, always 'unit'. | ||
*/ | ||
export interface GramNode extends GramPathlikeBase { | ||
export interface GramNode extends GramPathlikeAttributes { | ||
/** | ||
@@ -153,3 +153,6 @@ * Type discriminator for this AST element, always 'node'. | ||
/** | ||
* RelationshipOperator composes path expressions. | ||
* Navigable relations to compose path expressions. | ||
* Gram includes one extra relation that is not | ||
* navigable, the ',' pair relation used only in | ||
* path composition and not allowed in Edge definition. | ||
* | ||
@@ -163,4 +166,6 @@ * One of: | ||
*/ | ||
export type RelationshipOperator = 'left' | 'right' | 'either' | 'pair'; | ||
export type Navigation = 'left' | 'right' | 'either'; | ||
export type Relation = Navigation | 'pair'; | ||
/** | ||
@@ -175,3 +180,3 @@ * GramEdge is: | ||
*/ | ||
export interface GramEdge extends GramPathlikeBase { | ||
export interface GramEdge extends GramPathlikeAttributes { | ||
/** | ||
@@ -183,8 +188,9 @@ * Type discriminator for this AST element, always 'edge'. | ||
/** | ||
* The direction within a path. | ||
* A missing direction is assumed to be 'either'. | ||
* The relationship between the nodes. | ||
*/ | ||
direction?: RelationshipOperator; | ||
relation?: Navigation; | ||
/** | ||
* The operands of the Edge, known as "children" in the AST. | ||
* | ||
* children[0] is the 'left' child | ||
@@ -202,3 +208,3 @@ * children[1] is the 'right' child | ||
export const isGramEdge = (o: any): o is GramEdge => | ||
'type' in o && 'direction' in o && o.type === 'edge'; | ||
'type' in o && 'relation' in o && o.type === 'edge'; | ||
@@ -219,3 +225,3 @@ /** | ||
*/ | ||
export interface GramPath extends GramPathlikeBase { | ||
export interface GramPath extends GramPathlikeAttributes { | ||
/** | ||
@@ -230,3 +236,3 @@ * Type discriminator for this AST element, always 'path'. | ||
*/ | ||
direction?: RelationshipOperator | 'pair'; | ||
relation?: Relation; | ||
@@ -253,3 +259,3 @@ /** | ||
*/ | ||
export interface GramPathSeq extends GramPathlikeBase { | ||
export interface GramPathSeq extends GramPathlikeAttributes { | ||
/** | ||
@@ -256,0 +262,0 @@ * Type discriminator for this AST element, aways 'seq'. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
122982
1728