git clone git@github.com:nicholasgriffen/waiig-commentary.git
cd waiig-commentary
go run main.go
go get github.com/robertkrimen/godocdown/godocdown
godocdown /path/to/package > package.md
cat package.md >> README.md
-- import "interpreter/repl"
func Start(in io.Reader, out io.Writer)
Start reads lines in and writes tokens out
-- import "interpreter/lexer"
BUG(nicholasgriffen): Lexers lack Unicode, UTF-8 support
type Lexer struct {
}
Lexer takes source code and returns tokens
func New(input string) Lexer
New takes string and returns initialized lexer
func (lexer *Lexer) NextToken() token.Token
NextToken creates token and steps position
-- import "interpreter/token"
BUG(nicholasgriffen): Tokens lack filenames, linenumbers
const (
//ILLEGAL unknown type
ILLEGAL = "ILLEGAL"
//IDENT identifier
IDENT = "IDENT"
//FUNCTION function declaration
FUNCTION = "FUNCTION"
//RETURN end function execution with return value
RETURN = "RETURN"
//LET identifier naming
LET = "LET"
//TRUE boolean false
TRUE = "TRUE"
//FALSE boolean false
FALSE = "FALSE"
//IF if control flow
IF = "IF"
//ELSE else control flow
ELSE = "ELSE"
//IS comparison
IS = "=="
//ISNOT comparison
ISNOT = "!="
//EOF end of file
EOF = ""
//INT integer
INT = "INT"
//ASSIGN identifier assignment
ASSIGN = "="
//PLUS sum
PLUS = "+"
//MINUS subtract
MINUS = "-"
//STAR asterisk
STAR = "*"
//FSLASH forward slash
FSLASH = "/"
//COMMA expression separator{}
COMMA = ","
//SEMICOLON statement terminator
SEMICOLON = ";"
//BANG exclamation point
BANG = "!"
//LTHAN open angle
LTHAN = "<"
//RTHAN close angle
RTHAN = ">"
//LROUND open grouping
LROUND = "("
//RROUND close grouping
RROUND = ")"
//LCURLY open block
LCURLY = "{"
//RCURLY close block
RCURLY = "}"
)
type Token struct {
Type TokenType
Literal string
}
Token keywords, symbols
type TokenType string
TokenType matters downstream
func FindIdent(ident string) TokenType
FindIdent takes string and looks up TokenType