From 78cfd8633bdf1f77b40a10929556d30042cb5dff Mon Sep 17 00:00:00 2001 From: Felix Hanley Date: Tue, 10 Mar 2020 15:19:52 +1100 Subject: Add Tokens() returning the internal channel --- Makefile | 17 ++++++----------- go.mod | 2 +- lexer.go | 5 +++++ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 8243281..f522160 100644 --- a/Makefile +++ b/Makefile @@ -1,18 +1,13 @@ .PHONY: test -test: lint ## Run tests with coverage - go test -short -cover -coverprofile coverage.txt ./... - go tool cover -html=coverage.txt -o coverage.html +test: lint + go test -short -cover -coverprofile coverage.txt ./... \ + && go tool cover -html=coverage.txt -o coverage.html .PHONY: lint -lint: ## Run the code linter - revive ./... +lint: + go vet ./... .PHONY: clean -clean: ## Clean all test files +clean: rm -rf coverage* - -.PHONY: help -help: - grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) |sort \ - |awk 'BEGIN{FS=":.*?## "};{printf "\033[36m%-30s\033[0m %s\n",$$1,$$2}' diff --git a/go.mod b/go.mod index 7fe7e93..5c35ace 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ module src.userspace.com.au/lexer -go 1.12 +go 1.14 diff --git a/lexer.go b/lexer.go index 5dff2c8..35daff9 100644 --- a/lexer.go +++ b/lexer.go @@ -203,6 +203,11 @@ func (l *Lexer) SkipWhitespace() { } } +// Tokens returns the a token channel. +func (l *Lexer) Tokens() <-chan Token { + return l.tokens +} + // NextToken returns the next token from the lexer and done func (l *Lexer) NextToken() (*Token, bool) { if tok, ok := <-l.tokens; ok { -- cgit v1.2.3