Struct caribon::Ast [] [src]

pub struct Ast {
    pub words: Vec<Word>,
    pub begin_head: Option<usize>,
    pub begin_body: Option<usize>,
    pub end_body: Option<usize>,
}

The internal representation of the document.

Technically the name AST is not really well chosen, since it is not a tree, but mainly a vector of Words plus some additonal informations for HTML parsing, but the idea is that it is the internal representation of the documentation.

Fields

words: Vec<Word>

Vector of Words. The main data of the structure.

begin_head: Option<usize>

Position of tag, if any

begin_body: Option<usize> end_body: Option<usize>

position of

tag, if any

Methods

impl Ast
[src]

fn new() -> Ast

Creates a new, empty AST

fn mark_begin_head(&mut self)

Sets begin_head to current last position of words

This should be called before inserting the corresponding element.

fn mark_begin_body(&mut self)

Sets begin_body to current last position of words

This should be called before inserting the corresponding element.

fn mark_end_body(&mut self)

Sets end_body to current last position of words

This should be called before inserting the corresponding element.

fn get_body(&self) -> &[Word]

Get only the words contained between

and

If body_begin and body_end are both set (and the first one is before the second), returns a slice that contains only words in this part; else, returns all words.

fn get_body_mut(&mut self) -> &mut [Word]

Get only the words contained between

and
, mutable version

Same as get_body, but takes and return a mutable reference.

Trait Implementations

impl Clone for Ast
[src]

fn clone(&self) -> Ast

Returns a copy of the value. Read more

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

Performs copy-assignment from source. Read more

impl Debug for Ast
[src]

fn fmt(&self, __arg_0: &mut Formatter) -> Result

Formats the value using the given formatter.