parse

package
v0.0.0-...-8573055 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2014 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsExpr

func IsExpr(n Node) bool

func IsStatement

func IsStatement(n Node) bool

func NewLexError

func NewLexError(pos scanner.Position, msg string) error

func NewParseError

func NewParseError(tok Token, msg string) error

func NewSemanticError

func NewSemanticError(node Node, msg string) error

Types

type ArrayAccessNode

type ArrayAccessNode struct {
	Array Node
	Index Node
}

func (ArrayAccessNode) String

func (a ArrayAccessNode) String() string

type BinaryNode

type BinaryNode struct {
	Left  Node
	Oper  string
	Right Node
}

func (BinaryNode) String

func (b BinaryNode) String() string

func (BinaryNode) StringWithPrecedence

func (b BinaryNode) StringWithPrecedence() string

Use parens to make precedence more apparent

type BlockNode

type BlockNode struct {
	Nodes []Node
}

'{' node* '}'

func (BlockNode) String

func (b BlockNode) String() string

type BreakNode

type BreakNode struct{}

func (BreakNode) String

func (b BreakNode) String() string

type CaseNode

type CaseNode struct {
	Cond       Node
	Statements []Node
}

func (CaseNode) String

func (c CaseNode) String() string

type CharacterNode

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

func (CharacterNode) String

func (c CharacterNode) String() string

type ExternVarDeclNode

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

func (ExternVarDeclNode) String

func (e ExternVarDeclNode) String() string

type ExternVarInitNode

type ExternVarInitNode struct {
	Name  string
	Value Node
}

name value ';'

func (ExternVarInitNode) String

func (e ExternVarInitNode) String() string

type ExternVecInitNode

type ExternVecInitNode struct {
	Name   string
	Size   int
	Values []Node
}

name '[' size ']' value+ ';'

func (ExternVecInitNode) String

func (e ExternVecInitNode) String() string

type FunctionCallNode

type FunctionCallNode struct {
	Callable Node
	Args     []Node
}

func (FunctionCallNode) String

func (f FunctionCallNode) String() string

type FunctionNode

type FunctionNode struct {
	Name   string
	Params []string
	Body   Node
}

name '(' (var (',' var)*) ? ')' block

func (FunctionNode) String

func (f FunctionNode) String() string

type GotoNode

type GotoNode struct{ Label string }

func (GotoNode) String

func (g GotoNode) String() string

type IdentNode

type IdentNode struct {
	Value string
}

func (IdentNode) String

func (i IdentNode) String() string

type IfNode

type IfNode struct {
	Cond     Node
	Body     Node
	HasElse  bool
	ElseBody Node
}

func (IfNode) String

func (i IfNode) String() string

type IntegerNode

type IntegerNode struct {
	Value int
}

func (IntegerNode) String

func (i IntegerNode) String() string

type LabelNode

type LabelNode struct{ Name string }

func (LabelNode) String

func (l LabelNode) String() string

type LexError

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

func (*LexError) Error

func (l *LexError) Error() string

type Lexer

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

func NewLexer

func NewLexer(name string, input io.Reader) *Lexer

func (*Lexer) NextToken

func (lex *Lexer) NextToken() (Token, error)

func (*Lexer) PeekToken

func (lex *Lexer) PeekToken() (Token, error)

type Node

type Node interface {
	String() string
}

type NullNode

type NullNode struct{}

func (NullNode) String

func (n NullNode) String() string

type OperatorBinding

type OperatorBinding int

func OperatorPrecedence

func OperatorPrecedence(op string) (prec int, bind OperatorBinding)

type ParenNode

type ParenNode struct{ Node Node }

func (ParenNode) String

func (p ParenNode) String() string

type ParseError

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

func (*ParseError) Error

func (p *ParseError) Error() string

type Parser

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

func NewParser

func NewParser(name string, input io.Reader) *Parser

func (*Parser) Parse

func (p *Parser) Parse() (unit TranslationUnit, err error)

type ReturnNode

type ReturnNode struct{ Node Node }

func (ReturnNode) String

func (r ReturnNode) String() string

type SemanticError

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

func (*SemanticError) Error

func (s *SemanticError) Error() string

type StatementNode

type StatementNode struct {
	Expr Node
}

func (StatementNode) String

func (s StatementNode) String() string

type StringNode

type StringNode struct {
	Value string
}

func (StringNode) String

func (s StringNode) String() string

type SwitchNode

type SwitchNode struct {
	Cond        Node
	DefaultCase []Node
	Cases       []CaseNode
}

func (SwitchNode) String

func (s SwitchNode) String() string

type TernaryNode

type TernaryNode struct {
	Cond      Node
	TrueBody  Node
	FalseBody Node
}

Yes, I know "ternary" is no more descriptive than binary op, but there's only one.

func (TernaryNode) String

func (t TernaryNode) String() string

type Token

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

func (*Token) Error

func (t *Token) Error() Token

func (Token) String

func (t Token) String() string

type TokenType

type TokenType int

func (TokenType) String

func (t TokenType) String() string

type TranslationUnit

type TranslationUnit struct {
	File  string
	Funcs []FunctionNode
	Vars  []Node
}

func (TranslationUnit) ResolveDuplicates

func (t TranslationUnit) ResolveDuplicates() error

TODO: resolve auto variable declarations within function definitions

func (TranslationUnit) ResolveLabels

func (t TranslationUnit) ResolveLabels(fn FunctionNode) error

Make sure all goto jump to valid places

func (TranslationUnit) String

func (t TranslationUnit) String() string

func (TranslationUnit) Verify

func (t TranslationUnit) Verify() error

func (TranslationUnit) VerifyAssignments

func (t TranslationUnit) VerifyAssignments(fn FunctionNode) error

Verify that all assignments have a proper LHS and RHS

func (TranslationUnit) VerifyFunction

func (t TranslationUnit) VerifyFunction(fn FunctionNode) error

type UnaryNode

type UnaryNode struct {
	Oper    string
	Node    Node
	Postfix bool
}

func (UnaryNode) String

func (u UnaryNode) String() string

type VarDecl

type VarDecl struct {
	Name    string
	VecDecl bool
	Size    int
}

type VarDeclNode

type VarDeclNode struct {
	Vars []VarDecl
}

func (VarDeclNode) String

func (v VarDeclNode) String() string

type WhileNode

type WhileNode struct {
	Cond Node
	Body Node
}

func (WhileNode) String

func (w WhileNode) String() string

Jump to

Keyboard shortcuts

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