parser

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 3, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package parser with object pooling to reduce allocations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TestParsing_ArrayExpression

func TestParsing_ArrayExpression(t *testing.T)

TestParsing_ArrayExpression 数组表达式测试

func TestParsing_ArrayTrailingCommas

func TestParsing_ArrayTrailingCommas(t *testing.T)

TestParsing_ArrayTrailingCommas 数组尾随逗号测试

func TestParsing_BitwiseOperations

func TestParsing_BitwiseOperations(t *testing.T)

TestParsing_BitwiseOperations 位运算测试

func TestParsing_FunctionReturnTypes

func TestParsing_FunctionReturnTypes(t *testing.T)

TestParsing_FunctionReturnTypes 函数返回类型测试

func TestParsing_GroupedExpression

func TestParsing_GroupedExpression(t *testing.T)

TestParsing_GroupedExpression 分组表达式测试

func TestParsing_HeredocStrings

func TestParsing_HeredocStrings(t *testing.T)

TestParsing_HeredocStrings Heredoc字符串测试

func TestParsing_NowdocStrings

func TestParsing_NowdocStrings(t *testing.T)

TestParsing_NowdocStrings Nowdoc字符串测试

func TestParsing_OperatorPrecedence

func TestParsing_OperatorPrecedence(t *testing.T)

TestParsing_OperatorPrecedence 操作符优先级测试

func TestParsing_StringInterpolation

func TestParsing_StringInterpolation(t *testing.T)

TestParsing_StringInterpolation 字符串插值测试

func TestParsing_TypedParameters

func TestParsing_TypedParameters(t *testing.T)

TestParsing_TypedParameters 类型化参数测试

Types

type InfixParseFn

type InfixParseFn func(*Parser, ast.Expression) ast.Expression

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

Parser 解析器结构体

func New

func New(l *lexer.Lexer) *Parser

func NewFromPool

func NewFromPool(l *lexer.Lexer) *Parser

NewFromPool 从对象池中获取一个 Parser 实例

func (*Parser) Errors

func (p *Parser) Errors() []string

Errors 获取解析错误

func (*Parser) ParseProgram

func (p *Parser) ParseProgram() *ast.Program

ParseProgram 解析整个程序

func (*Parser) Release

func (p *Parser) Release()

Release 将 Parser 归还给对象池

type Precedence

type Precedence int

Precedence 操作符优先级 - 根据 PHP 官方优先级顺序

const (
	LOWEST        Precedence
	ASSIGN        // = += -= *= /= .= %= &= |= ^= <<= >>= **= ??=
	TERNARY       // ? :
	COALESCE      // ??
	LOGICAL_OR    // || or
	LOGICAL_AND   // && and
	BITWISE_OR    // |
	BITWISE_XOR   // ^
	BITWISE_AND   // &
	EQUALS        // == != === !==
	LESSGREATER   // < <= > >= <=> instanceof
	BITWISE_SHIFT // << >>
	SUM           // + - .
	PRODUCT       // * / %
	EXPONENT      // **
	PREFIX        // ! ~ -X +X ++X --X (int) (float) (string) (array) (object) (bool) @
	POSTFIX       // X++ X--
	CALL          // myFunction(X) $obj->prop Class::$prop
	INDEX         // array[index]
)

type PrefixParseFn

type PrefixParseFn func(*Parser) ast.Expression

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL