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 strThe 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: booltrue 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: SourceMapPre-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.