syntax

package
v0.0.0-...-d472ff9 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2018 License: BSD-2-Clause Imports: 5 Imported by: 6

Documentation

Overview

Package syntax defines an Abstract Syntax Tree, an AST, for Neugram.

Nodes in the AST are represented by Node objects. The particular nodes for expressions, statements, and types are defined in the respective packages:

syntax/expr
syntax/stmt
syntax/tipe

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cursor

type Cursor struct {
	Node   Node   // the current Node
	Parent Node   // the parent of the current Node
	Name   string // name of the parent field containing the current Node
	// contains filtered or unexported fields
}

A Cursor describes a Node during a syntax tree traversal.

type File

type File struct {
	Filename string
	Stmts    []stmt.Stmt
}

File is the syntax tree of a Neugram file.

func (File) Pos

func (f File) Pos() src.Pos

type Node

type Node interface {
	Pos() src.Pos
}

A Node is a node in the syntax tree.

func Walk

func Walk(root Node, preFn, postFn WalkFunc) (result Node)

Walk traverses a syntax tree, calling preFn and postFn for each node.

If a preFn is provided it is called for each node before its children are traversed. If preFn returns false no children are traversed.

If a postFn is provided it is called for each node after its children are traversed. TODO: If a postFn returns false traversal ends.

type WalkFunc

type WalkFunc func(*Cursor) bool

A WalkFunc is invoked by Walk when traversing nodes in a syntax tree.

The return value determines how traversal will proceed, it is described in detail in the Walk function documentation.

Directories

Path Synopsis
Package expr defines data structures representing Neugram expressions.
Package expr defines data structures representing Neugram expressions.
Package src provides source code position tracking.
Package src provides source code position tracking.
Package stmt defines data structures representing Neugram statements.
Package stmt defines data structures representing Neugram statements.
Package tipe defines data structures representing Neugram types.
Package tipe defines data structures representing Neugram types.
Package token defines data structures representing Neugram tokens.
Package token defines data structures representing Neugram tokens.

Jump to

Keyboard shortcuts

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