Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SowoCompileFile ¶
func SowoCompileFile(options CompilerOptions)
Compiles a sowo program file given some options
Types ¶
type Ast ¶
type Ast struct {
Type AstType
Children []*Ast
Name string
DataType TypeAnnotation
NumberDataValue int
BooleanDataValue bool
StringDataValue string
Operator BinaryOperator
}
type AstType ¶
type AstType int
const ( AstNoop AstType = iota AstModule AstFunction AstFuncArgs AstFuncReturnType AstBlock AstStatement AstVariable AstTypeAnnotation AstLocalVariable AstExpression AstAssignment AstBinaryOp AstNumberLiteral AstBooleanLiteral AstStringLiteral AstVariableRef AstIf AstWhile AstFuncCall AstReturn AstPrint )
func (AstType) MarshalJSON ¶
type BinaryOperator ¶
type BinaryOperator int
Represents the operator of a binary operation.
const ( OpPlus BinaryOperator = iota OpMinus OpTimes OpDivide OpEquals OpLessThen OpGreaterThen OpLessThenEqual OpGreaterThenEqual )
func (BinaryOperator) MarshalJSON ¶
func (op BinaryOperator) MarshalJSON() ([]byte, error)
func (BinaryOperator) String ¶
func (op BinaryOperator) String() (ret string)
type CompilerOptions ¶
type CompilerOptions struct {
PrintTokens bool
PrintAst bool
SaveTokens bool
SaveAst bool
SkipCompile bool
InputFile string
OutputFile string
}
Represents a set of options used by the compiler.
type Lexer ¶
type Lexer struct {
// The program string in input.
Input string
}
Struct representing a lexer.
type Parser ¶
type Parser struct {
// List of tokens that need to be parsed
Tokens []Token
}
Represent a parser with methods to parse a list of tokens into a Module.
type TokenType ¶
type TokenType int
Represent all the possible token types.
const ( TokenFunc TokenType = iota TokenSymbol TokenOpenParen TokenCloseParen TokenOpenCurly TokenCloseCurly TokenVar TokenColon TokenComma TokenEqual TokenEqualEqual TokenLessThen TokenGreaterThen TokenLessThenEqual TokenGreaterThenEqual TokenSemicolon TokenPlus TokenMinus TokenAsterisk TokenSlash TokenIf TokenElse TokenWhile TokenNumberLiteral TokenStringLiteral TokenHash TokenReturn TokenTrue TokenFalse TokenPrint )
type TypeAnnotation ¶
type TypeAnnotation int
Represents the type of a variable. It can be:
- Void
- Integer
const ( TypeVoid TypeAnnotation = iota TypeInteger TypeBoolean TypeString )
func (TypeAnnotation) MarshalJSON ¶
func (t TypeAnnotation) MarshalJSON() ([]byte, error)
func (TypeAnnotation) String ¶
func (t TypeAnnotation) String() (ret string)
Click to show internal directories.
Click to hide internal directories.