parser

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsInt64 added in v0.8.0

func AsInt64(value any) (int64, bool)

AsInt64 coerces a parsed scalar value (as produced by Parse) to int64. Parse yields integer scalars as int64 and floating scalars as float64; a plain int is accepted defensively. Any other type yields ok=false.

func ScanInlinePPtrs added in v0.8.0

func ScanInlinePPtrs(raw string, onPPtr func(fileID int64, guid string, hasGUID bool))

ScanInlinePPtrs scans raw Unity YAML text for every balanced inline brace group `{...}` that carries a top-level `fileID` key, reporting each fileID and the group's optional guid via onPPtr. It reads the actual braces in the raw bytes, so — unlike a walk of the parsed field tree — it is independent of how the line/value parser happened to structure (or mangle) a PPtr. It is brace-depth aware (a PPtr with a nested sub-mapping, or a PPtr nested inside another flow map, is handled), spans newlines (multiline-flow list items), and unquotes 'single'/"double" keys and values. Block-style PPtrs (no braces) have no brace group and are NOT reported here; recover those from the parsed tree.

It intentionally does NOT track quote state. YAML quoting is positional (a quote opens a scalar only at a value start), but a plain unquoted scalar can contain a literal apostrophe or quote (m_Name: Player's Gun) — tracking quote state on every ' / " byte would flip into a phantom "inside a string" mode and stop matching braces, silently dropping later PPtrs. Pure brace matching can only OVER-detect (a `{fileID: N}` literally inside a quoted string — which Unity never emits), never miss a real PPtr, so it is the safe choice for a scanner whose job is to never silently report "no refs".

Types

type Block

type Block struct {
	ClassID    int
	FileID     int64
	TypeName   string
	Fields     map[string]any
	RawBody    string
	StartLine  int
	EndLine    int
	IsStripped bool
}

func Parse

func Parse(data []byte) ([]Block, error)

func ParseFile

func ParseFile(path string) ([]Block, error)

Jump to

Keyboard shortcuts

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