Region

Struct Region 

Source
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:

  • tokenize
  • allow_unclosed_region
  • singleline

Fields§

§id: String

identifier that will be used to reference this region in an interpolation

§name: String

human-readable (preferebly all small caps) name of this region

§begin: String

String that determines beginning of this region

§end: String

String that determines end of this region

§interp: Vec<Region>

Vector of region interpolations

§tokenize: bool

This field determines if the contents of the region should be tokenized

§allow_unclosed_region: bool

This field can allow to leave region unclosed after parsing has finished

§global: bool

Determines if this region is the global context

§references: Option<String>

Region can be a reference to some other region

§singleline: bool

Determines if region cannot go past the new line character

§ignore_escaped: bool

Whether to ignore escaped characters for this region only

Implementations§

Source§

impl Region

Source

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

Source

pub fn new_global(interp: Vec<Region>) -> Region

Create a new global region

Source

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.

Trait Implementations§

Source§

impl Clone for Region

Source§

fn clone(&self) -> Region

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Region

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Region

Source§

fn eq(&self, other: &Region) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Region

Auto Trait Implementations§

§

impl Freeze for Region

§

impl RefUnwindSafe for Region

§

impl Send for Region

§

impl Sync for Region

§

impl Unpin for Region

§

impl UnwindSafe for Region

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.