parser

package
Version: v0.0.0-...-0469269 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	KEYWORD_ALLOC    string = "alloc"
	KEYWORD_AS       string = "as"
	KEYWORD_BREAK    string = "break"
	KEYWORD_CONTINUE string = "continue"
	KEYWORD_ELSE     string = "else"
	KEYWORD_ENUM     string = "enum"
	KEYWORD_EXT      string = "ext"
	KEYWORD_FOR      string = "for"
	KEYWORD_FREE     string = "free"
	KEYWORD_FUNC     string = "func"
	KEYWORD_IF       string = "if"
	KEYWORD_IMPL     string = "impl"
	KEYWORD_MATCH    string = "match"
	KEYWORD_MUT      string = "mut"
	KEYWORD_RETURN   string = "return"
	KEYWORD_SET      string = "set"
	KEYWORD_SIZEOF   string = "sizeof"
	KEYWORD_STRUCT   string = "struct"
	KEYWORD_USE      string = "use"
	KEYWORD_VOID     string = "void"
)
View Source
const (
	SIMPLE_ESCAPE_VALUES string = "\a\b\f\n\r\t\v\\'\""
	SIMPLE_ESCAPE_NAMES  string = "abfnrtv\\'\""
)

Variables

This section is empty.

Functions

func EscapeString

func EscapeString(s string) string

escape for debug output only things that can't be displayed need to be escaped

func UnescapeString

func UnescapeString(s string) string

Types

type AccessExpr

type AccessExpr struct {
	StructVariables []*Variable
	Variable        *Variable
	// contains filtered or unexported fields
}

func (*AccessExpr) GetType

func (v *AccessExpr) GetType() Type

func (*AccessExpr) NodeName

func (v *AccessExpr) NodeName() string

func (AccessExpr) Pos

func (v AccessExpr) Pos() (line, char int)

func (*AccessExpr) String

func (v *AccessExpr) String() string

type AssignStat

type AssignStat struct {
	Deref      *DerefExpr // one of these should be nil, not neither or both
	Access     *AccessExpr
	Assignment Expr
	// contains filtered or unexported fields
}

func (*AssignStat) NodeName

func (v *AssignStat) NodeName() string

func (AssignStat) Pos

func (v AssignStat) Pos() (line, char int)

func (*AssignStat) String

func (v *AssignStat) String() string

type Attr

type Attr struct {
	Key   string
	Value string
	// contains filtered or unexported fields
}

func (*Attr) Pos

func (v *Attr) Pos() (line, char int)

func (*Attr) String

func (v *Attr) String() string

type BinOpType

type BinOpType int
const (
	BINOP_ERR BinOpType = iota

	BINOP_ADD
	BINOP_SUB
	BINOP_MUL
	BINOP_DIV
	BINOP_MOD

	BINOP_GREATER
	BINOP_LESS
	BINOP_GREATER_EQ
	BINOP_LESS_EQ
	BINOP_EQ
	BINOP_NOT_EQ

	BINOP_BIT_AND
	BINOP_BIT_OR
	BINOP_BIT_XOR
	BINOP_BIT_LEFT
	BINOP_BIT_RIGHT

	BINOP_LOG_AND
	BINOP_LOG_OR
)

func (BinOpType) Category

func (v BinOpType) Category() OpCategory

func (BinOpType) OpString

func (v BinOpType) OpString() string

func (BinOpType) String

func (i BinOpType) String() string

type BinaryExpr

type BinaryExpr struct {
	Lhand, Rhand Expr
	Op           BinOpType
	Type         Type
	// contains filtered or unexported fields
}

func (*BinaryExpr) GetType

func (v *BinaryExpr) GetType() Type

func (*BinaryExpr) NodeName

func (v *BinaryExpr) NodeName() string

func (BinaryExpr) Pos

func (v BinaryExpr) Pos() (line, char int)

func (*BinaryExpr) String

func (v *BinaryExpr) String() string

type Block

type Block struct {
	Nodes []Node
	// contains filtered or unexported fields
}

func (*Block) NodeName

func (v *Block) NodeName() string

func (Block) Pos

func (v Block) Pos() (line, char int)

func (*Block) String

func (v *Block) String() string

type BracketExpr

type BracketExpr struct {
	Expr Expr
	// contains filtered or unexported fields
}

func (*BracketExpr) GetType

func (v *BracketExpr) GetType() Type

func (*BracketExpr) NodeName

func (v *BracketExpr) NodeName() string

func (BracketExpr) Pos

func (v BracketExpr) Pos() (line, char int)

func (*BracketExpr) String

func (v *BracketExpr) String() string

type CallExpr

type CallExpr struct {
	Function  *Function
	Arguments []Expr
	// contains filtered or unexported fields
}

func (*CallExpr) GetType

func (v *CallExpr) GetType() Type

func (*CallExpr) NodeName

func (v *CallExpr) NodeName() string

func (CallExpr) Pos

func (v CallExpr) Pos() (line, char int)

func (*CallExpr) String

func (v *CallExpr) String() string

type CallStat

type CallStat struct {
	Call *CallExpr
	// contains filtered or unexported fields
}

func (*CallStat) NodeName

func (v *CallStat) NodeName() string

func (CallStat) Pos

func (v CallStat) Pos() (line, char int)

func (*CallStat) String

func (v *CallStat) String() string

type CastExpr

type CastExpr struct {
	Expr Expr
	Type Type
	// contains filtered or unexported fields
}

func (*CastExpr) GetType

func (v *CastExpr) GetType() Type

func (*CastExpr) NodeName

func (v *CastExpr) NodeName() string

func (CastExpr) Pos

func (v CastExpr) Pos() (line, char int)

func (*CastExpr) String

func (v *CastExpr) String() string

type Decl

type Decl interface {
	Node

	DocComments() []*DocComment
	// contains filtered or unexported methods
}

type DerefExpr

type DerefExpr struct {
	Expr Expr
	Type Type
	// contains filtered or unexported fields
}

func (*DerefExpr) GetType

func (v *DerefExpr) GetType() Type

func (*DerefExpr) NodeName

func (v *DerefExpr) NodeName() string

func (DerefExpr) Pos

func (v DerefExpr) Pos() (line, char int)

func (*DerefExpr) String

func (v *DerefExpr) String() string

type DocComment

type DocComment struct {
	Contents           string
	StartLine, EndLine int
}

type Expr

type Expr interface {
	Node

	GetType() Type
	// contains filtered or unexported methods
}

type File

type File struct {
	Nodes  []Node
	Name   string
	Module llvm.Module
}

func Parse

func Parse(input *common.Sourcefile, verbose bool) *File

type FloatingLiteral

type FloatingLiteral struct {
	Value float64
	Type  Type
	// contains filtered or unexported fields
}

func (*FloatingLiteral) GetType

func (v *FloatingLiteral) GetType() Type

func (*FloatingLiteral) NodeName

func (v *FloatingLiteral) NodeName() string

func (FloatingLiteral) Pos

func (v FloatingLiteral) Pos() (line, char int)

func (*FloatingLiteral) String

func (v *FloatingLiteral) String() string

type Function

type Function struct {
	Name       string
	Parameters []*VariableDecl
	ReturnType Type
	Mutable    bool
	Attrs      []*Attr
	Body       *Block
	// contains filtered or unexported fields
}

func (*Function) MangledName

func (v *Function) MangledName(typ MangleType) string

func (*Function) Scope

func (v *Function) Scope() *Scope

func (*Function) String

func (v *Function) String() string

type FunctionDecl

type FunctionDecl struct {
	Function *Function
	// contains filtered or unexported fields
}

func (*FunctionDecl) DocComments

func (v *FunctionDecl) DocComments() []*DocComment

func (*FunctionDecl) NodeName

func (v *FunctionDecl) NodeName() string

func (FunctionDecl) Pos

func (v FunctionDecl) Pos() (line, char int)

func (*FunctionDecl) String

func (v *FunctionDecl) String() string

type IfStat

type IfStat struct {
	Exprs  []Expr
	Bodies []*Block
	Else   *Block // can be nil
	// contains filtered or unexported fields
}

func (*IfStat) NodeName

func (v *IfStat) NodeName() string

func (IfStat) Pos

func (v IfStat) Pos() (line, char int)

func (*IfStat) String

func (v *IfStat) String() string

type IntegerLiteral

type IntegerLiteral struct {
	Value uint64
	Type  Type
	// contains filtered or unexported fields
}

func (*IntegerLiteral) GetType

func (v *IntegerLiteral) GetType() Type

func (*IntegerLiteral) NodeName

func (v *IntegerLiteral) NodeName() string

func (IntegerLiteral) Pos

func (v IntegerLiteral) Pos() (line, char int)

func (*IntegerLiteral) String

func (v *IntegerLiteral) String() string

type Locatable

type Locatable interface {
	Pos() (line, char int)
	// contains filtered or unexported methods
}

type LoopStat

type LoopStat struct {
	LoopType LoopStatType

	Body *Block

	// LOOP_TYPE_CONDITIONAL
	Condition Expr
	// contains filtered or unexported fields
}

func (*LoopStat) NodeName

func (v *LoopStat) NodeName() string

func (LoopStat) Pos

func (v LoopStat) Pos() (line, char int)

func (*LoopStat) String

func (v *LoopStat) String() string

type LoopStatType

type LoopStatType int
const (
	LOOP_TYPE_UNSET LoopStatType = iota
	LOOP_TYPE_INFINITE
	LOOP_TYPE_CONDITIONAL
)

type MangleType

type MangleType int

In case we support multiple name mangline schemes

const (
	MANGLE_ARK_UNSTABLE MangleType = iota // see https://github.com/ark-lang/ark/issues/401
)

type Node

type Node interface {
	String() string
	NodeName() string

	Locatable
	// contains filtered or unexported methods
}

type OpCategory

type OpCategory int
const (
	OP_ARITHMETIC OpCategory = iota
	OP_COMPARISON
	OP_BITWISE
	OP_LOGICAL
	OP_ASSIGN
)

func (OpCategory) PrettyString

func (v OpCategory) PrettyString() string

type PointerType

type PointerType struct {
	Addressee Type
}

func (PointerType) Attrs

func (v PointerType) Attrs() []*Attr

func (PointerType) CanCastTo

func (v PointerType) CanCastTo(t Type) bool

func (PointerType) IsFloatingType

func (v PointerType) IsFloatingType() bool

func (PointerType) IsIntegerType

func (v PointerType) IsIntegerType() bool

func (PointerType) LevelsOfIndirection

func (v PointerType) LevelsOfIndirection() int

func (PointerType) RawType

func (v PointerType) RawType() Type

func (PointerType) TypeName

func (v PointerType) TypeName() string

type PrimitiveType

type PrimitiveType int
const (
	PRIMITIVE_i8 PrimitiveType = iota
	PRIMITIVE_i16
	PRIMITIVE_i32
	PRIMITIVE_i64
	PRIMITIVE_i128

	PRIMITIVE_u8
	PRIMITIVE_u16
	PRIMITIVE_u32
	PRIMITIVE_u64
	PRIMITIVE_u128

	PRIMITIVE_f32
	PRIMITIVE_f64
	PRIMITIVE_f128

	PRIMITIVE_str
	PRIMITIVE_rune

	PRIMITIVE_int
	PRIMITIVE_uint

	PRIMITIVE_bool
)

func (PrimitiveType) Attrs

func (v PrimitiveType) Attrs() []*Attr

func (PrimitiveType) CanCastTo

func (v PrimitiveType) CanCastTo(t Type) bool

func (PrimitiveType) IsFloatingType

func (v PrimitiveType) IsFloatingType() bool

func (PrimitiveType) IsIntegerType

func (v PrimitiveType) IsIntegerType() bool

func (PrimitiveType) LevelsOfIndirection

func (v PrimitiveType) LevelsOfIndirection() int

func (PrimitiveType) RawType

func (v PrimitiveType) RawType() Type

func (PrimitiveType) String

func (i PrimitiveType) String() string

func (PrimitiveType) TypeName

func (v PrimitiveType) TypeName() string

type ReturnStat

type ReturnStat struct {
	Value Expr
	// contains filtered or unexported fields
}

func (*ReturnStat) NodeName

func (v *ReturnStat) NodeName() string

func (ReturnStat) Pos

func (v ReturnStat) Pos() (line, char int)

func (*ReturnStat) String

func (v *ReturnStat) String() string

type RuneLiteral

type RuneLiteral struct {
	Value rune
	// contains filtered or unexported fields
}

func (*RuneLiteral) GetType

func (v *RuneLiteral) GetType() Type

func (*RuneLiteral) NodeName

func (v *RuneLiteral) NodeName() string

func (RuneLiteral) Pos

func (v RuneLiteral) Pos() (line, char int)

func (*RuneLiteral) String

func (v *RuneLiteral) String() string

type Scope

type Scope struct {
	Outer *Scope
	Vars  map[string]*Variable
	Types map[string]Type
	Funcs map[string]*Function
}

func (*Scope) GetFunction

func (v *Scope) GetFunction(name string) *Function

func (*Scope) GetType

func (v *Scope) GetType(name string) Type

func (*Scope) GetVariable

func (v *Scope) GetVariable(name string) *Variable

func (*Scope) InsertFunction

func (v *Scope) InsertFunction(t *Function) *Function

func (*Scope) InsertType

func (v *Scope) InsertType(t Type) Type

func (*Scope) InsertVariable

func (v *Scope) InsertVariable(t *Variable) *Variable

func (*Scope) IsGlobal

func (v *Scope) IsGlobal() bool

type Stat

type Stat interface {
	Node
	// contains filtered or unexported methods
}

type StringLiteral

type StringLiteral struct {
	Value  string
	StrLen int
	// contains filtered or unexported fields
}

func (*StringLiteral) GetType

func (v *StringLiteral) GetType() Type

func (*StringLiteral) NodeName

func (v *StringLiteral) NodeName() string

func (StringLiteral) Pos

func (v StringLiteral) Pos() (line, char int)

func (*StringLiteral) String

func (v *StringLiteral) String() string

type StructDecl

type StructDecl struct {
	Struct *StructType
	// contains filtered or unexported fields
}

func (*StructDecl) DocComments

func (v *StructDecl) DocComments() []*DocComment

func (*StructDecl) NodeName

func (v *StructDecl) NodeName() string

func (StructDecl) Pos

func (v StructDecl) Pos() (line, char int)

func (*StructDecl) String

func (v *StructDecl) String() string

type StructType

type StructType struct {
	Name      string
	Variables []*VariableDecl
	// contains filtered or unexported fields
}

func (*StructType) Attrs

func (v *StructType) Attrs() []*Attr

func (*StructType) CanCastTo

func (v *StructType) CanCastTo(t Type) bool

func (*StructType) IsFloatingType

func (v *StructType) IsFloatingType() bool

func (*StructType) IsIntegerType

func (v *StructType) IsIntegerType() bool

func (*StructType) LevelsOfIndirection

func (v *StructType) LevelsOfIndirection() int

func (*StructType) MangledName

func (v *StructType) MangledName(typ MangleType) string

func (*StructType) RawType

func (v *StructType) RawType() Type

func (*StructType) String

func (v *StructType) String() string

func (*StructType) TypeName

func (v *StructType) TypeName() string

type Type

type Type interface {
	TypeName() string
	RawType() Type            // type disregarding pointers
	LevelsOfIndirection() int // number of pointers you have to go through to get to the actual type
	IsIntegerType() bool
	IsFloatingType() bool
	CanCastTo(Type) bool
	Attrs() []*Attr
}

type UnOpType

type UnOpType int
const (
	UNOP_ERR UnOpType = iota

	UNOP_LOG_NOT

	UNOP_BIT_NOT

	UNOP_ADDRESS
)

func (UnOpType) OpString

func (v UnOpType) OpString() string

func (UnOpType) String

func (i UnOpType) String() string

type UnaryExpr

type UnaryExpr struct {
	Expr Expr
	Op   UnOpType
	Type Type
	// contains filtered or unexported fields
}

func (*UnaryExpr) GetType

func (v *UnaryExpr) GetType() Type

func (*UnaryExpr) NodeName

func (v *UnaryExpr) NodeName() string

func (UnaryExpr) Pos

func (v UnaryExpr) Pos() (line, char int)

func (*UnaryExpr) String

func (v *UnaryExpr) String() string

type Variable

type Variable struct {
	Type    Type
	Name    string
	Mutable bool
	Attrs   []*Attr

	ParentStruct *StructType
	// contains filtered or unexported fields
}

func (*Variable) MangledName

func (v *Variable) MangledName(typ MangleType) string

func (*Variable) Scope

func (v *Variable) Scope() *Scope

func (*Variable) String

func (v *Variable) String() string

type VariableDecl

type VariableDecl struct {
	Variable   *Variable
	Assignment Expr
	// contains filtered or unexported fields
}

func (*VariableDecl) DocComments

func (v *VariableDecl) DocComments() []*DocComment

func (*VariableDecl) NodeName

func (v *VariableDecl) NodeName() string

func (VariableDecl) Pos

func (v VariableDecl) Pos() (line, char int)

func (*VariableDecl) String

func (v *VariableDecl) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL