mago-syntax 1.20.1

A correct, fast, and memory-efficient PHP syntax implementation, including Lexer, Parser, AST, and utilities for Mago.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use crate::T;
use crate::ast::ast::Return;
use crate::error::ParseError;
use crate::parser::Parser;

impl<'input, 'arena> Parser<'input, 'arena> {
    pub(crate) fn parse_return(&mut self) -> Result<Return<'arena>, ParseError> {
        Ok(Return {
            r#return: self.expect_keyword(T!["return"])?,
            value: if matches!(self.stream.peek_kind(0)?, Some(T![";" | "?>"])) {
                None
            } else {
                Some(self.parse_expression()?)
            },
            terminator: self.parse_terminator()?,
        })
    }
}