diff --git a/Makefile.am b/Makefile.am index a1f699f..841b9aa 100644 --- a/Makefile.am +++ b/Makefile.am @@ -53,7 +53,6 @@ hclgo.bin: lib/libhcl.la $(hclgo_OBJECTS) go build -C $(srcdir) -ldflags "-X 'main.BINDIR=$(bindir)' -X 'main.SBINDIR=$(sbindir)' -X 'main.LIBDIR=$(libdir)' -X 'main.SYSCONFDIR=$(sysconfdir)'" -x -o $(abs_builddir)/hclgo.bin -modfile $(abs_builddir)/go.mod ## --------------------------------------------------------------- go clean -C $(srcdir) -x -modfile $(abs_builddir)/go.mod - rm -rf $(builddir)/go.mod $(builddir)/go.sum ## the go to o recipe is fake to deceive make .go.o: @@ -62,6 +61,7 @@ hclgo.bin: lib/libhcl.la $(hclgo_OBJECTS) .mod.o: echo $< > $@ + endif diff --git a/Makefile.in b/Makefile.in index 53ee890..6367f34 100644 --- a/Makefile.in +++ b/Makefile.in @@ -941,7 +941,6 @@ clean-local: @ENABLE_HCLGO_TRUE@ CGO_LDFLAGS="-L$(abs_builddir)/lib -L$(abs_builddir)/lib/.libs -lhcl -ldl -lquadmath" \ @ENABLE_HCLGO_TRUE@ go build -C $(srcdir) -ldflags "-X 'main.BINDIR=$(bindir)' -X 'main.SBINDIR=$(sbindir)' -X 'main.LIBDIR=$(libdir)' -X 'main.SYSCONFDIR=$(sysconfdir)'" -x -o $(abs_builddir)/hclgo.bin -modfile $(abs_builddir)/go.mod @ENABLE_HCLGO_TRUE@ go clean -C $(srcdir) -x -modfile $(abs_builddir)/go.mod -@ENABLE_HCLGO_TRUE@ rm -rf $(builddir)/go.mod $(builddir)/go.sum @ENABLE_HCLGO_TRUE@.go.o: @ENABLE_HCLGO_TRUE@ echo $< > $@ diff --git a/lib/comp.c b/lib/comp.c index fb5b604..6e43b2f 100644 --- a/lib/comp.c +++ b/lib/comp.c @@ -409,7 +409,8 @@ HCL_INFO2 (hcl, "CLASS NAMED VAR [%.*js]\n", name->len, name->ptr); /* the current function block accesses temporaries in an outer function block */ hcl->c->fnblk.info[hcl->c->fnblk.depth].access_outer = 1; /* temporaries in an outer function block is accessed by the current function block */ - hcl->c->fnblk.info[i - 1].accessed_by_inner = 1; + + if (i > 0) hcl->c->fnblk.info[i - 1].accessed_by_inner = 1; } return 1; diff --git a/main.go b/main.go index 7b3bad1..ac710d4 100644 --- a/main.go +++ b/main.go @@ -81,7 +81,7 @@ func main() { x.SetLogTarget("/dev/stderr") } - x.SetTrait (x.GetTrait() | hcl.TRAIT_LANG_ENABLE_EOL | hcl.TRAIT_LANG_ENABLE_BLOCK) + x.SetTrait(x.GetTrait() | hcl.TRAIT_LANG_ENABLE_EOL | hcl.TRAIT_LANG_ENABLE_BLOCK) err = x.Ignite(1000000) if err != nil { diff --git a/t/Makefile.am b/t/Makefile.am index 35f51a3..a6bae25 100644 --- a/t/Makefile.am +++ b/t/Makefile.am @@ -1,6 +1,7 @@ AUTOMAKE_OPTIONS = nostdinc check_SCRIPTS = \ + feed-01.hcl \ fun-01.hcl \ insta-01.hcl \ insta-02.hcl \ @@ -10,19 +11,19 @@ check_SCRIPTS = \ var-02.hcl check_ERRORS = \ - call-01.err \ - class-01.err \ - do-01.err \ - do-02.err \ - feed-01.err \ - feed-02.err \ - feed-03.err \ - feed-04.err \ - mlist-01.err \ - var-01.err \ - var-02.err \ - var-03.err \ - var-04.err + call-5001.err \ + class-5001.err \ + do-5001.err \ + do-5002.err \ + feed-5001.err \ + feed-5002.err \ + feed-5003.err \ + feed-5004.err \ + mlist-5001.err \ + var-5001.err \ + var-5002.err \ + var-5003.err \ + var-5004.err ##noinst_SCRIPTS = $(check_SCRIPTS) EXTRA_DIST = $(check_SCRIPTS) $(check_ERRORS) diff --git a/t/Makefile.in b/t/Makefile.in index 6bab9b5..948874b 100644 --- a/t/Makefile.in +++ b/t/Makefile.in @@ -472,6 +472,7 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AUTOMAKE_OPTIONS = nostdinc check_SCRIPTS = \ + feed-01.hcl \ fun-01.hcl \ insta-01.hcl \ insta-02.hcl \ @@ -481,19 +482,19 @@ check_SCRIPTS = \ var-02.hcl check_ERRORS = \ - call-01.err \ - class-01.err \ - do-01.err \ - do-02.err \ - feed-01.err \ - feed-02.err \ - feed-03.err \ - feed-04.err \ - mlist-01.err \ - var-01.err \ - var-02.err \ - var-03.err \ - var-04.err + call-5001.err \ + class-5001.err \ + do-5001.err \ + do-5002.err \ + feed-5001.err \ + feed-5002.err \ + feed-5003.err \ + feed-5004.err \ + mlist-5001.err \ + var-5001.err \ + var-5002.err \ + var-5003.err \ + var-5004.err EXTRA_DIST = $(check_SCRIPTS) $(check_ERRORS) TEST_EXTENSIONS = .hcl .err diff --git a/t/call-01.err b/t/call-5001.err similarity index 100% rename from t/call-01.err rename to t/call-5001.err diff --git a/t/class-01.err b/t/class-5001.err similarity index 100% rename from t/class-01.err rename to t/class-5001.err diff --git a/t/do-01.err b/t/do-5001.err similarity index 100% rename from t/do-01.err rename to t/do-5001.err diff --git a/t/do-02.err b/t/do-5002.err similarity index 100% rename from t/do-02.err rename to t/do-5002.err diff --git a/t/feed-01.hcl b/t/feed-01.hcl new file mode 100644 index 0000000..2afbcf8 --- /dev/null +++ b/t/feed-01.hcl @@ -0,0 +1,54 @@ +## this file is to test the reader/feeder againsst weirdly formatted input text. + +{ ## START + +| J | + +defun xxx (x y z + ::: r ) { + + | k + b + s | + + k := (+ x y z) + b := (* k k) + s := (* b b) + + printf "%d %d %d\n" k b s + + r := s + J := r +} + + +[ +j +] \ + := (xxx + 10 + 20 + 30) + +if (eqv? j 12960000) \ +{ + printf "OK: j is 12960000\n" +} else { + printf "BAD: j is not 12960000\n" +} + +xxx \ + 1 \ + 2 \ + 3 + +if (eqv? J 1296) { + printf "OK: J is 1296\n" +} else { + printf "BAD: J is not 1296\n" +} + + + + +} ## END diff --git a/t/feed-01.err b/t/feed-5001.err similarity index 100% rename from t/feed-01.err rename to t/feed-5001.err diff --git a/t/feed-02.err b/t/feed-5002.err similarity index 100% rename from t/feed-02.err rename to t/feed-5002.err diff --git a/t/feed-03.err b/t/feed-5003.err similarity index 100% rename from t/feed-03.err rename to t/feed-5003.err diff --git a/t/feed-04.err b/t/feed-5004.err similarity index 100% rename from t/feed-04.err rename to t/feed-5004.err diff --git a/t/mlist-01.err b/t/mlist-5001.err similarity index 100% rename from t/mlist-01.err rename to t/mlist-5001.err diff --git a/t/var-02.hcl b/t/var-02.hcl index 64977a1..f3ddf1f 100644 --- a/t/var-02.hcl +++ b/t/var-02.hcl @@ -14,11 +14,11 @@ if (eqv? j 20) { q := (x 30); }; -if (/= a 900) { print "ERROR: a is not 900\n" } +if (/= a 900) { print "ERROR: a is not 900\n" } \ else { printf "OK: %d\n" a }; -if (/= b 60) { print "ERROR: b is not 60\n" } +if (/= b 60) { print "ERROR: b is not 60\n" } \ else { printf "OK: %d\n" b }; -if (/= c 840) { print "ERROR: c is not 840\n" } +if (/= c 840) { print "ERROR: c is not 840\n" } \ else { printf "OK: %d\n" c }; diff --git a/t/var-01.err b/t/var-5001.err similarity index 100% rename from t/var-01.err rename to t/var-5001.err diff --git a/t/var-02.err b/t/var-5002.err similarity index 100% rename from t/var-02.err rename to t/var-5002.err diff --git a/t/var-03.err b/t/var-5003.err similarity index 100% rename from t/var-03.err rename to t/var-5003.err diff --git a/t/var-04.err b/t/var-5004.err similarity index 100% rename from t/var-04.err rename to t/var-5004.err