Skip to content

Commit ac2ad92

Browse files
committed
moved some files
1 parent fdef6b2 commit ac2ad92

25 files changed

+105
-235
lines changed

exampleVault/Test.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,9 @@ await dv.paragraph(`${filter}${backticks}${codeblock}${backticks}`);
4949

5050

5151
```meta-bind-parser-test
52+
declarationValidationGraph
53+
```
54+
55+
```meta-bind-parser-test
56+
argumentsValidationGraph
5257
```

exampleVault/examples.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
slider1: 5
2+
slider1: 6
33
suggest: test
44
toggle1: false
55
Domestic_tasks:
@@ -69,8 +69,9 @@ Lorem ipsum dolor sit amet, `INPUT[date():other note#date]` consectetur adipisci
6969
- `INPUT[text():meta bind/nonExistantFile#title]`
7070
- `INPUT[slider(nonExistantArgument)]`
7171
- `INPUT[slider]`
72-
7372
- `INPUT[inlineSelect(option(option a),option(option b),option(option c),option(option d):select]`
73+
- `INPUT[inlineSelect(option(option a),option(option b),option(option c),option(option d)):select#]`
74+
- `INPUT[inlineSelect(option(option a),option(option b),option(option c),option(option d)):select#:]`
7475

7576

7677
Lorem ipsum dolor sit amet, `INPUT[text():meta bind/nonExistantFile#title]` consectetur adipiscing elit. Pellentesque sit amet porttitor arcu. Quisque scelerisque dolor augue, et posuere nulla bibendum nec. `INPUT[slider(nonExistantArgument)]` Curabitur sed rhoncus nisl. Maecenas nisi justo, viverra vel tempus vel, hendrerit at metus. `INPUT[select(option(option a),option(option b),option(option c),option(option d)):select]` asdasd asdasdasd

src/api/InputFieldAPI.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import { InputFieldArgumentType, InputFieldType } from '../parsers/InputFieldDeclarationParser';
22
import { ErrorCollection } from '../utils/errors/ErrorCollection';
33
import { API } from './API';
4-
import { useSyncExternalStore } from 'preact/compat';
5-
import { UnvalidatedInputFieldDeclaration } from '../parsers/newInputFieldParser/InputFieldDeclarationValidator';
6-
import { StructureParserResult } from '../parsers/newInputFieldParser/StructureParser';
4+
import { InputFieldStructureParserResult, UnvalidatedInputFieldDeclaration } from '../parsers/newInputFieldParser/InputFieldDeclarationValidator';
75

86
export class InputFieldAPI {
97
private readonly api: API;
@@ -107,7 +105,7 @@ export class InputFieldAPI {
107105
arr.push(currentValue);
108106
}
109107
return arr;
110-
}, [] as { name: StructureParserResult; value?: StructureParserResult | undefined }[]),
108+
}, [] as { name: InputFieldStructureParserResult; value?: InputFieldStructureParserResult | undefined }[]),
111109
errorCollection: unvalidatedDeclaration.errorCollection.merge(override.errorCollection),
112110
};
113111
}

src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export default class MetaBindPlugin extends Plugin implements IPlugin {
9090
});
9191

9292
this.registerMarkdownCodeBlockProcessor('meta-bind-parser-test', (source, el, ctx) => {
93-
ctx.addChild(new ParserTestMDRC(el, RenderChildType.BLOCK, this, ctx.sourcePath, self.crypto.randomUUID(), {}));
93+
ctx.addChild(new ParserTestMDRC(el, RenderChildType.BLOCK, source, this, ctx.sourcePath, self.crypto.randomUUID(), {}));
9494
});
9595

9696
// this.registerMarkdownCodeBlockProcessor('meta-bind-js', (source, el, ctx) => {

src/parsers/newInputFieldParser/ParsingTree.ts renamed to src/parsers/generalParser/ParsingTree.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { ParsingError } from './ParsingError';
22
import { ErrorLevel } from '../../utils/errors/MetaBindErrors';
33
import { AbstractToken, Range } from './ParsingUtils';
4-
import { InputFieldTokenType } from './InputFieldTokenizer';
54

65
export enum PT_Element_Type {
76
LITERAL = 'LITERAL',
@@ -35,7 +34,7 @@ export abstract class Abstract_PT_Node<TokenType extends string, Token extends A
3534
this.children = children;
3635
}
3736

38-
getChild(index: number, expected?: InputFieldTokenType | undefined): PT_Element<TokenType, Token> {
37+
getChild(index: number, expected?: TokenType | undefined): PT_Element<TokenType, Token> {
3938
const el = this.children[index];
4039
if (!el) {
4140
throw new Error('This parser sucks');

src/parsers/newInputFieldParser/ParsingTreeParser.ts renamed to src/parsers/generalParser/ParsingTreeParser.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import { ParsingError } from './ParsingError';
22
import { ErrorLevel } from '../../utils/errors/MetaBindErrors';
33
import { ParsingTree, PT_Closure, PT_Element, PT_Element_Type, PT_Literal } from './ParsingTree';
4-
import { AbstractToken, Closure } from './ParsingUtils';
5-
import { InputFieldClosures, InputFieldToken, InputFieldTokenType } from './InputFieldTokenizer';
6-
import { EOF_TOKEN } from './validationGraph/ValidationGraph';
4+
import { AbstractToken, Closure, EOF_TOKEN } from './ParsingUtils';
75

86
export class ParsingTreeParser<TokenType extends string, Token extends AbstractToken<TokenType>> {
97
private readonly tokens: Token[];
@@ -66,7 +64,7 @@ export class ParsingTreeParser<TokenType extends string, Token extends AbstractT
6664
// skip the opening token
6765
this.position += 1;
6866

69-
while (this.getCurrentToken().type !== InputFieldTokenType.EOF) {
67+
while (this.getCurrentToken().type !== EOF_TOKEN) {
7068
const nestedRes = this.parseCurrentToken();
7169

7270
if (nestedRes.type === PT_Element_Type.LITERAL && (nestedRes as PT_Literal<TokenType, Token>).token.type === closure.closingTokenType) {
@@ -104,7 +102,7 @@ export class ParsingTreeParser<TokenType extends string, Token extends AbstractT
104102
// check for closure closing tokens that do not actually close a closure
105103
const currentClosure = this.closureStack.length > 0 ? this.closureStack[this.closureStack.length - 1] : undefined;
106104

107-
for (const closure of InputFieldClosures) {
105+
for (const closure of this.closures) {
108106
// if the closure is the current token
109107
if (
110108
currentClosure !== undefined &&

src/parsers/newInputFieldParser/ParsingUtils.ts renamed to src/parsers/generalParser/ParsingUtils.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,16 @@ export interface Range {
1313
from: number;
1414
to: number;
1515
}
16+
17+
export function createToken<TokenType extends string>(type: TokenType, literal: string, from: number, to: number): AbstractToken<TokenType> {
18+
return {
19+
type: type,
20+
literal: literal,
21+
range: {
22+
from: from,
23+
to: to,
24+
},
25+
};
26+
}
27+
28+
export const EOF_TOKEN = '__EOF__' as const;

0 commit comments

Comments
 (0)