cue/scanner: completely remove block comment support
Change-Id: I1c1d45d7b26a6d98634e65a8bbd91be4ac58a775
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/3983
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
diff --git a/cmd/cue/cmd/fix_test.go b/cmd/cue/cmd/fix_test.go
index 596e594..e7b64ba 100644
--- a/cmd/cue/cmd/fix_test.go
+++ b/cmd/cue/cmd/fix_test.go
@@ -63,52 +63,15 @@
"\(k)": v <-
for k, v in src
-
-/* foo
- bar
- */
-
-a: 3 + /* foo */ 5
`,
out: `package fix
for k, v in src {
"\(k)": v
}
-
-// foo
-// bar
for k, v in src {
"\(k)": v
}
-
-a:
- // foo
- 3 + 5
-`,
- }, {
- name: "comments",
- in: `package foo
-
-a: /* b */ 3 + 5
-a: 3 /* c */ + 5
-a: 3 + /* d */ 5
-a: 3 + 5 /* e
-f */
-`,
- out: `package foo
-
-// b
-a: 3 + 5
-a:
- // c
- 3 + 5
-a:
- // d
- 3 + 5
-// e
-// f
-a: 3 + 5
`,
}, {
name: "templates",
diff --git a/cue/format/testdata/expressions.golden b/cue/format/testdata/expressions.golden
index 0803ec4..51c0577 100644
--- a/cue/format/testdata/expressions.golden
+++ b/cue/format/testdata/expressions.golden
@@ -51,8 +51,8 @@
a: 8 @go(A) // comment
aa: 8 @go(A) // comment
bb: 9
- bbb: 10 @go(Bbb) @xml(,attr) // comment
- bbbb: 100 @go(Bbbb) /* a */ @xml(,attr) // comment
+ bbb: 10 @go(Bbb) @xml(,attr) // comment
+ bbbb: 100 @go(Bbbb) @xml(,attr) // comment
}
foo: {
diff --git a/cue/format/testdata/expressions.input b/cue/format/testdata/expressions.input
index d9be66e..16f42d4 100644
--- a/cue/format/testdata/expressions.input
+++ b/cue/format/testdata/expressions.input
@@ -52,7 +52,7 @@
aa: 8 @go(A) // comment
bb: 9
bbb: 10 @go(Bbb) @xml(,attr) // comment
- bbbb: 100 @go(Bbbb) /* a */ @xml(,attr) // comment
+ bbbb: 100 @go(Bbbb) @xml(,attr) // comment
}
foo bar: string @go(-)
@@ -171,7 +171,7 @@
b {
c: d
}
-
+
e: [{
a: 1, b: 2,
}]
diff --git a/cue/parser/error_test.go b/cue/parser/error_test.go
index d25dbc0..5af605f 100644
--- a/cue/parser/error_test.go
+++ b/cue/parser/error_test.go
@@ -33,10 +33,7 @@
package parser
import (
- "io/ioutil"
- "path/filepath"
"regexp"
- "strings"
"testing"
"cuelang.org/go/cue/errors"
@@ -170,21 +167,6 @@
compareErrors(t, file, expected, found)
}
-func TestErrors(t *testing.T) {
- list, err := ioutil.ReadDir(testdata)
- if err != nil {
- t.Fatal(err)
- }
- for _, fi := range list {
- name := fi.Name()
- t.Run(name, func(t *testing.T) {
- if !fi.IsDir() && !strings.HasPrefix(name, ".") && strings.HasSuffix(name, ".src") {
- checkErrors(t, filepath.Join(testdata, name), nil)
- }
- })
- }
-}
-
func TestFuzz(t *testing.T) {
testCases := []string{
"(({\"\\(0)\"(",
diff --git a/cue/parser/parser_test.go b/cue/parser/parser_test.go
index e6f83fe..3d9f5c5 100644
--- a/cue/parser/parser_test.go
+++ b/cue/parser/parser_test.go
@@ -368,7 +368,7 @@
5, 6, 7, 8 // and here
]
d: {
- a: /* 8 */ 1 // Hello
+ a: 1 // Hello
// Doc
b: 2
}
@@ -382,15 +382,15 @@
"a: {a: 1, b: 2, c: 3, <[d5// end] d: 4>}, " +
"b: [1, 2, 3, 4, <[d2// end] 5>], " +
"c: [1, 2, 3, <[l2// here] 4>, <[l4// here] {a: 3}>, 5, 6, 7, <[l2// and here] 8>], " +
- "d: {<[2/* 8 */] [l5// Hello] a: 1>, <[d0// Doc] b: 2>}, " +
+ "d: {<[l5// Hello] a: 1>, <[d0// Doc] b: 2>}, " +
"e1: <[d1// comment in list body] []>, " +
"e2: <[d1// comment in struct body] {}>",
}, {
"attribute comments",
`
- a: 1 /* a */ @a() /* b */ @b() /* c */ // d
+ a: 1 @a() @b() // d
`,
- `<[l5/* c */ // d] a: <[1/* a */] 1> <[1/* b */] @a()> @b()>`,
+ `<[l5// d] a: 1 @a() @b()>`,
}, {
"comprehension comments",
`
@@ -459,6 +459,12 @@
foo: in & 2
`,
out: "foo: <*ast.BadExpr>&2\nexpected operand, found 'in'",
+ }, {
+ desc: "dot import",
+ in: `
+ import . "foo"
+ `,
+ out: "import , \"foo\"\nexpected 'STRING', found '.'",
}}
for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) {
diff --git a/cue/parser/short_test.go b/cue/parser/short_test.go
index cba14bd..bfdb14c 100644
--- a/cue/parser/short_test.go
+++ b/cue/parser/short_test.go
@@ -32,18 +32,3 @@
})
}
}
-
-func TestInvalid(t *testing.T) {
- invalids := []string{
- `foo !/* ERROR "expected label or ':', found '!'" */`,
- `{ <Name
- /* ERROR "expected '>', found newline" */ >: foo }`,
- `foo: [/* ERROR "square bracket must have exactly one element" */ string, int]: int`,
- // TODO:
- // `{ </* ERROR "expected identifier, found newline" */
- // Name>: foo }`,
- }
- for _, src := range invalids {
- checkErrors(t, src, src)
- }
-}
diff --git a/cue/parser/testdata/commas.src b/cue/parser/testdata/commas.src
index 3865c39..621e2e8 100644
--- a/cue/parser/testdata/commas.src
+++ b/cue/parser/testdata/commas.src
@@ -18,9 +18,6 @@
import "path/to/pkg"
import name "path/to/pkg"
-import . /* ERROR "expected 'STRING', found '.'" */
-import /* ERROR "expected 'STRING', found newline" */
-import err /* ERROR "expected 'STRING', found newline" */
foo: [
0 // legal JSON
@@ -33,4 +30,3 @@
3
]
-not allowed :: /* ERROR "more than one label before '::'" */ {}
diff --git a/cue/scanner/scanner.go b/cue/scanner/scanner.go
index c9b9b06..822d3cb 100644
--- a/cue/scanner/scanner.go
+++ b/cue/scanner/scanner.go
@@ -201,20 +201,6 @@
goto exit
}
- /*-style comment */
- s.next()
- for s.ch >= 0 {
- ch := s.ch
- if ch == '\r' {
- hasCR = true
- }
- s.next()
- if ch == '*' && s.ch == '/' {
- s.next()
- goto exit
- }
- }
-
s.errf(offs, "comment not terminated")
exit:
@@ -927,7 +913,7 @@
case '*':
tok = token.MUL
case '/':
- if s.ch == '/' || s.ch == '*' {
+ if s.ch == '/' {
// comment
if s.insertEOL && s.findLineEnd() {
// reset position to the beginning of the comment
diff --git a/cue/scanner/scanner_test.go b/cue/scanner/scanner_test.go
index ac5e9be..d24f882 100644
--- a/cue/scanner/scanner_test.go
+++ b/cue/scanner/scanner_test.go
@@ -55,9 +55,7 @@
var testTokens = [...]elt{
// Special tokens
- {token.COMMENT, "/* a comment */", special},
{token.COMMENT, "// a comment \n", special},
- {token.COMMENT, "/*\r*/", special},
{token.COMMENT, "//\r\n", special},
// Attributes
@@ -420,24 +418,12 @@
"foo^//comment\n",
"foo^//comment",
- "foo^/*comment*/\n",
- "foo^/*\n*/",
- "foo^/*comment*/ \n",
- "foo^/*\n*/ ",
"foo ^// comment\n",
"foo ^// comment",
- "foo ^/*comment*/\n",
- "foo ^/*\n*/",
- "foo ^/* */ /* \n */ bar^/**/\n",
- "foo ^/*0*/ /*1*/ /*2*/\n",
- "foo ^/*comment*/ \n",
- "foo ^/*0*/ /*1*/ /*2*/ \n",
- "foo ^/**/ /*-------------*/ /*----\n*/bar ^/* \n*/baa^\n",
- "foo ^/* an EOF terminates a line */",
- "foo ^/* an EOF terminates a line */ /*",
- "foo ^/* an EOF terminates a line */ //",
+ "foo ^",
+ "foo ^//",
"package main^\n\nfoo: bar^",
"package main^",
@@ -462,11 +448,10 @@
package foo
// comment
- a: /* a */1
- b : 5 /*
- line one
- line two
- */
+ a: 1 // a
+ b : 5
+ // line one
+ // line two
c: "dfs"
`
want := []string{
@@ -476,14 +461,15 @@
`section COMMENT // comment`,
`newline IDENT a`,
`nospace : `,
- `blank COMMENT /* a */`,
- `nospace INT 1`,
+ `blank INT 1`,
"elided , \n",
+ `blank COMMENT // a`,
`newline IDENT b`,
`blank : `,
`blank INT 5`,
"elided , \n",
- "blank COMMENT /*\n\t line one\n\t line two\n\t*/",
+ "newline COMMENT // line one",
+ "newline COMMENT // line two",
`newline IDENT c`,
`nospace : `,
`blank STRING "dfs"`,
@@ -803,8 +789,6 @@
{`"\q"`, token.STRING, 2, `"\q"`, "unknown escape sequence"},
{`#"\q"#`, token.STRING, 0, `#"\q"#`, ""},
{`#"\#q"#`, token.STRING, 4, `#"\#q"#`, "unknown escape sequence"},
- {"/**/", token.COMMENT, 0, "/**/", ""},
- {"/*", token.COMMENT, 0, "/*", "comment not terminated"},
{"0", token.INT, 0, "0", ""},
{"077", token.INT, 0, "077", "illegal integer number"},
{"078.", token.FLOAT, 0, "078.", ""},
diff --git a/pkg/tool/http/http.cue b/pkg/tool/http/http.cue
index f7d0fd4..f8a3a60 100644
--- a/pkg/tool/http/http.cue
+++ b/pkg/tool/http/http.cue
@@ -27,28 +27,27 @@
request: {
body: *bytes | string
- header <Name>: string | [...string]
- trailer <Name>: string | [...string]
+ header: [string]: string | [...string]
+ trailer: [string]: string | [...string]
}
response: {
status: string
statusCode: int
body: *bytes | string
- header <Name>: string | [...string]
- trailer <Name>: string | [...string]
+ header: [string]: string | [...string]
+ trailer: [string]: string | [...string]
}
}
-/* TODO: support serving once we have the cue serve command.
-Serve: {
- port: int
-
- cert: string
- key: string
-
- handle <Pattern>: Message & {
- pattern: Pattern
- }
-}
-*/
+// TODO: support serving once we have the cue serve command.
+// Serve: {
+// port: int
+//
+// cert: string
+// key: string
+//
+// handle <Pattern>: Message & {
+// pattern: Pattern
+// }
+// }