@@ -21,7 +21,33 @@ interface ResolveOptions {
21
21
encoder : ( paramterValue : string , parameterName ?: string ) => string ;
22
22
}
23
23
24
+ export interface Grammar {
25
+ grammarObject : string ; // Internal identifier
26
+ rules : Rule [ ] ; // List of grammar rules
27
+ udts : UDT [ ] ; // User-defined terminals (empty in this grammar)
28
+ toString ( ) : string ; // Method to return the grammar in ABNF format
29
+ }
30
+
31
+ export interface Rule {
32
+ name : string ; // Rule name
33
+ lower : string ; // Lowercased rule name
34
+ index : number ; // Rule index
35
+ isBkr : boolean ; // Is this a back-reference?
36
+ opcodes ?: Opcode [ ] ; // List of opcodes for the rule
37
+ }
38
+
39
+ export type Opcode =
40
+ | { type : 1 ; children : number [ ] } // ALT (alternation)
41
+ | { type : 2 ; children : number [ ] } // CAT (concatenation)
42
+ | { type : 3 ; min : number ; max : number } // REP (repetition)
43
+ | { type : 4 ; index : number } // RNM (rule reference)
44
+ | { type : 5 ; min : number ; max : number } // TRG (terminal range)
45
+ | { type : 6 | 7 ; string : number [ ] } ; // TBS or TLS (byte sequence or literal string)
46
+
47
+ export type UDT = { } ; // User-defined terminals (empty in this grammar)
48
+
24
49
export function parse ( pathTemplate : string ) : ParseResult ;
25
50
export function test ( pathTemplate : string , options ?: TestOptions ) : boolean ;
26
51
export function resolve ( pathTemplate : string , parameters : Parameters , options ?: ResolveOptions ) : string ;
27
52
export function encodePathComponent ( parameterValue : string ) : string ;
53
+ export function Grammar ( ) : Grammar ;
0 commit comments