Documentation ¶
Index ¶
- Constants
- func Preprocess(inputFile, outputFile string)
- type AST
- type Assignment
- type Conditional
- type Expression
- type Function
- type FunctionCall
- type FunctionParameter
- type Global
- type RVFunctionCall
- type RuntimeValue
- type Struct
- type StructMember
- type TopExpression
- type Value
- type Variable
- type View
- type WhileLoop
- type YardToken
Constants ¶
View Source
const AssigneableRegisters = 4
View Source
const CalcTypeRegexAsm = `^asm\s*\{.*?\}$`
View Source
const CalcTypeRegexLiteral = `^((0(x|X))[0-9a-fA-F]+|\d+)$`
Careful here, we want to match base 10, 16, but not variables (e.g. 0xfAb = match, 0xno_u = no match, technically a variable [though it has a leading 0?])
View Source
const CalcTypeRegexMath = `^(?:\=\=|\!\=|\<\=|\>\=|\<\<|\>\>|\+|\-|\<|\>|\*|\/|\%|\(|\)|\s|,|\~|\||\&|\^|[a-zA-Z0-9_$\.])*$`
View Source
const FAULT_NO_RETURN = "0x0"
View Source
const LexerRegex = `(?s)(\s+)|` +
`(?P<Int>(?:(?:0(x|X))[0-9a-fA-F]+|\d+))|` +
`(?P<String>"(?:[^"\\]|\\.)*")|` +
`(?P<Eval>\[.*?\])|` +
`(?P<ASM>_asm\s*\{.*?\})|` +
`(?P<IdentWithDot>(?:[a-zA-Z0-9_$]+\.)+[a-zA-Z0-9_$]+)|` +
`(?P<Ident>[a-zA-Z_$][a-zA-Z0-9_$]*)|` +
`(?P<AssignmentOperator>\+\=|\-\=|\*\=|\/\=|\%\=|\=)|` +
`(?P<Operator>\=\=|\!\=|\<\=|\>\=|\<\<|\>\>|\+|\-|\<|\>|\*|\/|\%)|` +
`(?P<RawToken>\S)`
Variables ¶
This section is empty.
Functions ¶
func Preprocess ¶
func Preprocess(inputFile, outputFile string)
Types ¶
type AST ¶
type AST struct { TopExpressions []*TopExpression `{ @@ }` CommentHeaders []string }
func GenerateAST ¶
func (*AST) GenerateASM ¶
type Assignment ¶
type Assignment struct { Pos lexer.Position Name string `@(IdentWithDot|Ident)` Operator string `@AssignmentOperator` Value *RuntimeValue `@@` }
type Conditional ¶
type Conditional struct { Pos lexer.Position Condition string `"if" @Eval` BodyIf []*Expression `"{" { @@ } "}"` BodyElse []*Expression `["else" "{" { @@ } "}"]` }
type Expression ¶
type Expression struct { Pos lexer.Position Assignment *Assignment `(( @@` FunctionCall *FunctionCall `| @@` Variable *Variable `| @@` Return *RuntimeValue `| "return" @@) ";")` WhileLoop *WhileLoop `| @@` // ForLoop *ForLoop `| @@` IfCondition *Conditional `| @@` Asm *string `| @ASM` }
type Function ¶
type Function struct { Pos lexer.Position Inline bool `"func" [@"inline"]` Type string `@Ident` Name string `@Ident` Parameters []*FunctionParameter `"(" { @@ [","] } ")"` Body []*Expression `"{" { @@ } "}"` }
type FunctionCall ¶
type FunctionCall struct { Pos lexer.Position FunctionName string `@Ident` Parameters []*RuntimeValue `"(" { @@ [","] } ")"` }
type FunctionParameter ¶
type RVFunctionCall ¶
type RVFunctionCall struct { Pos lexer.Position FunctionName string `@Ident` Parameters []*RuntimeValue `"(" { @@ [","] } ")"` }
type RuntimeValue ¶
type Struct ¶
type Struct struct { Pos lexer.Position Name string `"struct" @Ident` Members []*StructMember `"{" { @@ } "}"` }
type StructMember ¶
type TopExpression ¶
type Variable ¶
type Variable struct { Pos lexer.Position Type string `@Ident` Name string `@Ident` Value *RuntimeValue `["=" @@]` }
Click to show internal directories.
Click to hide internal directories.