pub struct CstText {
pub text: String,
pub lines: Vec<usize>,
pub cst: Cst,
}
Expand description
CST にテキストの情報を付加したもの。
Fields§
§text: String
§lines: Vec<usize>
§cst: Cst
Implementations§
Source§impl CstText
impl CstText
Sourcepub fn parse<F>(
text: &str,
parser: F,
) -> Result<Self, (LineCol, Vec<&'static str>)>
pub fn parse<F>( text: &str, parser: F, ) -> Result<Self, (LineCol, Vec<&'static str>)>
与えられたパーサに基づき、与えられたテキストをパースする。
Sourcepub fn get_text_from_span(&self, span: Span) -> &str
pub fn get_text_from_span(&self, span: Span) -> &str
self.cst の子要素である Cst について、その要素に相当する text を取得する。
Sourcepub fn get_line_col(&self, pos: usize) -> Option<LineCol>
pub fn get_line_col(&self, pos: usize) -> Option<LineCol>
与えられた position の line 及び col を出力する。
Sourcepub fn from_line_col(&self, line: usize, column: usize) -> Option<usize>
pub fn from_line_col(&self, line: usize, column: usize) -> Option<usize>
与えられた line 及び col の position を出力する。
Sourcepub fn pritty_cst_recursive(&self, cst: &Cst) -> String
pub fn pritty_cst_recursive(&self, cst: &Cst) -> String
CST の構造を string にして出力する。
Sourcepub fn pritty_cst(&self, cst: &Cst) -> String
pub fn pritty_cst(&self, cst: &Cst) -> String
Cst を pritty 表示。
Sourcepub fn is_comment(&self, pos: usize) -> bool
pub fn is_comment(&self, pos: usize) -> bool
与えられた場所がコメント内かどうか判定する。
Trait Implementations§
impl Eq for CstText
impl StructuralPartialEq for CstText
Auto Trait Implementations§
impl Freeze for CstText
impl RefUnwindSafe for CstText
impl Send for CstText
impl Sync for CstText
impl Unpin for CstText
impl UnwindSafe for CstText
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more