pub struct Region {
pub id: String,
pub name: String,
pub begin: String,
pub end: String,
pub interp: Vec<Region>,
pub tokenize: bool,
pub allow_unclosed_region: bool,
pub global: bool,
pub references: Option<String>,
pub singleline: bool,
pub ignore_escaped: bool,
}Expand description
Structure that describes isolated text that should not be tokenized such as string or comment
Region can be used to create a way to describe a form of region in your code that should not be parsed. Additionally you can create interpolation rules in order to interpolate code inside.
§Macro
Creating regions may be too verbose at times hence you can use defined macro to create regions
§Example
reg!(str as "string literal" => {
begin: "'",
end: "'"
});You can extend region with multiple options. The recommended options are:
tokenizeallow_unclosed_regionsingleline
Fields§
§id: Stringidentifier that will be used to reference this region in an interpolation
name: Stringhuman-readable (preferebly all small caps) name of this region
begin: StringString that determines beginning of this region
end: StringString that determines end of this region
interp: Vec<Region>Vector of region interpolations
tokenize: boolThis field determines if the contents of the region should be tokenized
allow_unclosed_region: boolThis field can allow to leave region unclosed after parsing has finished
global: boolDetermines if this region is the global context
references: Option<String>Region can be a reference to some other region
singleline: boolDetermines if region cannot go past the new line character
ignore_escaped: boolWhether to ignore escaped characters for this region only
Implementations§
Source§impl Region
impl Region
Sourcepub fn new<T: AsRef<str>>(
id: T,
name: T,
begin: T,
end: T,
interp: Vec<Region>,
references: Option<T>,
) -> Self
pub fn new<T: AsRef<str>>( id: T, name: T, begin: T, end: T, interp: Vec<Region>, references: Option<T>, ) -> Self
Create a new region by scratch
Sourcepub fn new_global(interp: Vec<Region>) -> Region
pub fn new_global(interp: Vec<Region>) -> Region
Create a new global region
Sourcepub fn generate_region_map(&self) -> RegionMap
pub fn generate_region_map(&self) -> RegionMap
Generate a region for region handler
This functionality is required if we want to reference other regions. It is not supposed to be used explicitly in the code, however this can be used to debug complex region dependency tree.