@@ -30,13 +30,13 @@ use crate::{statistics, Scanner};
30
30
#[ derive( Debug ) ]
31
31
pub struct Compiler {
32
32
/// List of compiled rules.
33
- rules : Vec < rule:: Rule > ,
33
+ pub ( crate ) rules : Vec < rule:: Rule > ,
34
34
35
35
/// List of compiled, global rules.
36
- global_rules : Vec < rule:: Rule > ,
36
+ pub ( crate ) global_rules : Vec < rule:: Rule > ,
37
37
38
38
/// List of compiled variables.
39
- variables : Vec < variable:: Variable > ,
39
+ pub ( crate ) variables : Vec < variable:: Variable > ,
40
40
41
41
/// Number of variables used by global rules.
42
42
nb_global_rules_variables : usize ,
@@ -46,7 +46,7 @@ pub struct Compiler {
46
46
/// This list always contains at least one namespace: the default one,
47
47
/// at index 0. Other namespaces are added when rules are added in the
48
48
/// non default namespace.
49
- namespaces : Vec < Namespace > ,
49
+ pub ( crate ) namespaces : Vec < Namespace > ,
50
50
51
51
/// Map from the namespace name to its index in the `namespaces` list.
52
52
namespaces_indexes : HashMap < String , usize > ,
@@ -57,15 +57,15 @@ pub struct Compiler {
57
57
available_modules : HashMap < & ' static str , AvailableModule > ,
58
58
59
59
/// List of imported modules, passed to the scanner.
60
- imported_modules : Vec < Box < dyn crate :: module:: Module > > ,
60
+ pub ( crate ) imported_modules : Vec < Box < dyn crate :: module:: Module > > ,
61
61
62
62
/// Externally defined symbols.
63
- external_symbols : Vec < external_symbol:: ExternalSymbol > ,
63
+ pub ( crate ) external_symbols : Vec < external_symbol:: ExternalSymbol > ,
64
64
65
65
/// Bytes intern pool.
66
66
///
67
67
/// This is used to reduce memory footprint and share byte strings.
68
- bytes_pool : BytesPoolBuilder ,
68
+ pub ( crate ) bytes_pool : BytesPoolBuilder ,
69
69
70
70
/// Compilation parameters
71
71
params : CompilerParams ,
@@ -484,17 +484,7 @@ impl Compiler {
484
484
/// Can fail if generating a set of all rules variables is not possible.
485
485
#[ must_use]
486
486
pub fn into_scanner ( self ) -> Scanner {
487
- let namespaces = self . namespaces . into_iter ( ) . map ( |v| v. name ) . collect ( ) ;
488
-
489
- Scanner :: new (
490
- self . rules ,
491
- self . global_rules ,
492
- self . variables ,
493
- self . imported_modules ,
494
- self . external_symbols ,
495
- namespaces,
496
- self . bytes_pool . into_pool ( ) ,
497
- )
487
+ Scanner :: new ( self )
498
488
}
499
489
}
500
490
@@ -505,9 +495,9 @@ impl Compiler {
505
495
/// - new rules can reference already existing rules
506
496
/// - new rules can either import new modules, or directly use already imported modules
507
497
#[ derive( Debug , Default ) ]
508
- struct Namespace {
498
+ pub ( crate ) struct Namespace {
509
499
/// Name of the namespace, `None` if default.
510
- name : Option < String > ,
500
+ pub ( crate ) name : Option < String > ,
511
501
512
502
/// Map of a rule name to its index in the `rules` vector in [`Compiler`].
513
503
///
0 commit comments