mirror of
https://github.com/google/go-jsonnet.git
synced 2025-08-07 14:57:24 +02:00
parent
f46dea2835
commit
2ea01b24d8
@ -520,6 +520,15 @@ type ObjectComp struct {
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// Parens represents parentheses
|
||||
// ( e )
|
||||
type Parens struct {
|
||||
NodeBase
|
||||
Inner Node
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// Self represents the self keyword.
|
||||
type Self struct{ NodeBase }
|
||||
|
||||
|
@ -15797,7 +15797,7 @@ var StdAst = &DesugaredObject{
|
||||
},
|
||||
End: Location{
|
||||
Line: int(67),
|
||||
Column: int(79),
|
||||
Column: int(80),
|
||||
},
|
||||
file: p1,
|
||||
},
|
||||
@ -22348,7 +22348,7 @@ var StdAst = &DesugaredObject{
|
||||
},
|
||||
End: Location{
|
||||
Line: int(102),
|
||||
Column: int(86),
|
||||
Column: int(87),
|
||||
},
|
||||
file: p1,
|
||||
},
|
||||
@ -30534,7 +30534,7 @@ var StdAst = &DesugaredObject{
|
||||
},
|
||||
End: Location{
|
||||
Line: int(162),
|
||||
Column: int(58),
|
||||
Column: int(59),
|
||||
},
|
||||
file: p1,
|
||||
},
|
||||
@ -31033,7 +31033,7 @@ var StdAst = &DesugaredObject{
|
||||
},
|
||||
End: Location{
|
||||
Line: int(164),
|
||||
Column: int(67),
|
||||
Column: int(68),
|
||||
},
|
||||
file: p1,
|
||||
},
|
||||
@ -31722,7 +31722,7 @@ var StdAst = &DesugaredObject{
|
||||
},
|
||||
End: Location{
|
||||
Line: int(166),
|
||||
Column: int(95),
|
||||
Column: int(96),
|
||||
},
|
||||
file: p1,
|
||||
},
|
||||
@ -37243,7 +37243,7 @@ var StdAst = &DesugaredObject{
|
||||
},
|
||||
End: Location{
|
||||
Line: int(193),
|
||||
Column: int(81),
|
||||
Column: int(82),
|
||||
},
|
||||
file: p1,
|
||||
},
|
||||
@ -37954,7 +37954,7 @@ var StdAst = &DesugaredObject{
|
||||
},
|
||||
End: Location{
|
||||
Line: int(195),
|
||||
Column: int(87),
|
||||
Column: int(88),
|
||||
},
|
||||
file: p1,
|
||||
},
|
||||
@ -39367,7 +39367,7 @@ var StdAst = &DesugaredObject{
|
||||
},
|
||||
End: Location{
|
||||
Line: int(201),
|
||||
Column: int(90),
|
||||
Column: int(91),
|
||||
},
|
||||
file: p1,
|
||||
},
|
||||
@ -40078,7 +40078,7 @@ var StdAst = &DesugaredObject{
|
||||
},
|
||||
End: Location{
|
||||
Line: int(203),
|
||||
Column: int(87),
|
||||
Column: int(88),
|
||||
},
|
||||
file: p1,
|
||||
},
|
||||
@ -41512,7 +41512,7 @@ var StdAst = &DesugaredObject{
|
||||
},
|
||||
End: Location{
|
||||
Line: int(209),
|
||||
Column: int(88),
|
||||
Column: int(89),
|
||||
},
|
||||
file: p1,
|
||||
},
|
||||
@ -41955,7 +41955,7 @@ var StdAst = &DesugaredObject{
|
||||
},
|
||||
End: Location{
|
||||
Line: int(211),
|
||||
Column: int(86),
|
||||
Column: int(87),
|
||||
},
|
||||
file: p1,
|
||||
},
|
||||
@ -69708,7 +69708,7 @@ var StdAst = &DesugaredObject{
|
||||
},
|
||||
End: Location{
|
||||
Line: int(439),
|
||||
Column: int(59),
|
||||
Column: int(60),
|
||||
},
|
||||
file: p1,
|
||||
},
|
||||
@ -69737,7 +69737,7 @@ var StdAst = &DesugaredObject{
|
||||
},
|
||||
End: Location{
|
||||
Line: int(439),
|
||||
Column: int(59),
|
||||
Column: int(60),
|
||||
},
|
||||
file: p1,
|
||||
},
|
||||
@ -69913,7 +69913,7 @@ var StdAst = &DesugaredObject{
|
||||
},
|
||||
End: Location{
|
||||
Line: int(439),
|
||||
Column: int(59),
|
||||
Column: int(60),
|
||||
},
|
||||
file: p1,
|
||||
},
|
||||
@ -70867,7 +70867,7 @@ var StdAst = &DesugaredObject{
|
||||
},
|
||||
End: Location{
|
||||
Line: int(442),
|
||||
Column: int(74),
|
||||
Column: int(75),
|
||||
},
|
||||
file: p1,
|
||||
},
|
||||
@ -73709,7 +73709,7 @@ var StdAst = &DesugaredObject{
|
||||
},
|
||||
End: Location{
|
||||
Line: int(461),
|
||||
Column: int(53),
|
||||
Column: int(54),
|
||||
},
|
||||
file: p1,
|
||||
},
|
||||
@ -73732,7 +73732,7 @@ var StdAst = &DesugaredObject{
|
||||
},
|
||||
End: Location{
|
||||
Line: int(460),
|
||||
Column: int(74),
|
||||
Column: int(75),
|
||||
},
|
||||
file: p1,
|
||||
},
|
||||
@ -90882,7 +90882,7 @@ var StdAst = &DesugaredObject{
|
||||
},
|
||||
End: Location{
|
||||
Line: int(576),
|
||||
Column: int(95),
|
||||
Column: int(96),
|
||||
},
|
||||
file: p1,
|
||||
},
|
||||
@ -103665,7 +103665,7 @@ var StdAst = &DesugaredObject{
|
||||
},
|
||||
End: Location{
|
||||
Line: int(694),
|
||||
Column: int(94),
|
||||
Column: int(95),
|
||||
},
|
||||
file: p1,
|
||||
},
|
||||
@ -104109,7 +104109,7 @@ var StdAst = &DesugaredObject{
|
||||
},
|
||||
End: Location{
|
||||
Line: int(696),
|
||||
Column: int(92),
|
||||
Column: int(93),
|
||||
},
|
||||
file: p1,
|
||||
},
|
||||
@ -104553,7 +104553,7 @@ var StdAst = &DesugaredObject{
|
||||
},
|
||||
End: Location{
|
||||
Line: int(698),
|
||||
Column: int(83),
|
||||
Column: int(84),
|
||||
},
|
||||
file: p1,
|
||||
},
|
||||
@ -116822,7 +116822,7 @@ var StdAst = &DesugaredObject{
|
||||
},
|
||||
End: Location{
|
||||
Line: int(770),
|
||||
Column: int(54),
|
||||
Column: int(55),
|
||||
},
|
||||
file: p1,
|
||||
},
|
||||
@ -140302,7 +140302,7 @@ var StdAst = &DesugaredObject{
|
||||
},
|
||||
End: Location{
|
||||
Line: int(907),
|
||||
Column: int(62),
|
||||
Column: int(63),
|
||||
},
|
||||
file: p1,
|
||||
},
|
||||
@ -140327,7 +140327,7 @@ var StdAst = &DesugaredObject{
|
||||
},
|
||||
End: Location{
|
||||
Line: int(907),
|
||||
Column: int(62),
|
||||
Column: int(63),
|
||||
},
|
||||
file: p1,
|
||||
},
|
||||
@ -142156,7 +142156,7 @@ var StdAst = &DesugaredObject{
|
||||
},
|
||||
End: Location{
|
||||
Line: int(923),
|
||||
Column: int(87),
|
||||
Column: int(88),
|
||||
},
|
||||
file: p1,
|
||||
},
|
||||
@ -142838,7 +142838,7 @@ var StdAst = &DesugaredObject{
|
||||
},
|
||||
End: Location{
|
||||
Line: int(927),
|
||||
Column: int(96),
|
||||
Column: int(97),
|
||||
},
|
||||
file: p1,
|
||||
},
|
||||
|
@ -560,6 +560,13 @@ func desugar(astPtr *ast.Node, objLevel int) (err error) {
|
||||
}
|
||||
*astPtr = comp
|
||||
|
||||
case *ast.Parens:
|
||||
*astPtr = node.Inner
|
||||
err = desugar(astPtr, objLevel)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
case *ast.Self:
|
||||
// Nothing to do.
|
||||
|
||||
|
@ -99,6 +99,8 @@ func directChildren(node ast.Node) []ast.Node {
|
||||
spec = spec.Outer
|
||||
}
|
||||
return result
|
||||
case *ast.Parens:
|
||||
return []ast.Node{node.Inner}
|
||||
case *ast.Self:
|
||||
return nil
|
||||
case *ast.SuperIndex:
|
||||
@ -172,6 +174,8 @@ func thunkChildren(node ast.Node) []ast.Node {
|
||||
return []ast.Node{node.Body}
|
||||
case *ast.ObjectComp:
|
||||
return nil
|
||||
case *ast.Parens:
|
||||
return nil
|
||||
case *ast.Self:
|
||||
return nil
|
||||
case *ast.SuperIndex:
|
||||
|
@ -724,11 +724,14 @@ func (p *parser) parseTerminal() (ast.Node, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_, err = p.popExpect(tokenParenR)
|
||||
tokRight, err := p.popExpect(tokenParenR)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return inner, nil
|
||||
return &ast.Parens{
|
||||
NodeBase: ast.NewNodeBaseLoc(locFromTokens(tok, tokRight)),
|
||||
Inner: inner,
|
||||
}, nil
|
||||
|
||||
// Literals
|
||||
case tokenNumber:
|
||||
|
@ -229,9 +229,9 @@ var errorTests = []testError{
|
||||
{`function a a`, `test:1:10-11 Expected ( but got (IDENTIFIER, "a")`},
|
||||
|
||||
{`import (a b)`, `test:1:11-12 Expected token ")" but got (IDENTIFIER, "b")`},
|
||||
{`import (a+b)`, `test:1:9-12 Computed imports are not allowed`},
|
||||
{`import (a+b)`, `test:1:8-13 Computed imports are not allowed`},
|
||||
{`importstr (a b)`, `test:1:14-15 Expected token ")" but got (IDENTIFIER, "b")`},
|
||||
{`importstr (a+b)`, `test:1:12-15 Computed imports are not allowed`},
|
||||
{`importstr (a+b)`, `test:1:11-16 Computed imports are not allowed`},
|
||||
|
||||
{`local a = b ()`, `test:1:15 Expected , or ; but got end of file`},
|
||||
{`local a = b; (a b)`, `test:1:17-18 Expected token ")" but got (IDENTIFIER, "b")`},
|
||||
|
2
testdata/div4.golden
vendored
2
testdata/div4.golden
vendored
@ -1,6 +1,6 @@
|
||||
RUNTIME ERROR: Overflow
|
||||
-------------------------------------------------
|
||||
testdata/div4:1:1-19 $
|
||||
testdata/div4:1:1-20 $
|
||||
|
||||
1/(1e-160)/(1e-160)
|
||||
|
||||
|
2
testdata/error_function_fail.golden
vendored
2
testdata/error_function_fail.golden
vendored
@ -1,6 +1,6 @@
|
||||
RUNTIME ERROR: Couldn't manifest function in JSON output.
|
||||
-------------------------------------------------
|
||||
testdata/error_function_fail:1:1-22 $
|
||||
testdata/error_function_fail:1:1-23 $
|
||||
|
||||
error (function(x) 42)
|
||||
|
||||
|
2
testdata/percent_bad2.golden
vendored
2
testdata/percent_bad2.golden
vendored
@ -1,6 +1,6 @@
|
||||
RUNTIME ERROR: Too many values to format: 1, expected 0
|
||||
-------------------------------------------------
|
||||
<std>:576:21-95 function <format_codes_arr>
|
||||
<std>:576:21-96 function <format_codes_arr>
|
||||
|
||||
error ("Too many values to format: " + std.length(arr) + ", expected " + j)
|
||||
|
||||
|
2
testdata/percent_format_str4.golden
vendored
2
testdata/percent_format_str4.golden
vendored
@ -1,6 +1,6 @@
|
||||
RUNTIME ERROR: Too many values to format: 2, expected 1
|
||||
-------------------------------------------------
|
||||
<std>:576:21-95 function <format_codes_arr>
|
||||
<std>:576:21-96 function <format_codes_arr>
|
||||
|
||||
error ("Too many values to format: " + std.length(arr) + ", expected " + j)
|
||||
|
||||
|
2
testdata/string_plus_function.golden
vendored
2
testdata/string_plus_function.golden
vendored
@ -1,6 +1,6 @@
|
||||
RUNTIME ERROR: Couldn't manifest function in JSON output.
|
||||
-------------------------------------------------
|
||||
testdata/string_plus_function:1:1-23 $
|
||||
testdata/string_plus_function:1:1-24 $
|
||||
|
||||
"xxx" + (function() 42)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user