Skip to main content

ParseResult

Struct ParseResult 

Source
pub struct ParseResult<'arena, 'src> {
    pub source: &'src str,
    pub program: Program<'arena, 'src>,
    pub comments: Vec<Comment<'src>>,
    pub errors: Vec<ParseError>,
    pub errors_truncated: bool,
    pub source_map: SourceMap,
}
Expand description

The result of parsing a PHP source string.

Fields§

§source: &'src str

The original source text. Useful for extracting text from spans via &result.source[span.start as usize..span.end as usize].

§program: Program<'arena, 'src>

The parsed AST. Always produced, even when errors are present.

§comments: Vec<Comment<'src>>

All comments found in the source, in source order, except /** */ doc-block comments that are immediately attached to a declaration.

When the parser encounters a /** */ comment directly before a function, class, method, property, constant, or enum case, it removes that comment from this list and stores it in the declaration node’s doc_comment field instead. The two collections are therefore disjoint: iterating both without deduplication will double-count nothing, but iterating only one will miss the other’s entries.

To process every comment in the file, iterate result.comments (for line, hash, block, and unattached doc comments) and also visit each declaration node’s doc_comment field. Or use php_ast::visitor::walk_comments with a [Visitor] that also overrides the declaration visit methods.

§errors: Vec<ParseError>

Parse errors and diagnostics. Empty on a successful parse.

§errors_truncated: bool

true when the error list was capped at the internal limit and further errors were silently dropped. Callers that need a complete error list (e.g. linters) should treat this as an incomplete result.

§source_map: SourceMap

Pre-computed line index for resolving byte offsets in Span to line/column positions. Use SourceMap::offset_to_line_col or SourceMap::span_to_line_col to convert.

Auto Trait Implementations§

§

impl<'arena, 'src> Freeze for ParseResult<'arena, 'src>

§

impl<'arena, 'src> !RefUnwindSafe for ParseResult<'arena, 'src>

§

impl<'arena, 'src> !Send for ParseResult<'arena, 'src>

§

impl<'arena, 'src> !Sync for ParseResult<'arena, 'src>

§

impl<'arena, 'src> Unpin for ParseResult<'arena, 'src>

§

impl<'arena, 'src> UnsafeUnpin for ParseResult<'arena, 'src>

§

impl<'arena, 'src> !UnwindSafe for ParseResult<'arena, 'src>

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> 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, 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.