pub struct ProgramText {
pub structure: Result<Program>,
pub cst: Cst,
pub lines: Vec<usize>,
pub text: String,
}Expand description
CstText と似ているが、こちらは構文要素が構造体で分かれている。
Fields§
§structure: Result<Program>§cst: Cst§lines: Vec<usize>§text: StringImplementations§
Source§impl ProgramText
impl ProgramText
pub fn parse(text: &str) -> 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(&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§
Auto Trait Implementations§
impl Freeze for ProgramText
impl RefUnwindSafe for ProgramText
impl Send for ProgramText
impl Sync for ProgramText
impl Unpin for ProgramText
impl UnwindSafe for ProgramText
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