package main

import (
	"fmt"
	"io/ioutil"

	"./lexer"
	"./parser"
	"./print"
)

func main() {
	dat, err := ioutil.ReadFile("sample.dtodo")
	if err != nil {
		panic(err)
	}

	todo(string(dat))
}

func todo(src string) {
	tokenChan := make(chan lexer.Token)
	nodeChan := make(chan parser.Todo)
	go parser.Run(nodeChan, tokenChan)
	go lexer.Run(tokenChan, &src)

	root := <-nodeChan
	fmt.Printf("%s\n", print.Stringify(root))
	return
}

package main

import (
	"fmt"
	"io/ioutil"

	"./lexer"
	"./parser"
	"./print"
)

func main() {
	dat, err := ioutil.ReadFile("sample.dtodo")
	if err != nil {
		panic(err)
	}

	todo(string(dat))
}

func todo(src string) {
	tokenChan := make(chan lexer.Token)
	nodeChan := make(chan parser.Todo)
	go lexer.Run(tokenChan, &src)
	go parser.Run(nodeChan, tokenChan)
	root := <-nodeChan
	fmt.Printf("%s\n", print.Stringify(root))
	return
}

Change calling sequence of go routines.
Refactoring: Change calling sequence of go routines.

A sequence "lexer -> parser" is correct and more pretty than "parser ->
lexer" but due to my lack of understanding on go routine, It was
reversed.
