rule.rs 1.3 KB
Newer Older
1
use crate::inter::{IRawRepository, IRawGrammar, ILocation};
2

P
Phodal Huang 已提交
3
pub struct RuleFactory {}
4 5

impl RuleFactory {
6
    pub fn get_compiled_rule_id(repository: IRawRepository) {}
7

8 9 10 11 12 13 14 15 16 17 18 19 20 21
    pub fn create_capture_rule() {}
}


pub struct Rule {
    pub location: ILocation,
    pub id: i32,
    pub name: Option<String>,
    pub content_name: Option<String>,
}

impl Rule {
    pub fn new(location: ILocation, id: i32, name: Option<String>, content_name: Option<String>) -> Self {
        Rule { location, id, name, content_name }
22
    }
23
}
24

25 26 27 28 29 30
pub trait AbstractRule {

}

pub struct IncludeOnlyRule {
    pub rule: Rule
P
Phodal Huang 已提交
31
}
P
Phodal Huang 已提交
32

33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
impl AbstractRule for IncludeOnlyRule {}

pub struct BeginWhileRule {
    pub rule: Rule
}

impl AbstractRule for BeginWhileRule {}

pub struct MatchRule {
    pub rule: Rule
}

impl AbstractRule for MatchRule {}

pub struct BeginEndRule {
    pub rule: Rule
}

impl AbstractRule for BeginEndRule {}

pub struct CaptureRule {
    pub rule: Rule
}

impl AbstractRule for CaptureRule {}


P
Phodal Huang 已提交
60 61 62
// todo: trait with types
// https://users.rust-lang.org/t/impl-trait-with-generic-function-for-generic-struct/27083/2
pub trait IRuleRegistry {
63
    fn get_rule(&self, pattern_id: i32) -> Rule;
P
Phodal Huang 已提交
64 65 66 67 68 69
    // fn register_rule(&self);
}

pub trait IGrammarRegistry {
    fn get_external_grammar(&self, scope_name: String, repository: IRawRepository) -> Option<IRawGrammar>;
}