import type { Fn , Fn0 , IObjectOf , Nullable } from "@thi.ng/api" ; import type { ParseContext } from "./context.js" ; export interface ParseScope < T > { id : string ; state : Nullable < ParseState < T > > ; children : Nullable < ParseScope < T > [ ] > ; result : any ; } export interface ParseState < T > { p : number ; l : number ; c : number ; done ? : boolean ; last ? : T ; } export interface IReader < T > { read ( state ) : T ; next ( state ) : void ; isDone ( state ) : boolean ; format ( state ) : string ; } export type Parser < T > = Fn < ParseContext < T > , boolean > ; export type LitParser < T > = Parser < T > & { __lit : true ; } ; export type DynamicParser < T > = Parser < T > & { set : Fn < Parser < T > , void > ; } ; export type PassValue < T > = T | Fn0 < T > ; export type CharSet = IObjectOf < boolean > ; export type ScopeTransform < T > = ( scope : Nullable < ParseScope < T > > , ctx : ParseContext < T > , user ? : any ) => Nullable < ParseScope < T > > ; export interface GrammarOpts { defaultValue debug : boolean ; defaultValue optimize : boolean ; } export type Rules = IObjectOf < Parser < string > > ; export type RuleTransforms = IObjectOf < ScopeTransform < string > > ; export interface Language { grammar : ParseContext < string > ; env : RuleTransforms ; rules : Rules ; } export interface ContextOpts { defaultVal maxDepth : number ; defaultValue debug : boolean ; defaultValue retain : boolean ; }