tagset-parser 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,64 @@
1
+ import { AbstractParseTreeVisitor } from "antlr4ng";
2
+ /**
3
+ * This interface defines a complete generic visitor for a parse tree produced
4
+ * by `TagSetParser`.
5
+ *
6
+ * @param <Result> The return type of the visit operation. Use `void` for
7
+ * operations with no return type.
8
+ */
9
+ export class TagSetVisitor extends AbstractParseTreeVisitor {
10
+ /**
11
+ * Visit a parse tree produced by `TagSetParser.program`.
12
+ * @param ctx the parse tree
13
+ * @return the visitor result
14
+ */
15
+ visitProgram;
16
+ /**
17
+ * Visit a parse tree produced by `TagSetParser.line`.
18
+ * @param ctx the parse tree
19
+ * @return the visitor result
20
+ */
21
+ visitLine;
22
+ /**
23
+ * Visit a parse tree produced by `TagSetParser.setDecl`.
24
+ * @param ctx the parse tree
25
+ * @return the visitor result
26
+ */
27
+ visitSetDecl;
28
+ /**
29
+ * Visit a parse tree produced by `TagSetParser.labelPart`.
30
+ * @param ctx the parse tree
31
+ * @return the visitor result
32
+ */
33
+ visitLabelPart;
34
+ /**
35
+ * Visit a parse tree produced by `TagSetParser.itemDecl`.
36
+ * @param ctx the parse tree
37
+ * @return the visitor result
38
+ */
39
+ visitItemDecl;
40
+ /**
41
+ * Visit a parse tree produced by `TagSetParser.sugarDecl`.
42
+ * @param ctx the parse tree
43
+ * @return the visitor result
44
+ */
45
+ visitSugarDecl;
46
+ /**
47
+ * Visit a parse tree produced by `TagSetParser.pattern`.
48
+ * @param ctx the parse tree
49
+ * @return the visitor result
50
+ */
51
+ visitPattern;
52
+ /**
53
+ * Visit a parse tree produced by `TagSetParser.valueList`.
54
+ * @param ctx the parse tree
55
+ * @return the visitor result
56
+ */
57
+ visitValueList;
58
+ /**
59
+ * Visit a parse tree produced by `TagSetParser.valueItem`.
60
+ * @param ctx the parse tree
61
+ * @return the visitor result
62
+ */
63
+ visitValueItem;
64
+ }
@@ -0,0 +1 @@
1
+ export { parse } from './parser.js';
@@ -0,0 +1,14 @@
1
+ import { CharStream, CommonTokenStream } from 'antlr4ng';
2
+ import { TagSetLexer } from './generated/TagSetLexer.js';
3
+ import { TagSetParser } from './generated/TagSetParser.js';
4
+ import { TagSetASTVisitor } from './visitor.js';
5
+ export function parse(input) {
6
+ const chars = CharStream.fromString(input);
7
+ const lexer = new TagSetLexer(chars);
8
+ const tokens = new CommonTokenStream(lexer);
9
+ const parser = new TagSetParser(tokens);
10
+ const tree = parser.program();
11
+ const visitor = new TagSetASTVisitor();
12
+ tree.accept(visitor);
13
+ return visitor.buildAST();
14
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,81 @@
1
+ import { TagSetVisitor } from './generated/TagSetVisitor.js';
2
+ import { calcBitmask } from './bitmask.js';
3
+ function extractPatternIds(ctx) {
4
+ return ctx
5
+ .WORD()
6
+ .map((w) => w.getText())
7
+ .filter((t) => t !== '_');
8
+ }
9
+ function extractValues(ctx) {
10
+ return ctx.valueItem().map((vi) => {
11
+ const parts = [
12
+ ...vi.WORD().map((w) => w.getText()),
13
+ ...vi.QUOTED_STRING().map((q) => {
14
+ const text = q.getText();
15
+ return text.startsWith('"') && text.endsWith('"')
16
+ ? text.slice(1, -1)
17
+ : text;
18
+ }),
19
+ ];
20
+ return parts.join(' ');
21
+ });
22
+ }
23
+ function autoDetectSets(explicitSets, rawItems) {
24
+ const explicitIds = new Set(explicitSets.map((s) => s.id));
25
+ const discovered = [];
26
+ for (const item of rawItems) {
27
+ for (const id of item.patternIds) {
28
+ if (!explicitIds.has(id) && !discovered.includes(id)) {
29
+ discovered.push(id);
30
+ }
31
+ }
32
+ }
33
+ let nextIndex = explicitSets.length;
34
+ const autoSets = discovered.map((id) => ({
35
+ id,
36
+ label: id,
37
+ index: nextIndex++,
38
+ }));
39
+ return [...explicitSets, ...autoSets];
40
+ }
41
+ export class TagSetASTVisitor extends TagSetVisitor {
42
+ explicitSets = [];
43
+ rawItems = [];
44
+ setIndex = 0;
45
+ visitProgram = (ctx) => {
46
+ for (const line of ctx.line()) {
47
+ line.accept(this);
48
+ }
49
+ };
50
+ visitSetDecl = (ctx) => {
51
+ const id = ctx.WORD().getText();
52
+ const label = ctx
53
+ .labelPart()
54
+ .map((lp) => lp.getText())
55
+ .join(' ');
56
+ this.explicitSets.push({ id, label, index: this.setIndex++ });
57
+ };
58
+ visitItemDecl = (ctx) => {
59
+ const patternCtx = ctx.pattern();
60
+ const patternIds = extractPatternIds(patternCtx);
61
+ const values = extractValues(ctx.valueList());
62
+ this.rawItems.push({ patternIds, values });
63
+ };
64
+ visitSugarDecl = (ctx) => {
65
+ const patternIds = ctx
66
+ .WORD()
67
+ .map((w) => w.getText())
68
+ .filter((t) => t !== '_');
69
+ const values = extractValues(ctx.valueList());
70
+ this.rawItems.push({ patternIds, values });
71
+ };
72
+ buildAST() {
73
+ const sets = autoDetectSets(this.explicitSets, this.rawItems);
74
+ const items = this.rawItems.map((raw) => {
75
+ const pattern = raw.patternIds.join('&');
76
+ const bitmask = calcBitmask(pattern, sets);
77
+ return { pattern, bitmask, values: raw.values };
78
+ });
79
+ return { sets, items };
80
+ }
81
+ }
@@ -0,0 +1,2 @@
1
+ import type { SetDecl } from './types.js';
2
+ export declare function calcBitmask(pattern: string, sets: SetDecl[]): number;
@@ -0,0 +1,31 @@
1
+ import * as antlr from "antlr4ng";
2
+ export declare class TagSetLexer extends antlr.Lexer {
3
+ static readonly SET = 1;
4
+ static readonly ITEM = 2;
5
+ static readonly AMP = 3;
6
+ static readonly COMMA = 4;
7
+ static readonly COLON = 5;
8
+ static readonly QUOTED_STRING = 6;
9
+ static readonly WORD = 7;
10
+ static readonly NL = 8;
11
+ static readonly WS = 9;
12
+ static readonly channelNames: string[];
13
+ static readonly literalNames: (string | null)[];
14
+ static readonly symbolicNames: (string | null)[];
15
+ static readonly modeNames: string[];
16
+ static readonly ruleNames: string[];
17
+ constructor(input: antlr.CharStream);
18
+ get grammarFileName(): string;
19
+ get literalNames(): (string | null)[];
20
+ get symbolicNames(): (string | null)[];
21
+ get ruleNames(): string[];
22
+ get serializedATN(): number[];
23
+ get channelNames(): string[];
24
+ get modeNames(): string[];
25
+ static readonly _serializedATN: number[];
26
+ private static __ATN;
27
+ static get _ATN(): antlr.ATN;
28
+ private static readonly vocabulary;
29
+ get vocabulary(): antlr.Vocabulary;
30
+ private static readonly decisionsToDFA;
31
+ }
@@ -0,0 +1,110 @@
1
+ import { ErrorNode, ParseTreeListener, ParserRuleContext, TerminalNode } from "antlr4ng";
2
+ import { ProgramContext } from "./TagSetParser.js";
3
+ import { LineContext } from "./TagSetParser.js";
4
+ import { SetDeclContext } from "./TagSetParser.js";
5
+ import { LabelPartContext } from "./TagSetParser.js";
6
+ import { ItemDeclContext } from "./TagSetParser.js";
7
+ import { SugarDeclContext } from "./TagSetParser.js";
8
+ import { PatternContext } from "./TagSetParser.js";
9
+ import { ValueListContext } from "./TagSetParser.js";
10
+ import { ValueItemContext } from "./TagSetParser.js";
11
+ /**
12
+ * This interface defines a complete listener for a parse tree produced by
13
+ * `TagSetParser`.
14
+ */
15
+ export declare class TagSetListener implements ParseTreeListener {
16
+ /**
17
+ * Enter a parse tree produced by `TagSetParser.program`.
18
+ * @param ctx the parse tree
19
+ */
20
+ enterProgram?: (ctx: ProgramContext) => void;
21
+ /**
22
+ * Exit a parse tree produced by `TagSetParser.program`.
23
+ * @param ctx the parse tree
24
+ */
25
+ exitProgram?: (ctx: ProgramContext) => void;
26
+ /**
27
+ * Enter a parse tree produced by `TagSetParser.line`.
28
+ * @param ctx the parse tree
29
+ */
30
+ enterLine?: (ctx: LineContext) => void;
31
+ /**
32
+ * Exit a parse tree produced by `TagSetParser.line`.
33
+ * @param ctx the parse tree
34
+ */
35
+ exitLine?: (ctx: LineContext) => void;
36
+ /**
37
+ * Enter a parse tree produced by `TagSetParser.setDecl`.
38
+ * @param ctx the parse tree
39
+ */
40
+ enterSetDecl?: (ctx: SetDeclContext) => void;
41
+ /**
42
+ * Exit a parse tree produced by `TagSetParser.setDecl`.
43
+ * @param ctx the parse tree
44
+ */
45
+ exitSetDecl?: (ctx: SetDeclContext) => void;
46
+ /**
47
+ * Enter a parse tree produced by `TagSetParser.labelPart`.
48
+ * @param ctx the parse tree
49
+ */
50
+ enterLabelPart?: (ctx: LabelPartContext) => void;
51
+ /**
52
+ * Exit a parse tree produced by `TagSetParser.labelPart`.
53
+ * @param ctx the parse tree
54
+ */
55
+ exitLabelPart?: (ctx: LabelPartContext) => void;
56
+ /**
57
+ * Enter a parse tree produced by `TagSetParser.itemDecl`.
58
+ * @param ctx the parse tree
59
+ */
60
+ enterItemDecl?: (ctx: ItemDeclContext) => void;
61
+ /**
62
+ * Exit a parse tree produced by `TagSetParser.itemDecl`.
63
+ * @param ctx the parse tree
64
+ */
65
+ exitItemDecl?: (ctx: ItemDeclContext) => void;
66
+ /**
67
+ * Enter a parse tree produced by `TagSetParser.sugarDecl`.
68
+ * @param ctx the parse tree
69
+ */
70
+ enterSugarDecl?: (ctx: SugarDeclContext) => void;
71
+ /**
72
+ * Exit a parse tree produced by `TagSetParser.sugarDecl`.
73
+ * @param ctx the parse tree
74
+ */
75
+ exitSugarDecl?: (ctx: SugarDeclContext) => void;
76
+ /**
77
+ * Enter a parse tree produced by `TagSetParser.pattern`.
78
+ * @param ctx the parse tree
79
+ */
80
+ enterPattern?: (ctx: PatternContext) => void;
81
+ /**
82
+ * Exit a parse tree produced by `TagSetParser.pattern`.
83
+ * @param ctx the parse tree
84
+ */
85
+ exitPattern?: (ctx: PatternContext) => void;
86
+ /**
87
+ * Enter a parse tree produced by `TagSetParser.valueList`.
88
+ * @param ctx the parse tree
89
+ */
90
+ enterValueList?: (ctx: ValueListContext) => void;
91
+ /**
92
+ * Exit a parse tree produced by `TagSetParser.valueList`.
93
+ * @param ctx the parse tree
94
+ */
95
+ exitValueList?: (ctx: ValueListContext) => void;
96
+ /**
97
+ * Enter a parse tree produced by `TagSetParser.valueItem`.
98
+ * @param ctx the parse tree
99
+ */
100
+ enterValueItem?: (ctx: ValueItemContext) => void;
101
+ /**
102
+ * Exit a parse tree produced by `TagSetParser.valueItem`.
103
+ * @param ctx the parse tree
104
+ */
105
+ exitValueItem?: (ctx: ValueItemContext) => void;
106
+ visitTerminal(node: TerminalNode): void;
107
+ visitErrorNode(node: ErrorNode): void;
108
+ enterEveryRule(node: ParserRuleContext): void;
109
+ exitEveryRule(node: ParserRuleContext): void;
110
+ }
@@ -0,0 +1,147 @@
1
+ import * as antlr from "antlr4ng";
2
+ import { TagSetListener } from "./TagSetListener.js";
3
+ import { TagSetVisitor } from "./TagSetVisitor.js";
4
+ export declare class TagSetParser extends antlr.Parser {
5
+ static readonly SET = 1;
6
+ static readonly ITEM = 2;
7
+ static readonly AMP = 3;
8
+ static readonly COMMA = 4;
9
+ static readonly COLON = 5;
10
+ static readonly QUOTED_STRING = 6;
11
+ static readonly WORD = 7;
12
+ static readonly NL = 8;
13
+ static readonly WS = 9;
14
+ static readonly RULE_program = 0;
15
+ static readonly RULE_line = 1;
16
+ static readonly RULE_setDecl = 2;
17
+ static readonly RULE_labelPart = 3;
18
+ static readonly RULE_itemDecl = 4;
19
+ static readonly RULE_sugarDecl = 5;
20
+ static readonly RULE_pattern = 6;
21
+ static readonly RULE_valueList = 7;
22
+ static readonly RULE_valueItem = 8;
23
+ static readonly literalNames: (string | null)[];
24
+ static readonly symbolicNames: (string | null)[];
25
+ static readonly ruleNames: string[];
26
+ get grammarFileName(): string;
27
+ get literalNames(): (string | null)[];
28
+ get symbolicNames(): (string | null)[];
29
+ get ruleNames(): string[];
30
+ get serializedATN(): number[];
31
+ protected createFailedPredicateException(predicate?: string, message?: string): antlr.FailedPredicateException;
32
+ constructor(input: antlr.TokenStream);
33
+ program(): ProgramContext;
34
+ line(): LineContext;
35
+ setDecl(): SetDeclContext;
36
+ labelPart(): LabelPartContext;
37
+ itemDecl(): ItemDeclContext;
38
+ sugarDecl(): SugarDeclContext;
39
+ pattern(): PatternContext;
40
+ valueList(): ValueListContext;
41
+ valueItem(): ValueItemContext;
42
+ static readonly _serializedATN: number[];
43
+ private static __ATN;
44
+ static get _ATN(): antlr.ATN;
45
+ private static readonly vocabulary;
46
+ get vocabulary(): antlr.Vocabulary;
47
+ private static readonly decisionsToDFA;
48
+ }
49
+ export declare class ProgramContext extends antlr.ParserRuleContext {
50
+ constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
51
+ EOF(): antlr.TerminalNode;
52
+ NL(): antlr.TerminalNode[];
53
+ NL(i: number): antlr.TerminalNode | null;
54
+ line(): LineContext[];
55
+ line(i: number): LineContext | null;
56
+ get ruleIndex(): number;
57
+ enterRule(listener: TagSetListener): void;
58
+ exitRule(listener: TagSetListener): void;
59
+ accept<Result>(visitor: TagSetVisitor<Result>): Result | null;
60
+ }
61
+ export declare class LineContext extends antlr.ParserRuleContext {
62
+ constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
63
+ setDecl(): SetDeclContext | null;
64
+ itemDecl(): ItemDeclContext | null;
65
+ sugarDecl(): SugarDeclContext | null;
66
+ NL(): antlr.TerminalNode | null;
67
+ get ruleIndex(): number;
68
+ enterRule(listener: TagSetListener): void;
69
+ exitRule(listener: TagSetListener): void;
70
+ accept<Result>(visitor: TagSetVisitor<Result>): Result | null;
71
+ }
72
+ export declare class SetDeclContext extends antlr.ParserRuleContext {
73
+ constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
74
+ SET(): antlr.TerminalNode;
75
+ WORD(): antlr.TerminalNode;
76
+ labelPart(): LabelPartContext[];
77
+ labelPart(i: number): LabelPartContext | null;
78
+ get ruleIndex(): number;
79
+ enterRule(listener: TagSetListener): void;
80
+ exitRule(listener: TagSetListener): void;
81
+ accept<Result>(visitor: TagSetVisitor<Result>): Result | null;
82
+ }
83
+ export declare class LabelPartContext extends antlr.ParserRuleContext {
84
+ constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
85
+ WORD(): antlr.TerminalNode | null;
86
+ QUOTED_STRING(): antlr.TerminalNode | null;
87
+ get ruleIndex(): number;
88
+ enterRule(listener: TagSetListener): void;
89
+ exitRule(listener: TagSetListener): void;
90
+ accept<Result>(visitor: TagSetVisitor<Result>): Result | null;
91
+ }
92
+ export declare class ItemDeclContext extends antlr.ParserRuleContext {
93
+ constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
94
+ ITEM(): antlr.TerminalNode;
95
+ pattern(): PatternContext;
96
+ valueList(): ValueListContext;
97
+ get ruleIndex(): number;
98
+ enterRule(listener: TagSetListener): void;
99
+ exitRule(listener: TagSetListener): void;
100
+ accept<Result>(visitor: TagSetVisitor<Result>): Result | null;
101
+ }
102
+ export declare class SugarDeclContext extends antlr.ParserRuleContext {
103
+ constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
104
+ WORD(): antlr.TerminalNode[];
105
+ WORD(i: number): antlr.TerminalNode | null;
106
+ COLON(): antlr.TerminalNode;
107
+ valueList(): ValueListContext;
108
+ COMMA(): antlr.TerminalNode[];
109
+ COMMA(i: number): antlr.TerminalNode | null;
110
+ get ruleIndex(): number;
111
+ enterRule(listener: TagSetListener): void;
112
+ exitRule(listener: TagSetListener): void;
113
+ accept<Result>(visitor: TagSetVisitor<Result>): Result | null;
114
+ }
115
+ export declare class PatternContext extends antlr.ParserRuleContext {
116
+ constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
117
+ WORD(): antlr.TerminalNode[];
118
+ WORD(i: number): antlr.TerminalNode | null;
119
+ AMP(): antlr.TerminalNode[];
120
+ AMP(i: number): antlr.TerminalNode | null;
121
+ get ruleIndex(): number;
122
+ enterRule(listener: TagSetListener): void;
123
+ exitRule(listener: TagSetListener): void;
124
+ accept<Result>(visitor: TagSetVisitor<Result>): Result | null;
125
+ }
126
+ export declare class ValueListContext extends antlr.ParserRuleContext {
127
+ constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
128
+ valueItem(): ValueItemContext[];
129
+ valueItem(i: number): ValueItemContext | null;
130
+ COMMA(): antlr.TerminalNode[];
131
+ COMMA(i: number): antlr.TerminalNode | null;
132
+ get ruleIndex(): number;
133
+ enterRule(listener: TagSetListener): void;
134
+ exitRule(listener: TagSetListener): void;
135
+ accept<Result>(visitor: TagSetVisitor<Result>): Result | null;
136
+ }
137
+ export declare class ValueItemContext extends antlr.ParserRuleContext {
138
+ constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
139
+ WORD(): antlr.TerminalNode[];
140
+ WORD(i: number): antlr.TerminalNode | null;
141
+ QUOTED_STRING(): antlr.TerminalNode[];
142
+ QUOTED_STRING(i: number): antlr.TerminalNode | null;
143
+ get ruleIndex(): number;
144
+ enterRule(listener: TagSetListener): void;
145
+ exitRule(listener: TagSetListener): void;
146
+ accept<Result>(visitor: TagSetVisitor<Result>): Result | null;
147
+ }
@@ -0,0 +1,73 @@
1
+ import { AbstractParseTreeVisitor } from "antlr4ng";
2
+ import { ProgramContext } from "./TagSetParser.js";
3
+ import { LineContext } from "./TagSetParser.js";
4
+ import { SetDeclContext } from "./TagSetParser.js";
5
+ import { LabelPartContext } from "./TagSetParser.js";
6
+ import { ItemDeclContext } from "./TagSetParser.js";
7
+ import { SugarDeclContext } from "./TagSetParser.js";
8
+ import { PatternContext } from "./TagSetParser.js";
9
+ import { ValueListContext } from "./TagSetParser.js";
10
+ import { ValueItemContext } from "./TagSetParser.js";
11
+ /**
12
+ * This interface defines a complete generic visitor for a parse tree produced
13
+ * by `TagSetParser`.
14
+ *
15
+ * @param <Result> The return type of the visit operation. Use `void` for
16
+ * operations with no return type.
17
+ */
18
+ export declare class TagSetVisitor<Result> extends AbstractParseTreeVisitor<Result> {
19
+ /**
20
+ * Visit a parse tree produced by `TagSetParser.program`.
21
+ * @param ctx the parse tree
22
+ * @return the visitor result
23
+ */
24
+ visitProgram?: (ctx: ProgramContext) => Result;
25
+ /**
26
+ * Visit a parse tree produced by `TagSetParser.line`.
27
+ * @param ctx the parse tree
28
+ * @return the visitor result
29
+ */
30
+ visitLine?: (ctx: LineContext) => Result;
31
+ /**
32
+ * Visit a parse tree produced by `TagSetParser.setDecl`.
33
+ * @param ctx the parse tree
34
+ * @return the visitor result
35
+ */
36
+ visitSetDecl?: (ctx: SetDeclContext) => Result;
37
+ /**
38
+ * Visit a parse tree produced by `TagSetParser.labelPart`.
39
+ * @param ctx the parse tree
40
+ * @return the visitor result
41
+ */
42
+ visitLabelPart?: (ctx: LabelPartContext) => Result;
43
+ /**
44
+ * Visit a parse tree produced by `TagSetParser.itemDecl`.
45
+ * @param ctx the parse tree
46
+ * @return the visitor result
47
+ */
48
+ visitItemDecl?: (ctx: ItemDeclContext) => Result;
49
+ /**
50
+ * Visit a parse tree produced by `TagSetParser.sugarDecl`.
51
+ * @param ctx the parse tree
52
+ * @return the visitor result
53
+ */
54
+ visitSugarDecl?: (ctx: SugarDeclContext) => Result;
55
+ /**
56
+ * Visit a parse tree produced by `TagSetParser.pattern`.
57
+ * @param ctx the parse tree
58
+ * @return the visitor result
59
+ */
60
+ visitPattern?: (ctx: PatternContext) => Result;
61
+ /**
62
+ * Visit a parse tree produced by `TagSetParser.valueList`.
63
+ * @param ctx the parse tree
64
+ * @return the visitor result
65
+ */
66
+ visitValueList?: (ctx: ValueListContext) => Result;
67
+ /**
68
+ * Visit a parse tree produced by `TagSetParser.valueItem`.
69
+ * @param ctx the parse tree
70
+ * @return the visitor result
71
+ */
72
+ visitValueItem?: (ctx: ValueItemContext) => Result;
73
+ }
@@ -0,0 +1,2 @@
1
+ export { parse } from './parser.js';
2
+ export type { SetDecl, ItemDecl, TagSetAST } from './types.js';
@@ -0,0 +1,2 @@
1
+ import type { TagSetAST } from './types.js';
2
+ export declare function parse(input: string): TagSetAST;
@@ -0,0 +1,14 @@
1
+ export interface SetDecl {
2
+ id: string;
3
+ label: string;
4
+ index: number;
5
+ }
6
+ export interface ItemDecl {
7
+ pattern: string;
8
+ bitmask: number;
9
+ values: string[];
10
+ }
11
+ export interface TagSetAST {
12
+ sets: SetDecl[];
13
+ items: ItemDecl[];
14
+ }
@@ -0,0 +1,13 @@
1
+ import { TagSetVisitor } from './generated/TagSetVisitor.js';
2
+ import type { ProgramContext, SetDeclContext, ItemDeclContext, SugarDeclContext } from './generated/TagSetParser.js';
3
+ import type { TagSetAST } from './types.js';
4
+ export declare class TagSetASTVisitor extends TagSetVisitor<void> {
5
+ private explicitSets;
6
+ private rawItems;
7
+ private setIndex;
8
+ visitProgram: (ctx: ProgramContext) => void;
9
+ visitSetDecl: (ctx: SetDeclContext) => void;
10
+ visitItemDecl: (ctx: ItemDeclContext) => void;
11
+ visitSugarDecl: (ctx: SugarDeclContext) => void;
12
+ buildAST(): TagSetAST;
13
+ }
package/license ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) elzup <guild0105@gmail.com> (elzup.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/package.json ADDED
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "tagset-parser",
3
+ "version": "0.0.0",
4
+ "description": "TagSet DSL parser",
5
+ "author": "elzup",
6
+ "license": "MIT",
7
+ "type": "module",
8
+ "main": "lib/cjs/index.js",
9
+ "module": "lib/esm/index.js",
10
+ "types": "lib/types/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./lib/types/index.d.ts",
14
+ "import": "./lib/esm/index.js",
15
+ "require": "./lib/cjs/index.js"
16
+ }
17
+ },
18
+ "repository": "elzup/tagset-parser",
19
+ "bugs": {
20
+ "url": "https://github.com/elzup/tagset-parser/issues"
21
+ },
22
+ "homepage": "https://github.com/elzup/tagset-parser#readme",
23
+ "keywords": [
24
+ "tagset",
25
+ "parser",
26
+ "dsl"
27
+ ],
28
+ "engines": {
29
+ "node": ">=18"
30
+ },
31
+ "files": [
32
+ "lib/"
33
+ ],
34
+ "sideEffects": false,
35
+ "devDependencies": {
36
+ "@elzup/tsconfig": "1.1.0",
37
+ "@types/node": "24.10.1",
38
+ "@vitest/coverage-v8": "^4.0.15",
39
+ "@vitest/ui": "^4.0.15",
40
+ "antlr-ng": "^1.0.10",
41
+ "oxlint": "^1.31.0",
42
+ "prettier": "^3.8.1",
43
+ "rimraf": "^6.1.2",
44
+ "typescript": "5.9.3",
45
+ "vitest": "^4.0.15"
46
+ },
47
+ "dependencies": {
48
+ "antlr4ng": "^3.0.16"
49
+ },
50
+ "scripts": {
51
+ "generate": "antlr-ng -Dlanguage=TypeScript --generate-visitor -o src/generated src/grammar/TagSet.g4",
52
+ "clean": "rimraf lib",
53
+ "build": "npm run clean && npm run build:cjs && npm run build:esm && npm run build:types",
54
+ "build:cjs": "tsc --module commonjs --outDir lib/cjs && echo '{\"type\": \"commonjs\"}' > lib/cjs/package.json",
55
+ "build:esm": "tsc --module esnext --outDir lib/esm --moduleResolution node --allowSyntheticDefaultImports",
56
+ "build:types": "tsc --declaration --emitDeclarationOnly --outDir lib/types",
57
+ "format": "prettier --write .",
58
+ "lint": "oxlint --ignore-pattern src/generated/",
59
+ "lint:fix": "oxlint --fix --ignore-pattern src/generated/",
60
+ "test": "vitest run",
61
+ "test:watch": "vitest",
62
+ "test:ui": "vitest --ui",
63
+ "test:cov": "vitest run --coverage"
64
+ }
65
+ }