Skip to content

Commit 64cb21d

Browse files
author
Leif Shackelford
committed
dot => semantic divider
1 parent e2d5901 commit 64cb21d

File tree

11 files changed

+59
-23
lines changed

11 files changed

+59
-23
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "js-moss",
33
"description": "moss is a set of parsing rules for yaml and json",
4-
"version": "0.22.30",
4+
"version": "0.22.31",
55
"homepage": "https://github.com/1e1f/js-moss",
66
"author": {
77
"name": "Leif Shackelford",

src/async.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ export const parseObject = async (current: Moss.ReturnValue) => {
193193
if (readKey[0] === "$") {
194194
try {
195195
writeKey = <any>(await interpolate(current, readKey)).data;
196-
} catch (e) {}
196+
} catch (e) { }
197197
} else if (readKey[0] == "\\") {
198198
writeKey = readKey.slice(1);
199199
} else {
@@ -770,9 +770,8 @@ async function _interpolate(
770770
}
771771
if (!(resolvedBranches && resolvedBranches.length)) {
772772
throw {
773-
message: `No async results for ${bl}, in ${
774-
Object.keys(resolvers).length
775-
} resolvers @ ${toYaml(layer.data)}`,
773+
message: `No async results for ${bl}, in ${Object.keys(resolvers).length
774+
} resolvers @ ${toYaml(layer.data)}`,
776775
};
777776
}
778777
const parsedBranches = [];

src/branch/canonical.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@ import { Moss } from "../types";
22
import { decode, encode } from "./parser";
33

44
export const canonicalBl = (bl: string | Moss.Branch) => {
5-
if (typeof bl == "string") {
6-
return encode(decode(bl));
5+
try {
6+
if (typeof bl == "string") {
7+
return encode(decode(bl));
8+
}
9+
return encode(canonicalBranchLocator(bl));
10+
} catch (e) {
11+
console.error("canonicalBl bl failed for input", bl)
712
}
8-
return encode(canonicalBranchLocator(bl));
913
};
1014

1115
export const disambiguatedHash = (org: string) => {

src/branch/indexer.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ const blIndexer: IndexProducer<BLIndex> = {
112112
keyPath: "deps",
113113
};
114114

115+
116+
117+
115118
const branchIndexer = [blIndexer];
116119

117120
const indexAny = (
@@ -227,13 +230,20 @@ export const createBranchIndex = (
227230
// console.log("createdKindIndex", kind.n);
228231
const bi: SearchIndex = {};
229232
indexAny(ast, branchIndexer, bi, hashFunctions);
233+
if (ast.data?.market) {
234+
bi.m = ast.data?.market;
235+
}
230236
return {
231237
...bi,
232238
bl,
233239
kind,
234240
};
235241
};
236242

243+
export const marketIndex = {
244+
market: "s.m"
245+
};
246+
237247
export const indexPaths = {
238248
organization: "s.bl.o",
239249
name: "s.bl.n",

src/branch/parser/compiled/hydrate.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ const grammar: Grammar = {
199199
{"name": "disambiguatedChunk", "symbols": ["disambiguatedChunk", "_", "nonSemanticDivider"], "postprocess": join},
200200
{"name": "disambiguatedChunk", "symbols": ["disambiguatedString"], "postprocess": id},
201201
{"name": "gap", "symbols": ["__"], "postprocess": () => " "},
202-
{"name": "semanticDivider", "symbols": [/[/]/], "postprocess": token},
203-
{"name": "nonSemanticDivider", "symbols": [/[-'.&_]/], "postprocess": token},
202+
{"name": "semanticDivider", "symbols": [/[./]/], "postprocess": token},
203+
{"name": "nonSemanticDivider", "symbols": [/[-&#'_()+]/], "postprocess": token},
204204
{"name": "disambiguatedString$ebnf$1", "symbols": ["disambiguatedChar"]},
205205
{"name": "disambiguatedString$ebnf$1", "symbols": ["disambiguatedString$ebnf$1", "disambiguatedChar"], "postprocess": (d) => d[0].concat([d[1]])},
206206
{"name": "disambiguatedString", "symbols": ["disambiguatedString$ebnf$1"], "postprocess": stringOfSame},

src/branch/parser/grammars/hydrate.ne

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,10 @@ gap
179179
-> __ {% () => " " %}
180180

181181
semanticDivider
182-
-> [/] {% token %}
182+
-> [./] {% token %}
183183

184184
nonSemanticDivider
185-
-> [-'.&_] {% token %}
185+
-> [-&#'_()+] {% token %}
186186

187187
disambiguatedString
188188
-> disambiguatedChar:+ {% stringOfSame %}

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ export { Async, Sync };
1010

1111
import "./moreFunctions";
1212

13-
export type { Moss, importPrefix, queryPrefix } from "./types";
13+
export { Moss, importPrefix, queryPrefix } from "./types";

src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export interface BLIndex {
2424

2525
export interface SearchIndex extends BLIndex {
2626
kind?: BLIndex;
27+
m?: string;
2728
deps?: BLIndex[];
2829
bl?: BLIndex;
2930
}

src/yaml/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const toYaml = (obj: any, options?: any): string => {
1111

1212
export const fromYaml = (yaml: string, options?: any): any => {
1313
if (!yaml) {
14-
console.warn("loading empty yaml string");
14+
console.debug("loading empty yaml string");
1515
return {};
1616
}
1717
return load(yaml, options);

test/branchLocator.test.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,16 @@ const shouldPass = [
7777
organizationSegment: 'has-hyphen',
7878
}
7979
},
80-
{
81-
informalBl: 'This name is a sentence.@Org~Prj',
82-
canonicalBl: 'thisnameisasentence@org~prj',
83-
branch: {
84-
nameSegment: 'This name is a sentence.',
85-
projectSegment: 'Prj',
86-
organizationSegment: 'Org',
87-
}
88-
},
80+
// This is no longer allowed (ending with dot)
81+
// {
82+
// informalBl: 'This name is a sentence.@Org~Prj',
83+
// canonicalBl: 'thisnameisasentence.@org~prj',
84+
// branch: {
85+
// nameSegment: 'This name is a sentence.',
86+
// projectSegment: 'Prj',
87+
// organizationSegment: 'Org',
88+
// }
89+
// },
8990
{
9091
informalBl: 'main@QA~test',
9192
canonicalBl: 'main@qa~test',

0 commit comments

Comments
 (0)