bf

package
v0.0.0-...-99d40e0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package bf parses Brainfuck source files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Lexer

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

Lexer scans tokens in Brainfuck source.

func NewLexer

func NewLexer(file *token.File, src []byte) *Lexer

NewLexer constructs a Brainfuck lexer.

func (*Lexer) NextToken

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

NextToken scans a single Brainfuck token.

type Program

type Program struct {
	Tokens []*Token
	File   *token.File
}

Program is a sequence of Brainfuck tokens with file information.

func (*Program) LowerIR

func (p *Program) LowerIR() (*ir.Program, []error)

LowerIR lowers a Brainfuck program to Nebula IR in SSA form.

func (*Program) String

func (p *Program) String() string

type Token

type Token struct {
	Type Type
	Pos  token.Pos
}

Token is a lexical token in Brainfuck.

func LexTokens

func LexTokens(file *token.File, src []byte) ([]*Token, error)

LexTokens scans a Brainfuck source files into tokens.

type Type

type Type uint8

Type is the instruction type of a Brainfuck token.

const (
	Illegal    Type = iota
	IncPtr          // >
	DecPtr          // <
	IncData         // +
	DecData         // -
	Print           // .
	Read            // ,
	Bracket         // [
	EndBracket      // ]
)

Instruction types.

func (Type) String

func (typ Type) String() string

func (Type) StringBF

func (typ Type) StringBF() string

StringBF formats the instruction type as Brainfuck syntax.

Jump to

Keyboard shortcuts

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