Skip to main content

mago_syntax/
settings.rs

1/// Settings for the lexer.
2#[derive(Debug, Clone, Copy)]
3pub struct LexerSettings {
4    /// Whether to enable short open tags (`<?`).
5    ///
6    /// When enabled (default), `<?` is treated as a short open tag that switches to PHP scripting mode.
7    /// When disabled, only `<?php` and `<?=` are recognized as valid PHP open tags.
8    ///
9    /// This corresponds to PHP's `short_open_tag` ini directive.
10    pub enable_short_tags: bool,
11}
12
13/// Settings for the parser.
14#[derive(Debug, Clone, Copy, Default)]
15pub struct ParserSettings {
16    /// Settings for the lexer.
17    pub lexer: LexerSettings,
18    /// Keep unfinished bodies and lists at EOF for editor queries.
19    /// Missing delimiters still produce parse errors.
20    pub recover_incomplete: bool,
21    /// Drop whitespace trivia that no comment precedes within the same token gap.
22    /// Docblock and pragma lookups only ever read whitespace that follows a comment.
23    pub elide_detached_whitespace: bool,
24}
25
26impl Default for LexerSettings {
27    fn default() -> Self {
28        Self { enable_short_tags: true }
29    }
30}