ascii32

package module
v0.0.0-...-a443f4f Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2020 License: MIT Imports: 4 Imported by: 0

README

ascii32

A language named .

Just started. This much works:

echo ' 3 8 + ! ' | go run ascii32.go

2020/09/28 01:38:29 Step[0]: {1 1   3}
2020/09/28 01:38:29 Step[1]: {1 2 3 1}
2020/09/28 01:38:29 Step[2]: {1 3   3}
2020/09/28 01:38:29 Step[3]: {1 4 8 1}
2020/09/28 01:38:29 Step[4]: {1 5   3}
2020/09/28 01:38:29 Step[5]: {1 6 + 2}
2020/09/28 01:38:29 Step[6]: {1 7   3}
2020/09/28 01:38:29 Step[7]: {1 8 ! 2}
<1><1>2020/09/28 01:38:29 Step[8]: {1 9   3}
2020/09/28 01:38:29 Step[9]: {1 10  0}
2020/09/28 01:38:29 Final Stack: {[]}

where ! prints the top of the stack (like . in Forth).

Notice the output in angle brackets: <1><1>

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsLetter

func IsLetter(r rune) bool

func IsNewLine

func IsNewLine(r rune) bool

func IsWhite

func IsWhite(r rune) bool

Types

type A__

type A__ struct {
	Emit func(r rune)
	Ops  [128]func(*A__)
	Data Stack
}

func New__

func New__(emit func(r rune)) *A__

func (*A__) RunProgram

func (o *A__) RunProgram(s string)

func (*A__) Step

func (o *A__) Step(t Tok)

type Stack

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

func (*Stack) Pop

func (o *Stack) Pop() string

func (*Stack) Push

func (o *Stack) Push(x string)

func (*Stack) String

func (o *Stack) String() string

type Tok

type Tok struct {
	Line int
	Col  int
	S    string
	Type TokType
}

func Tokenize

func Tokenize(s string) []Tok

type TokType

type TokType int
const (
	TokEOF TokType = iota
	TokLetters
	TokOp
	TokWhite
)

Jump to

Keyboard shortcuts

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