lang, lang: types: Add automatic stringer generation
It's more useful if we know the string representation of Kind's.
This commit is contained in:
@@ -23,8 +23,11 @@ OLDGOYACC := $(shell go version | grep -E 'go1.6|go1.7')
|
||||
all: build
|
||||
|
||||
build: lexer.nn.go y.go
|
||||
@# recursively run make in child dir named types
|
||||
@$(MAKE) --quiet -C types
|
||||
|
||||
clean:
|
||||
$(MAKE) --quiet -C types clean
|
||||
@rm -f lexer.nn.go y.go y.output || true
|
||||
|
||||
lexer.nn.go: lexer.nex
|
||||
|
||||
@@ -1 +1 @@
|
||||
# err: err3: can't unify, invariant illogicality with equality: base kind does not match (2 != 3)
|
||||
# err: err3: can't unify, invariant illogicality with equality: base kind does not match (Str != Int)
|
||||
|
||||
@@ -1 +1 @@
|
||||
# err: err3: can't unify, invariant illogicality with equals: base kind does not match (2 != 5)
|
||||
# err: err3: can't unify, invariant illogicality with equals: base kind does not match (Str != List)
|
||||
|
||||
30
lang/types/Makefile
Normal file
30
lang/types/Makefile
Normal file
@@ -0,0 +1,30 @@
|
||||
# Mgmt
|
||||
# Copyright (C) 2013-2019+ James Shubin and the project contributors
|
||||
# Written by James Shubin <james@shubin.ca> and the project contributors
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
SHELL = /usr/bin/env bash
|
||||
.PHONY: all build clean
|
||||
|
||||
all: build
|
||||
|
||||
build: kind_stringer.go
|
||||
|
||||
clean:
|
||||
@rm -f kind_stringer.go || true
|
||||
|
||||
kind_stringer.go: type.go
|
||||
@echo "Generating: type kind strings..."
|
||||
go generate
|
||||
@@ -697,7 +697,7 @@ func TestUnification1(t *testing.T) {
|
||||
name: "typed if expr",
|
||||
ast: stmt,
|
||||
fail: true,
|
||||
experrstr: "can't unify, invariant illogicality with equality: base kind does not match (2 != 3)",
|
||||
experrstr: "can't unify, invariant illogicality with equality: base kind does not match (Str != Int)",
|
||||
})
|
||||
}
|
||||
{
|
||||
@@ -750,7 +750,7 @@ func TestUnification1(t *testing.T) {
|
||||
name: "typed var expr",
|
||||
ast: stmt,
|
||||
fail: true,
|
||||
experrstr: "can't unify, invariant illogicality with equality: base kind does not match (2 != 1)",
|
||||
experrstr: "can't unify, invariant illogicality with equality: base kind does not match (Str != Bool)",
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ if [ "$COMMITS" != "" ] && [ "$COMMITS" -gt "1" ]; then
|
||||
fi
|
||||
|
||||
# find all go files, exluding temporary directories and generated files
|
||||
LINT=$(find * -maxdepth 9 -iname '*.go' -not -path 'old/*' -not -path 'tmp/*' -not -path 'bindata/*' -not -path 'lang/y.go' -not -path 'lang/lexer.nn.go' -not -path 'vendor/*' -exec golint {} \;) # current golint output
|
||||
LINT=$(find * -maxdepth 9 -iname '*.go' -not -path 'old/*' -not -path 'tmp/*' -not -path 'bindata/*' -not -path 'lang/y.go' -not -path 'lang/lexer.nn.go' -not -path 'lang/types/kind_stringer.go' -not -path 'vendor/*' -exec golint {} \;) # current golint output
|
||||
|
||||
COUNT=`echo -e "$LINT" | wc -l` # number of golint problems in current branch
|
||||
[ "$LINT" = "" ] && echo PASS && exit # everything is "perfect"
|
||||
|
||||
@@ -48,6 +48,7 @@ gml="$gml --enable=misspell"
|
||||
gml="$gml --exclude=lang/lexer.nn.go"
|
||||
gml="$gml --exclude=lang/y.go"
|
||||
gml="$gml --exclude=bindata/bindata.go"
|
||||
gml="$gml --exclude=lang/types/kind_stringer.go"
|
||||
|
||||
gometalinter="$gml" # final
|
||||
echo "Using: $gometalinter"
|
||||
|
||||
Reference in New Issue
Block a user