parser

package
v0.0.0-...-1b8cbf5 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package parser defines a Papyrus parser.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(file *source.File, log *issue.Log, opts ...Option) (script *ast.Script, ok bool)

Parse returns the file parsed as an *ast.Script or false if parsing failed. If this returns false, the log is guarnteed to contain at least one issue.

Types

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option defines an option to configure how parsing is performed.

func WithComments

func WithComments(enabled bool) Option

WithComments controls block and line (i.e. loose) comment processing.

If enabled, loose comments will be attached to the appropriate nodes and/or appear as ast.CommentStatement nodes. This is only required when the nodes may need to be written back out as source, e.g. when formatting.

func WithRecovery

func WithRecovery(enabled bool) Option

WithRecovery controls parsing should attempt error recovery and potentially include ast.Error nodes in the resulting AST.

If enabled, the parser will attempt error recovery if an issue is found and instead of immediately failing, it will try to emit an error node instead. It is the responsibility of the caller to check for the presensce of ast.Error nodes.

Enabling this does not guarantee that parsing will never fail with an [Error].

Jump to

Keyboard shortcuts

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