Skip to content

Commit

Permalink
Merge pull request #2110 from goplus/main
Browse files Browse the repository at this point in the history
v1.3.0
  • Loading branch information
xushiwei authored Feb 16, 2025
2 parents 370a8e4 + 6b8c809 commit fa730d7
Show file tree
Hide file tree
Showing 98 changed files with 4,251 additions and 427 deletions.
31 changes: 31 additions & 0 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
coverage:
ignore:
- "builtin"
- "ast"
- "test"
- "scanner"
- "format"
- "demo"
- "demo/unit-test"
- "cmd"
- "cl/cltest"
- "cl/outline"
- "cl/internal/spx"
- "cl/internal/spx2"
- "cl/internal/spx3"
- "cl/internal/test"
- "cl/internal/overload"
- "cl/internal/llgo-hello"
- "parser/fsx"
- "parser/parsertest"
- "x/jsonrpc2"
- "x/jsonrpc2/jsonrpc2test"
- "x/watcher"
- "x/langserver"
- "x/fsnotify"
- "x/fakenet"
- "x/typesutil"
- "x/gocmd"
- "x/gopenv"
- "tool"

5 changes: 2 additions & 3 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ jobs:
- macos-latest
go:
- 1.19.x
- 1.20.x
- 1.21.x
- 1.22.x
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
Expand All @@ -48,7 +48,6 @@ jobs:
run: go test -v -coverprofile="coverage.txt" -covermode=atomic ./...

- name: Codecov
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: goplus/gop
2 changes: 1 addition & 1 deletion .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
python .github/workflows/check_goreleaser_config.py
- name: Install Snapcraft
uses: samuelmeuli/action-snapcraft@v2
uses: samuelmeuli/action-snapcraft@v3

- name: Checkout tag
run: |
Expand Down
35 changes: 7 additions & 28 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ dockers:
build_flag_templates:
- --platform=linux/386
- --build-arg=USE_GORELEASER_ARTIFACTS=1
- --build-arg=GORELEASER_ARTIFACTS_TARBALL=./.dist/{{.ProjectName}}{{.Version}}.linux-386.tar.gz
extra_files:
- ./
- goarch: amd64
Expand All @@ -60,6 +61,7 @@ dockers:
build_flag_templates:
- --platform=linux/amd64
- --build-arg=USE_GORELEASER_ARTIFACTS=1
- --build-arg=GORELEASER_ARTIFACTS_TARBALL=./.dist/{{.ProjectName}}{{.Version}}.linux-amd64.tar.gz
extra_files:
- ./
- goarch: arm64
Expand All @@ -69,6 +71,7 @@ dockers:
build_flag_templates:
- --platform=linux/arm64
- --build-arg=USE_GORELEASER_ARTIFACTS=1
- --build-arg=GORELEASER_ARTIFACTS_TARBALL=./.dist/{{.ProjectName}}{{.Version}}.linux-arm64.tar.gz
extra_files:
- ./

Expand Down Expand Up @@ -182,16 +185,14 @@ nfpms:
dst: "/usr/lib/{{ .ProjectName }}/Makefile"
- src: "README.md"
dst: "/usr/lib/{{ .ProjectName }}/README.md"
- src: "_gendeps.go"
dst: "/usr/lib/{{ .ProjectName }}/_gendeps.go"
- src: "all.bash"
dst: "/usr/lib/{{ .ProjectName }}/all.bash"
- src: "all.bat"
dst: "/usr/lib/{{ .ProjectName }}/all.bat"
- src: "ast"
dst: "/usr/lib/{{ .ProjectName }}/ast"
- src: "build_install_run.go"
dst: "/usr/lib/{{ .ProjectName }}/build_install_run.go"
- src: "tool"
dst: "/usr/lib/{{ .ProjectName }}/tool"
- src: "builtin"
dst: "/usr/lib/{{ .ProjectName }}/builtin"
- src: "cl"
Expand All @@ -204,22 +205,14 @@ nfpms:
dst: "/usr/lib/{{ .ProjectName }}/env"
- src: "format"
dst: "/usr/lib/{{ .ProjectName }}/format"
- src: "gengo.go"
dst: "/usr/lib/{{ .ProjectName }}/gengo.go"
- src: "go.mod"
dst: "/usr/lib/{{ .ProjectName }}/go.mod"
- src: "go.sum"
dst: "/usr/lib/{{ .ProjectName }}/go.sum"
- src: "imp.go"
dst: "/usr/lib/{{ .ProjectName }}/imp.go"
- src: "load.go"
dst: "/usr/lib/{{ .ProjectName }}/load.go"
- src: "make.bash"
dst: "/usr/lib/{{ .ProjectName }}/make.bash"
- src: "make.bat"
dst: "/usr/lib/{{ .ProjectName }}/make.bat"
- src: "outline.go"
dst: "/usr/lib/{{ .ProjectName }}/outline.go"
- src: "parser"
dst: "/usr/lib/{{ .ProjectName }}/parser"
- src: "printer"
Expand All @@ -230,8 +223,6 @@ nfpms:
dst: "/usr/lib/{{ .ProjectName }}/test"
- src: "demo"
dst: "/usr/lib/{{ .ProjectName }}/demo"
- src: "tidy.go"
dst: "/usr/lib/{{ .ProjectName }}/tidy.go"
- src: "token"
dst: "/usr/lib/{{ .ProjectName }}/token"
- src: "x"
Expand Down Expand Up @@ -268,16 +259,14 @@ snapcrafts:
destination: "Makefile"
- source: "README.md"
destination: "README.md"
- source: "_gendeps.go"
destination: "_gendeps.go"
- source: "all.bash"
destination: "all.bash"
- source: "all.bat"
destination: "all.bat"
- source: "ast"
destination: "ast"
- source: "build_install_run.go"
destination: "build_install_run.go"
- source: "tool"
destination: "tool"
- source: "builtin"
destination: "builtin"
- source: "cl"
Expand All @@ -290,22 +279,14 @@ snapcrafts:
destination: "env"
- source: "format"
destination: "format"
- source: "gengo.go"
destination: "gengo.go"
- source: "go.mod"
destination: "go.mod"
- source: "go.sum"
destination: "go.sum"
- source: "imp.go"
destination: "imp.go"
- source: "load.go"
destination: "load.go"
- source: "make.bash"
destination: "make.bash"
- source: "make.bat"
destination: "make.bat"
- source: "outline.go"
destination: "outline.go"
- source: "parser"
destination: "parser"
- source: "printer"
Expand All @@ -316,8 +297,6 @@ snapcrafts:
destination: "test"
- source: "demo"
destination: "demo"
- source: "tidy.go"
destination: "tidy.go"
- source: "token"
destination: "token"
- source: "x"
Expand Down
13 changes: 5 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,18 @@ ARG BASE_IMAGE=golang:1.22-bookworm

FROM $BASE_IMAGE AS build
ARG USE_GORELEASER_ARTIFACTS=0
ARG GORELEASER_ARTIFACTS_TARBALL
WORKDIR /usr/local/src/gop
COPY . .
ENV GOPROOT=/usr/local/gop
RUN set -eux; \
mkdir -p $GOPROOT/bin; \
git ls-tree --full-tree --name-only -r HEAD | grep -vE "^\." | xargs -I {} cp --parents {} $GOPROOT/; \
mkdir $GOPROOT; \
if [ $USE_GORELEASER_ARTIFACTS -eq 1 ]; then \
GOARCH=$(go env GOARCH); \
BIN_DIR_SUFFIX=linux_$GOARCH; \
[ $GOARCH = "amd64" ] && BIN_DIR_SUFFIX=${BIN_DIR_SUFFIX}_v1; \
[ $GOARCH = "arm" ] && BIN_DIR_SUFFIX=${BIN_DIR_SUFFIX}_$(go env GOARM | cut -d , -f 1); \
cp .dist/gop_$BIN_DIR_SUFFIX/bin/gop $GOPROOT/bin/; \
tar -xzf "${GORELEASER_ARTIFACTS_TARBALL}" -C $GOPROOT; \
else \
git ls-tree --full-tree --name-only -r HEAD | grep -vE "^\." | xargs -I {} cp --parents {} $GOPROOT/; \
./all.bash; \
cp bin/gop $GOPROOT/bin/; \
mv bin $GOPROOT/; \
fi

FROM $BASE_IMAGE
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ For more details, see [Quick Start](doc/docs.md).
## Key Features of Go+

* Approaching natural language expression and intuitive (see [How Go+ simplifies Go's expressions](#how-go-simplifies-gos-expressions)).
* Smallest but Turing-complete syntax set in best practices (see [Go+ Specification for STEM Education](doc/spec-mini.md)).
* Fully compatible with [Go](https://github.com/golang/go) and can mix Go/Go+ code in the same package (see [Go+ Full Specification](doc/spec.md) and [Go/Go+ Hybrid Programming](doc/docs.md#gogo-hybrid-programming)).
* Integrating with the C ecosystem including Python and providing limitless possibilities based on [LLGo](https://github.com/goplus/llgo) (see [Support for C/C++ and Python](#support-for-cc-and-python)).
* Smallest but Turing-complete syntax set in best practices (see [The Go+ Mini Specification](doc/spec-mini.md)).
* Fully compatible with [Go](https://github.com/golang/go) and can mix Go/Go+ code in the same package (see [The Go+ Full Specification](doc/spec.md) and [Go/Go+ Hybrid Programming](doc/docs.md#gogo-hybrid-programming)).
* Integrating with the C ecosystem including Python and providing limitless possibilities based on [LLGo](https://github.com/goplus/llgo) (see [Importing C/C++ and Python libraries](#importing-cc-and-python-libraries)).
* Does not support DSL (Domain-Specific Languages), but supports SDF (Specific Domain Friendliness) (see [Go+ Classfiles](#go-classfiles)).


Expand Down Expand Up @@ -81,10 +81,10 @@ Code style is just the first step. We have made many efforts to make the code mo
| OnStart(func() {<br>&nbsp;&nbsp;&nbsp;&nbsp;...<br>}) | onStart => {<br>&nbsp;&nbsp;&nbsp;&nbsp;...<br>} | Lambda expressions |
| type Rect struct {<br>&nbsp;&nbsp;&nbsp;&nbsp;Width&nbsp; float64<br>&nbsp;&nbsp;&nbsp;&nbsp;Height float64<br>}<br><br>func (this *Rect) Area() float64 { <br>&nbsp;&nbsp;&nbsp;&nbsp;return this.Width * this.Height<br>} | var (<br>&nbsp;&nbsp;&nbsp;&nbsp;Width&nbsp; float64<br>&nbsp;&nbsp;&nbsp;&nbsp;Height float64<br>)<br><br>func Area() float64 { <br>&nbsp;&nbsp;&nbsp;&nbsp;return Width * Height<br>} | [Go+ Classfiles](doc/classfile.md): We can express OOP with global variables and functions. |

For more details, see [Go+ Specification for STEM Education](doc/spec-mini.md).
For more details, see [The Go+ Mini Specification](doc/spec-mini.md).


## Support for C/C++ and Python
## Importing C/C++ and Python libraries

Go+ can choose different Go compilers as its underlying support. Currently known supported Go compilers include:

Expand Down Expand Up @@ -115,10 +115,10 @@ module YourModulePath

go 1.21 // llgo 1.0

require github.com/goplus/llgo v0.9.7
require github.com/goplus/llgo v0.9.9
```

Based on LLGo, Go+ can support importing libraries written in C/C++ and Python.
Based on LLGo, Go+ can import libraries written in C/C++ and Python.

Here is an example (see [chello](demo/_llgo/chello/hello.gop)) of printing `Hello world` using C's `printf`:

Expand Down
20 changes: 20 additions & 0 deletions ast/ast_gop.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,26 @@ func NextPartPos(pos token.Pos, part any) (nextPos token.Pos) {

// -----------------------------------------------------------------------------

// A NumberUnitLit node represents a number with unit.
type NumberUnitLit struct {
ValuePos token.Pos // literal position
Kind token.Token // token.INT or token.FLOAT
Value string // literal string of the number; e.g. 42, 0x7f, 3.14, 1e-9
Unit string // unit string of the number; e.g. "px", "em", "rem"
}

func (*NumberUnitLit) exprNode() {}

func (x *NumberUnitLit) Pos() token.Pos {
return x.ValuePos
}

func (x *NumberUnitLit) End() token.Pos {
return token.Pos(int(x.ValuePos) + len(x.Value) + len(x.Unit))
}

// -----------------------------------------------------------------------------

// A EnvExpr node represents a ${name} expression.
type EnvExpr struct {
TokPos token.Pos // position of "$"
Expand Down
Loading

0 comments on commit fa730d7

Please sign in to comment.