Skip to content

Commit 9ab1354

Browse files
author
Jay Patel
committed
Implement workaround for URI parsing
1 parent 6cb88fe commit 9ab1354

File tree

6 files changed

+55
-4
lines changed

6 files changed

+55
-4
lines changed

grammar.abnf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ infixAssertion = attributePath SP infixAssertionOperator SP infixAssertionValue
2020
infixAssertionOperator = "eq" / "ne" / "co" / "sw" / "ew" / "gt" / "lt" / "ge" / "le"
2121
infixAssertionValue = null / true / false / number / string
2222

23+
<<<<<<< Updated upstream
2324
attributePath = [URI ":"] attributePathSegment *("." attributePathSegment)
25+
=======
26+
attributePath = [URI "<"] attributePathSegment *1("." attributePathSegment)
27+
>>>>>>> Stashed changes
2428
attributePathSegment = ALPHA *("-" / "_" / DIGIT / ALPHA)
2529

2630
; rfc7159

grammar.js

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Yard.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class TrackMap {
2424
infixAssertionValue = [] as (null | boolean | number | string)[];
2525
attributePath = [] as string[][];
2626
attributePathSegment = [] as string[];
27+
uri = [] as string[];
2728
}
2829

2930
class Stat {
@@ -43,6 +44,7 @@ class Stat {
4344
infixAssertionValue = 0 as number;
4445
attributePath = 0 as number;
4546
attributePathSegment = 0 as number;
47+
uri = 0 as number;
4648
}
4749

4850
class StatsMap {
@@ -62,6 +64,7 @@ class StatsMap {
6264
infixAssertionValue = [] as Stat[];
6365
attributePath = [] as Stat[];
6466
attributePathSegment = [] as Stat[];
67+
uri = [] as Stat[];
6568
}
6669

6770
export class Yard {

src/attributePath.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,17 @@ export function attributePath(
1414
break;
1515

1616
case ids.SEM_POST:
17-
const { attributePathSegment } = yard.post("attributePath");
17+
const { attributePathSegment, uri } = yard.post("attributePath");
1818

1919
if (attributePathSegment.length < 1) {
2020
throw new Error(
2121
`INVARIANT: Expected 1 or more attributePathSegment, but got ${attributePathSegment.length};`
2222
);
2323
}
24-
25-
yard.tracks.attributePath.push(attributePathSegment.reverse());
24+
yard.tracks.attributePath.push([
25+
...uri,
26+
...attributePathSegment.reverse()
27+
]);
2628
break;
2729
}
2830

src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { infixAssertionOperator } from "./infixAssertionOperator";
1919
import { infixAssertionValue } from "./infixAssertionValue";
2020
import { attributePath } from "./attributePath";
2121
import { attributePathSegment } from "./attributePathSegment";
22+
import { uri } from "./uri";
2223

2324
const grammar = new Grammar();
2425
const parser = new Parser();
@@ -39,7 +40,8 @@ parser.ast.callbacks = {
3940
infixAssertionOperator,
4041
infixAssertionValue,
4142
attributePath,
42-
attributePathSegment
43+
attributePathSegment,
44+
uri
4345
};
4446

4547
export function compileFilter(input: string): (data: any) => boolean {

src/uri.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { ids, utils } from "apg-lib";
2+
import { Yard } from "./Yard";
3+
4+
export function uri(
5+
state: typeof ids.SEM_PRE | typeof ids.SEM_POST,
6+
chars: number[],
7+
phraseIndex: number,
8+
phraseLength: number,
9+
yard: Yard
10+
): typeof ids.SEM_OK | typeof ids.SEM_SKIP {
11+
switch (state) {
12+
case ids.SEM_PRE:
13+
break;
14+
15+
case ids.SEM_POST:
16+
yard.tracks.uri.push(
17+
utils.charsToString(chars, phraseIndex, phraseLength)
18+
);
19+
break;
20+
}
21+
22+
return ids.SEM_OK;
23+
}

0 commit comments

Comments
 (0)