Documentation ¶
Overview ¶
Copyright 2013 Benjamin Gentil. All rights reserved. license can be found in the LICENSE file (MIT License)
Copyright 2013 Benjamin Gentil. All rights reserved. license can be found in the LICENSE file (MIT License)
Copyright 2013 Benjamin Gentil. All rights reserved. license can be found in the LICENSE file (MIT License)
Copyright 2013 Benjamin Gentil. All rights reserved. license can be found in the LICENSE file (MIT License)
Copyright 2013 Benjamin Gentil. All rights reserved. license can be found in the LICENSE file (MIT License)
Copyright 2013 Benjamin Gentil. All rights reserved. license can be found in the LICENSE file (MIT License)
Copyright 2013 Benjamin Gentil. All rights reserved. license can be found in the LICENSE file (MIT License)
Copyright 2013 Benjamin Gentil. All rights reserved. license can be found in the LICENSE file (MIT License)
Index ¶
- Constants
- Variables
- func Debug(f string, v ...interface{})
- func DebugDump(v *llvm.Value)
- func DebugDumpMod(m *llvm.Module)
- func DisableColor()
- func DisableDebug()
- func EnableColor()
- func EnableDebug()
- func Error(f string, v ...interface{})
- func Errorln(f string, v ...interface{})
- func JNil(s string) string
- func LLVMType(name string) llvm.Type
- func RegisterType(name string, t llvm.Type)
- func ZlangType(t llvm.Type) string
- type ContextValue
- type LexItem
- type Lexer
- type Node
- type NodeArray
- type NodeAssignement
- type NodeBinOperator
- type NodeBlock
- type NodeBool
- type NodeBreak
- type NodeByte
- type NodeCall
- type NodeExpr
- type NodeExpression
- type NodeFloat
- type NodeFunction
- type NodeIdentifier
- type NodeIf
- type NodeInteger
- type NodePrototype
- type NodeReturn
- type NodeStmt
- type NodeString
- type NodeVariable
- type NodeWhile
- type Parser
- type Position
- type Token
Constants ¶
const ( LeftBlockDelim = '{' RightBlockDelim = '}' LeftParentDelim = '(' RightParentDelim = ')' ParamDelim = ',' StringDelim = '"' EscapeCar = '\\' Comment = "//" LeftBlockComment = "/*" RightBlockComment = "*/" )
const ( POINTER_CHAR = '@' TYPE_BOOL = "bool" TYPE_BYTE = "byte" TYPE_INT = "int" TYPE_INT32 = "int32" TYPE_INT64 = "int64" TYPE_FLOAT = "float" TYPE_FLOAT32 = "float32" TYPE_FLOAT64 = "float64" TYPE_STRING = "string" TYPE_STRUCT = "struct" )
const ( ResetCode = "\033[0m" // reset color RedCode = "\033[31m" GreenCode = "\033[32m" YellowCode = "\033[33m" )
Variables ¶
var DEBUG = false
Functions ¶
func DebugDumpMod ¶
func DisableColor ¶
func DisableColor()
func DisableDebug ¶
func DisableDebug()
func EnableColor ¶
func EnableColor()
func EnableDebug ¶
func EnableDebug()
func JNil ¶
replace <nil> by null to have valid JSON fix also array prepresentation by separating object with , instead of space
func RegisterType ¶
Types ¶
type ContextValue ¶
type Lexer ¶
type Lexer struct {
// contains filtered or unexported fields
}
lexer holds the state of the scanner.
type NodeArray ¶
******************************************** Expressions ********************************************
type NodeAssignement ¶
type NodeAssignement struct { Node NodeExpr LHS *NodeIdentifier RHS NodeExpr }
******************************************** Expressions ********************************************
func NAssignement ¶
func NAssignement(lhs *NodeIdentifier, rhs NodeExpr) *NodeAssignement
func (*NodeAssignement) String ¶
func (n *NodeAssignement) String() string
type NodeBinOperator ¶
******************************************** Expressions ********************************************
func NBinOp ¶
func NBinOp(operator string, lhs, rhs NodeExpr) *NodeBinOperator
func (*NodeBinOperator) String ¶
func (n *NodeBinOperator) String() string
type NodeBlock ¶
******************************************** Expressions ********************************************
type NodeBool ¶
******************************************** Expressions ********************************************
type NodeBreak ¶
******************************************** Statements ********************************************
type NodeByte ¶
******************************************** Expressions ********************************************
type NodeCall ¶
type NodeCall struct { Node NodeExpr Name *NodeIdentifier Args []NodeExpr }
******************************************** Expressions ********************************************
func NCall ¶
func NCall(name *NodeIdentifier, args []NodeExpr) *NodeCall
type NodeExpr ¶
type NodeExpr interface { Node // contains filtered or unexported methods }
******************************************** Expressions ********************************************
type NodeExpression ¶
******************************************** Statements ********************************************
func NExpression ¶
func NExpression(exp NodeExpr) *NodeExpression
func (*NodeExpression) String ¶
func (n *NodeExpression) String() string
type NodeFloat ¶
******************************************** Expressions ********************************************
type NodeFunction ¶
type NodeFunction struct { Node NodeStmt Proto *NodePrototype Body *NodeBlock }
******************************************** Statements ********************************************
func NFunction ¶
func NFunction(proto *NodePrototype, body *NodeBlock) *NodeFunction
func (*NodeFunction) String ¶
func (n *NodeFunction) String() string
type NodeIdentifier ¶
******************************************** Expressions ********************************************
func NIdentifier ¶
func NIdentifier(value string, keys []NodeExpr) *NodeIdentifier
func (*NodeIdentifier) String ¶
func (n *NodeIdentifier) String() string
type NodeIf ¶
type NodeIf struct { Node NodeStmt Condition NodeExpr Body *NodeBlock Elif []*NodeBlock // TODO: support for else if Else *NodeBlock }
******************************************** Statements ********************************************
type NodeInteger ¶
******************************************** Expressions ********************************************
func NInteger ¶
func NInteger(value string) *NodeInteger
func (*NodeInteger) String ¶
func (n *NodeInteger) String() string
type NodePrototype ¶
type NodePrototype struct { Node NodeStmt Type *NodeIdentifier Name *NodeIdentifier Args []*NodeVariable }
******************************************** Statements ********************************************
func NPrototype ¶
func NPrototype(name, typ *NodeIdentifier, args []*NodeVariable) *NodePrototype
Make nodes creation easier
func (*NodePrototype) String ¶
func (n *NodePrototype) String() string
type NodeReturn ¶
******************************************** Statements ********************************************
func NReturn ¶
func NReturn(exp NodeExpr) *NodeReturn
func (*NodeReturn) String ¶
func (n *NodeReturn) String() string
type NodeStmt ¶
******************************************** Statements ********************************************
type NodeString ¶
******************************************** Expressions ********************************************
func NString ¶
func NString(value string) *NodeString
func (*NodeString) String ¶
func (n *NodeString) String() string
type NodeVariable ¶
type NodeVariable struct { Node NodeStmt Type *NodeIdentifier Name *NodeIdentifier AssignExpr *NodeAssignement }
******************************************** Statements ********************************************
func NVariable ¶
func NVariable(name, typ *NodeIdentifier, assign *NodeAssignement) *NodeVariable
func (*NodeVariable) String ¶
func (n *NodeVariable) String() string
type NodeWhile ¶
******************************************** Statements ********************************************
type Parser ¶
type Parser struct { Input string Module llvm.Module Builder llvm.Builder // contains filtered or unexported fields }
func (*Parser) DepthIndent ¶
func (*Parser) RaiseError ¶
type Position ¶
type Position struct {
// contains filtered or unexported fields
}
For error reporting
type Token ¶
type Token int
const ( TOK_ERROR Token = iota TOK_COMMENT // /* comment */ or // comment TOK_BLANK // space, tab TOK_ENDL // \r, \n TOK_IDENTIFIER TOK_EOF TOK_BOOL // true / false TOK_FLOAT // 1.0 TOK_INT // 1 //TOK_CHAR // 'a' TOK_BYTE // 0x20 TOK_STRING // "azerty" TOK_ASSIGN_S // is (=) TOK_NOT_S // not (!) TOK_EQUAL_S // eq (==) TOK_NEQ_S // neq (!=) TOK_LT_S // lt (<) TOK_LE_S // le (<=) TOK_GT_S // gt (>) TOK_GE_S // ge (>=) TOK_AND_S // and TOK_OR_S // or TOK_NAND_S // nand TOK_NOR_S // nor TOK_XOR_S // xor TOK_LSH_S // lshift TOK_RSH_S // rshift TOK_PLUS // + TOK_MINUS // - TOK_MUL // * TOK_DIV // / TOK_INC // ++ TOK_DEC // -- TOK_LPAREN // ( TOK_RPAREN // ) TOK_LBLOCK // { TOK_RBLOCK // } TOK_LBRACKET // [ TOK_RBRACKET // ] TOK_DOT // . TOK_COMMA // , TOK_FUNC // function declaration TOK_EXTERN // extern (C bindings) TOK_RETURN // return TOK_IF // if TOK_ELSE // else TOK_SWITCH // switch TOK_CASE // case TOK_BREAK // break TOK_FOR // for TOK_WHILE // while )