Repository: goplus/gop
Pull request #2045 (2024-12-25 05:48:20)

mini spec ebnf: String literals


Patch:
diff --git a/.goreleaser.yaml b/.goreleaser.yaml
index 2553aacc..d96b74a3 100644
--- a/.goreleaser.yaml
+++ b/.goreleaser.yaml
@@ -51,7 +51,6 @@ 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
@@ -61,7 +60,6 @@ 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
@@ -71,7 +69,6 @@ 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:
       - ./
 
diff --git a/Dockerfile b/Dockerfile
index 8b214ce7..bbca70c3 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -2,18 +2,21 @@ 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 $GOPROOT; \
+	mkdir -p $GOPROOT/bin; \
+	git ls-tree --full-tree --name-only -r HEAD | grep -vE "^\." | xargs -I {} cp --parents {} $GOPROOT/; \
 	if [ $USE_GORELEASER_ARTIFACTS -eq 1 ]; then \
-		tar -xzf "${GORELEASER_ARTIFACTS_TARBALL}" -C $GOPROOT; \
+		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/; \
 	else \
-		git ls-tree --full-tree --name-only -r HEAD | grep -vE "^\." | xargs -I {} cp --parents {} $GOPROOT/; \
 		./all.bash; \
-		mv bin $GOPROOT/; \
+		cp bin/gop $GOPROOT/bin/; \
 	fi
 
 FROM $BASE_IMAGE
diff --git a/doc/spec-mini.md b/doc/spec-mini.md
index 8f74b0d9..a8c73193 100644
--- a/doc/spec-mini.md
+++ b/doc/spec-mini.md
@@ -109,8 +109,6 @@ Identifiers name program entities such as variables and types. An identifier is
 identifier = letter { letter | unicode_digit } .
 ```
 
-For example:
-
 ```go
 a
 _x9
@@ -164,8 +162,6 @@ octal_digits   = octal_digit { [ "_" ] octal_digit } .
 hex_digits     = hex_digit { [ "_" ] hex_digit } .
 ```
 
-For example:
-
 ```go
 42
 4_2
@@ -210,8 +206,6 @@ hex_mantissa      = [ "_" ] hex_digits "." [ hex_digits ] |
 hex_exponent      = ( "p" | "P" ) [ "+" | "-" ] decimal_digits .
 ```
 
-For example:
-
 ```go
 0.
 72.40
@@ -254,7 +248,7 @@ TODO
 
 ### Imaginary literals
 
-An imaginary literal represents the imaginary part of a [complex constant](). It consists of an [integer](#integer-literals) or [floating-point](#floating-point-literals) literal followed by the lowercase letter _i_. The value of an imaginary literal is the value of the respective integer or floating-point literal multiplied by the imaginary unit _i_.
+An imaginary literal represents the imaginary part of a [complex constant](#constants). It consists of an [integer](#integer-literals) or [floating-point](#floating-point-literals) literal followed by the lowercase letter _i_. The value of an imaginary literal is the value of the respective integer or floating-point literal multiplied by the imaginary unit _i_.
 
 ```go
 imaginary_lit = (decimal_digits | int_lit | float_lit) "i" .
@@ -288,7 +282,7 @@ false
 
 ### Rune literals
 
-A rune literal represents a [rune constant](), an integer value identifying a Unicode code point. A rune literal is expressed as one or more characters enclosed in single quotes, as in `'x'` or `'\n'`. Within the quotes, any character may appear except newline and unescaped single quote. A single quoted character represents the Unicode value of the character itself, while multi-character sequences beginning with a backslash encode values in various formats.
+A rune literal represents a [rune constant](#constants), an integer value identifying a Unicode code point. A rune literal is expressed as one or more characters enclosed in single quotes, as in `'x'` or `'\n'`. Within the quotes, any character may appear except newline and unescaped single quote. A single quoted character represents the Unicode value of the character itself, while multi-character sequences beginning with a backslash encode values in various formats.
 
 The simplest form represents the single character within the quotes; since Go+ source text is Unicode characters encoded in UTF-8, multiple UTF-8-encoded bytes may represent a single integer value. For instance, the literal `'a'` holds a single byte representing a literal a, Unicode `U+0061`, value 0x61, while `'ä'` holds two bytes (0xc3 0xa4) representing a literal a-dieresis, `U+00E4`, value 0xe4.
 
@@ -325,8 +319,6 @@ big_u_value      = `\` "U" hex_digit hex_digit hex_digit hex_digit
 escaped_char     = `\` ( "a" | "b" | "f" | "n" | "r" | "t" | "v" | `\` | "'" | `"` ) .
 ```
 
-For example:
-
 ```go
 'a'
 'ä'
@@ -351,12 +343,18 @@ For example:
 
 ### String literals
 
-A string literal represents a [string constant]() obtained from concatenating a sequence of characters. There are two forms: raw string literals and interpreted string literals.
+A string literal represents a [string constant](#constants) obtained from concatenating a sequence of characters. There are two forms: raw string literals and interpreted string literals.
 
 Raw string literals are character sequences between back quotes, as in \`foo\`. Within the quotes, any character may appear except back quote. The value of a raw string literal is the string composed of the uninterpreted (implicitly UTF-8-encoded) characters between the quotes; in particular, backslashes have no special meaning and the string may contain newlines. Carriage return characters (`'\r'`) inside raw string literals are discarded from the raw string value.
 
 Interpreted string literals are character sequences between double quotes, as in `"bar"`. Within the quotes, any character may appear except newline and unescaped double quote. The text between the quotes forms the value of the literal, with backslash escapes interpreted as they are in [rune literals](#rune-literals) (except that `\'` is illegal and `\"` is legal), with the same restrictions. The three-digit octal (`\nnn`) and two-digit hexadecimal (`\xnn`) escapes represent individual bytes of the resulting string; all other escapes represent the (possibly multi-byte) UTF-8 encoding of individual characters. Thus inside a string literal `\377` and `\xFF` represent a single byte of value 0xFF=255, while `ÿ`, `\u00FF`, `\U000000FF` and `\xc3\xbf` represent the two bytes 0xc3 0xbf of the UTF-8 encoding of character `U+00FF`.
 
+```go
+string_lit             = raw_string_lit | interpreted_string_lit .
+raw_string_lit         = "`" { unicode_char | newline } "`" .
+interpreted_string_lit = `"` { unicode_value | byte_value } `"` .
+```
+
 ```go
 `abc`                // same as "abc"
 `\n
@@ -929,8 +927,6 @@ It is shorthand for a regular [variable declaration](#variable-declarations) wit
 "var" IdentifierList "=" ExpressionList .
 ```
 
-For example:
-
 ```go
 i, j := 0, 10
 f := func() int { return 7 }
@@ -1085,8 +1081,6 @@ append cap complex imag len make new real
 unsafe.Add unsafe.Alignof unsafe.Offsetof unsafe.Sizeof unsafe.Slice unsafe.SliceData unsafe.String unsafe.StringData
 ```
 
-For example:
-
 ```go
 h(x+y)
 f.Close()
@@ -1200,8 +1194,6 @@ In assignments, each value must be [assignable]() to the type of the operand to
 IfStmt = "if" [ SimpleStmt ";" ] Expression Block [ "else" ( IfStmt | Block ) ] .
 ```
 
-For example:
-
 ```go
 if x > 1 {
 	x = 1
@@ -1249,8 +1241,6 @@ InitStmt = SimpleStmt .
 PostStmt = SimpleStmt .
 ```
 
-For example:
-
 ```go
 for i := 0; i < 10; i++ {
 	f(i)
@@ -1430,8 +1420,6 @@ LabeledStmt = Label ":" Statement .
 Label       = identifier .
 ```
 
-For example:
-
 ```go
 Error:
 	log.Panic("error encountered")
@@ -1501,8 +1489,6 @@ A "goto" statement transfers control to the statement with the corresponding lab
 GotoStmt = "goto" Label .
 ```
 
-For example:
-
 ```go
 goto Error
 ```
@@ -2139,8 +2125,6 @@ VarDecl     = "var" ( VarSpec | "(" { VarSpec ";" } ")" ) .
 VarSpec     = IdentifierList ( Type [ "=" ExpressionList ] | "=" ExpressionList ) .
 ```
 
-For example:
-
 ```go
 var i int
 var U, V, W float64
diff --git a/go.mod b/go.mod
index 10b3a11e..cbe3b4a8 100644
--- a/go.mod
+++ b/go.mod
@@ -4,7 +4,7 @@ go 1.18
 
 require (
 	github.com/fsnotify/fsnotify v1.8.0
-	github.com/goplus/gogen v1.16.4-0.20241205134824-ac870e207d8f
+	github.com/goplus/gogen v1.16.3
 	github.com/goplus/llgo v0.9.8
 	github.com/goplus/mod v0.13.12
 	github.com/qiniu/x v1.13.10
diff --git a/go.sum b/go.sum
index cead13c2..e1e847ac 100644
--- a/go.sum
+++ b/go.sum
@@ -1,7 +1,7 @@
 github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M=
 github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
-github.com/goplus/gogen v1.16.4-0.20241205134824-ac870e207d8f h1:+CwzStluc1MGjEQbR5CQOXWOqlBLYnaeECKcSXrHYKg=
-github.com/goplus/gogen v1.16.4-0.20241205134824-ac870e207d8f/go.mod h1:6TQYbabXDF9LCdDkOOzHmfg1R4ENfXQ3XpHa9RhTSD8=
+github.com/goplus/gogen v1.16.3 h1:nNkV1b6zd89d/UhMb4bZHcEfdAHtPaadrJFXNcoUITI=
+github.com/goplus/gogen v1.16.3/go.mod h1:6TQYbabXDF9LCdDkOOzHmfg1R4ENfXQ3XpHa9RhTSD8=
 github.com/goplus/llgo v0.9.8 h1:9qFO5sEYzTXYixNL9m9qDNfI2kjtnU3bPMf5hOwQlME=
 github.com/goplus/llgo v0.9.8/go.mod h1:1phqPJEgr/uw59PRz/NB7s54OoP+NGjC6pz0HovT5JY=
 github.com/goplus/mod v0.13.12 h1:Trwk6j3i9VvBuW6/9ZxmkoFlEL2v3HKQu0Na1c6DAdw=


Test patch:
diff --git a/cl/compile_gop_test.go b/cl/compile_gop_test.go
index 90bbdd66..04742bf2 100644
--- a/cl/compile_gop_test.go
+++ b/cl/compile_gop_test.go
@@ -1630,37 +1630,3 @@ func main() {
 }
 `)
 }
-
-func TestOverloadUntyped(t *testing.T) {
-	gopMixedClTest(t, "main", `
-package main
-
-type specialObj int
-type SpriteName string
-
-type SpriteImpl struct {
-}
-
-func (p *SpriteImpl) turn(v any) {
-}
-func (p *SpriteImpl) TurnTo__0(sprite *SpriteImpl) {
-}
-func (p *SpriteImpl) TurnTo__1(sprite SpriteName) {
-}
-func (p *SpriteImpl) TurnTo__2(obj specialObj) {
-}
-func (p *SpriteImpl) TurnTo__3(degree float64) {
-}
-`, `
-p := &SpriteImpl{}
-p.turnTo 180.0
-p.turnTo 180.1
-`, `package main
-
-func main() {
-	p := &SpriteImpl{}
-	p.TurnTo__2(180.0)
-	p.TurnTo__3(180.1)
-}
-`)
-}