@@ -12,6 +12,7 @@ use crate::parser_rule_context::ParserRuleContext;
1212use crate :: token_factory:: TokenFactory ;
1313use crate :: tree:: { ParseTree , Tree } ;
1414use better_any:: { Tid , TidAble } ;
15+ use std:: any:: type_name;
1516
1617//pub trait RuleContext:RuleNode {
1718/// Minimal rule context functionality required for parser to work properly
@@ -101,8 +102,10 @@ impl<'a, TF: TokenFactory<'a>> ParserNodeType<'a> for EmptyContextType<'a, TF> {
101102#[ allow( missing_docs) ]
102103pub trait CustomRuleContext < ' input > {
103104 type TF : TokenFactory < ' input > + ' input ;
105+ /// Type that describes type of context nodes, stored in this context
104106 type Ctx : ParserNodeType < ' input , TF = Self :: TF > ;
105107 //const RULE_INDEX:usize;
108+ /// Rule index that corresponds to this context type
106109 fn get_rule_index ( & self ) -> usize ;
107110
108111 fn get_alt_number ( & self ) -> isize { INVALID_ALT }
@@ -194,7 +197,12 @@ impl<'input, ExtCtx: CustomRuleContext<'input>> RuleContext<'input>
194197}
195198
196199impl < ' input , ExtCtx : CustomRuleContext < ' input > > Debug for BaseRuleContext < ' input , ExtCtx > {
197- fn fmt ( & self , _f : & mut Formatter < ' _ > ) -> std:: fmt:: Result { unimplemented ! ( ) }
200+ fn fmt ( & self , f : & mut Formatter < ' _ > ) -> std:: fmt:: Result {
201+ f. debug_struct ( type_name :: < Self > ( ) )
202+ . field ( "invoking_state" , & self . invoking_state )
203+ . field ( ".." , & ".." )
204+ . finish ( )
205+ }
198206}
199207
200208impl < ' input , ExtCtx : CustomRuleContext < ' input > > Tree < ' input > for BaseRuleContext < ' input , ExtCtx > { }
0 commit comments