parse

package
v0.0.0-...-c8d5561 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2014 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ERROR = 0xffff + iota
	EOF
	FOR
	PACKAGE
	IMPORT
	FUNC
	RETURN
	STRUCT
	CONSTANT
	STRING
	IDENTIFIER
	VAR
	CONST
	ELLIPSIS
	TYPE
	IF
	BREAK
	CONTINUE
	ELSE
	NEQ
	EQ
	LTEQ
	GTEQ
	INC
	DEC
	ADDASSIGN
	ANDASSIGN
	SUBASSIGN
	XORASSIGN
	MULASSIGN
	ORASSIGN
	AND
	ANDNOT
	OR
	LSHIFT
	RSHIFT
)

Variables

This section is empty.

Functions

func DebugDump

func DebugDump(w io.Writer, n Node)

func Lex

func Lex(path string, r io.Reader) (<-chan *Token, chan<- struct{})

Lexers the reader in a goroutine. The goroutine must be read until completion or error. The Error token is returned on lex error. returns a token channel, and a cancel channel.

Types

type ArrayOf

type ArrayOf struct {
	SpanProvider
	Dim     uint
	SubType Node
}

type Assign

type Assign struct {
	SpanProvider
	Op   TokenKind
	L, R Node
}

type Binop

type Binop struct {
	SpanProvider
	Op   TokenKind
	L, R Node
}

type Call

type Call struct {
	SpanProvider
	FuncLike Node
	Args     []Node
}

type ConstDecl

type ConstDecl struct {
	SpanProvider
	Name string
	Body Node
}

type Constant

type Constant struct {
	SpanProvider
	Val int64
}

type EmptyStatement

type EmptyStatement struct {
	SpanProvider
}

type ExpressionStatement

type ExpressionStatement struct {
	SpanProvider
	Expr Node
}

type File

type File struct {
	SpanProvider
	Pkg string
	//List of imports in the translation unit.
	Imports    []*String
	FuncDecls  []*FuncDecl
	TypeDecls  []*TypeDecl
	ConstDecls []*ConstDecl
	VarDecls   []*VarDecl
}

func Parse

func Parse(c <-chan *Token) (*File, error)

type FilePos

type FilePos struct {
	// Line number starting at one.
	Line int
	// Col starting at one.
	Col int
}

Represents a single point in the file as shown in most text editors. Tabs are treated as being aligned to 4 places.

func (FilePos) String

func (p FilePos) String() string

type FileSpan

type FileSpan struct {
	//Path
	Path  string
	Start FilePos
	End   FilePos
}

A span across two points.

type For

type For struct {
	SpanProvider
	Init, Cond, Step Node
	Body             []Node
}

type FuncDecl

type FuncDecl struct {
	SpanProvider
	Name    string
	RetType Node

	ArgNames []string
	ArgTypes []Node
	Body     []Node
	// contains filtered or unexported fields
}

type Ident

type Ident struct {
	SpanProvider
	Val string
}

type If

type If struct {
	SpanProvider
	Cond Node
	Body []Node
	Els  []Node
}

type IndexInto

type IndexInto struct {
	SpanProvider
	Index Node
	Expr  Node
}

type Initializer

type Initializer struct {
	SpanProvider
	Sub []Node
}

type Node

type Node interface {
	GetSpan() FileSpan
}

type PointerTo

type PointerTo struct {
	SpanProvider
	PointsTo Node
}

type Return

type Return struct {
	SpanProvider
	Expr Node
}

type Selector

type Selector struct {
	SpanProvider
	Name string
	Expr Node
}

type SpanProvider

type SpanProvider struct {
	// The file span of the token.
	Span FileSpan
}

func (*SpanProvider) GetSpan

func (s *SpanProvider) GetSpan() FileSpan

type String

type String struct {
	SpanProvider
	Val string
}

type Struct

type Struct struct {
	SpanProvider
	Names []string
	Types []Node
}

type Token

type Token struct {
	// Tag for the token kind.
	Kind TokenKind
	// The raw contents of the token.
	Val string
	// The file span of the token.
	Span FileSpan
}

The type representing a G lexical token.

type TokenKind

type TokenKind int

func (TokenKind) String

func (k TokenKind) String() string

type TypeDecl

type TypeDecl struct {
	SpanProvider
	Name string
	Type Node
}

type Unop

type Unop struct {
	SpanProvider
	Op   TokenKind
	Expr Node
}

type VarDecl

type VarDecl struct {
	SpanProvider
	Name string
	Type Node
	Init *Assign
}

Jump to

Keyboard shortcuts

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