Added token tests
This commit is contained in:
parent
c0f399df7f
commit
18993e0855
7 changed files with 241 additions and 75 deletions
|
@ -18,7 +18,7 @@ type Function struct {
|
|||
// Compile turns a function into machine code.
|
||||
func (f *Function) Compile() {
|
||||
for i, t := range f.Body {
|
||||
if t.Kind == token.Identifier && t.String() == "print" {
|
||||
if t.Kind == token.Identifier && t.Text() == "print" {
|
||||
message := f.Body[i+2].Bytes
|
||||
f.Assembler.MoveRegisterNumber(x64.SyscallNumber, linux.Write)
|
||||
f.Assembler.MoveRegisterNumber(x64.SyscallArgs[0], 1)
|
||||
|
|
|
@ -95,7 +95,7 @@ func scanFile(path string, functions chan<- *Function) error {
|
|||
|
||||
if blockLevel == 0 {
|
||||
function := &Function{
|
||||
Name: tokens[headerStart].String(),
|
||||
Name: tokens[headerStart].Text(),
|
||||
Head: tokens[headerStart:bodyStart],
|
||||
Body: tokens[bodyStart : i+1],
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue