1
1
mirror of https://github.com/github/semantic.git synced 2024-11-29 02:44:36 +03:00

Merge branch 'master' into interpreter-decomposition

This commit is contained in:
Rob Rix 2017-02-24 11:43:48 -05:00 committed by GitHub
commit 8b5dfbee42
337 changed files with 5641 additions and 0 deletions

View File

@ -22,9 +22,11 @@ import Test.Hspec.Expectations.Pretty
spec :: Spec
spec = parallel $ do
it "lists example fixtures" $ do
examples "test/fixtures/go/" `shouldNotReturn` []
examples "test/fixtures/ruby/" `shouldNotReturn` []
examples "test/fixtures/javascript/" `shouldNotReturn` []
describe "go" $ runTestsIn "test/fixtures/go/"
describe "javascript" $ runTestsIn "test/fixtures/javascript/"
describe "ruby" $ runTestsIn "test/fixtures/ruby/"

5
test/fixtures/go/array-types.A.go vendored Normal file
View File

@ -0,0 +1,5 @@
package main
func main() {
type a [2+2]x
}

5
test/fixtures/go/array-types.B.go vendored Normal file
View File

@ -0,0 +1,5 @@
package main
func main() {
type a [1+1]y
}

View File

@ -0,0 +1,16 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(Other "type_declaration"
(TypeDecl
(Identifier)
(ArrayTy
(RelationalOperator
{ (NumberLiteral)
->(NumberLiteral) }
{ (NumberLiteral)
->(NumberLiteral) })
{ (Identifier)
->(Identifier) })))))

View File

@ -0,0 +1,16 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(Other "type_declaration"
(TypeDecl
(Identifier)
(ArrayTy
(RelationalOperator
{ (NumberLiteral)
->(NumberLiteral) }
{ (NumberLiteral)
->(NumberLiteral) })
{ (Identifier)
->(Identifier) })))))

13
test/fixtures/go/array-types.parseA.txt vendored Normal file
View File

@ -0,0 +1,13 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(Other "type_declaration"
(TypeDecl
(Identifier)
(ArrayTy
(RelationalOperator
(NumberLiteral)
(NumberLiteral))
(Identifier))))))

13
test/fixtures/go/array-types.parseB.txt vendored Normal file
View File

@ -0,0 +1,13 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(Other "type_declaration"
(TypeDecl
(Identifier)
(ArrayTy
(RelationalOperator
(NumberLiteral)
(NumberLiteral))
(Identifier))))))

View File

@ -0,0 +1,5 @@
package main
func main() {
const a1 = [...]int{1, 2, 3}
}

View File

@ -0,0 +1,5 @@
package main
func main() {
const a1 = [...]int{4,5,6}
}

View File

@ -0,0 +1,24 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(Other "const_declaration"
(VarAssignment
(Other "identifier_list"
(Identifier))
(Other "expression_list"
(Other "composite_literal"
(ArrayTy
(Identifier))
{+(Element
(NumberLiteral))+}
{+(Element
(NumberLiteral))+}
(Element
{ (NumberLiteral)
->(NumberLiteral) })
{-(Element
(NumberLiteral))-}
{-(Element
(NumberLiteral))-}))))))

View File

@ -0,0 +1,24 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(Other "const_declaration"
(VarAssignment
(Other "identifier_list"
(Identifier))
(Other "expression_list"
(Other "composite_literal"
(ArrayTy
(Identifier))
{+(Element
(NumberLiteral))+}
(Element
{ (NumberLiteral)
->(NumberLiteral) })
{+(Element
(NumberLiteral))+}
{-(Element
(NumberLiteral))-}
{-(Element
(NumberLiteral))-}))))))

View File

@ -0,0 +1,19 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(Other "const_declaration"
(VarAssignment
(Other "identifier_list"
(Identifier))
(Other "expression_list"
(Other "composite_literal"
(ArrayTy
(Identifier))
(Element
(NumberLiteral))
(Element
(NumberLiteral))
(Element
(NumberLiteral))))))))

View File

@ -0,0 +1,19 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(Other "const_declaration"
(VarAssignment
(Other "identifier_list"
(Identifier))
(Other "expression_list"
(Other "composite_literal"
(ArrayTy
(Identifier))
(Element
(NumberLiteral))
(Element
(NumberLiteral))
(Element
(NumberLiteral))))))))

View File

@ -0,0 +1,8 @@
package main
func main() {
a = 1
b, c += 2, 3
d *= 3
e += 1
}

View File

@ -0,0 +1,8 @@
package main
func main() {
x = 1
y, c += 2, 3
z *= 3
h += 1
}

View File

@ -0,0 +1,31 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(Assignment
(Other "expression_list"
{ (Identifier)
->(Identifier) })
(Other "expression_list"
(NumberLiteral)))
(Assignment
(Other "expression_list"
{ (Identifier)
->(Identifier) }
(Identifier))
(Other "expression_list"
(NumberLiteral)
(NumberLiteral)))
(Assignment
(Other "expression_list"
{ (Identifier)
->(Identifier) })
(Other "expression_list"
(NumberLiteral)))
(Assignment
(Other "expression_list"
{ (Identifier)
->(Identifier) })
(Other "expression_list"
(NumberLiteral)))))

View File

@ -0,0 +1,31 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(Assignment
(Other "expression_list"
{ (Identifier)
->(Identifier) })
(Other "expression_list"
(NumberLiteral)))
(Assignment
(Other "expression_list"
{ (Identifier)
->(Identifier) }
(Identifier))
(Other "expression_list"
(NumberLiteral)
(NumberLiteral)))
(Assignment
(Other "expression_list"
{ (Identifier)
->(Identifier) })
(Other "expression_list"
(NumberLiteral)))
(Assignment
(Other "expression_list"
{ (Identifier)
->(Identifier) })
(Other "expression_list"
(NumberLiteral)))))

View File

@ -0,0 +1,27 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(Assignment
(Other "expression_list"
(Identifier))
(Other "expression_list"
(NumberLiteral)))
(Assignment
(Other "expression_list"
(Identifier)
(Identifier))
(Other "expression_list"
(NumberLiteral)
(NumberLiteral)))
(Assignment
(Other "expression_list"
(Identifier))
(Other "expression_list"
(NumberLiteral)))
(Assignment
(Other "expression_list"
(Identifier))
(Other "expression_list"
(NumberLiteral)))))

View File

@ -0,0 +1,27 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(Assignment
(Other "expression_list"
(Identifier))
(Other "expression_list"
(NumberLiteral)))
(Assignment
(Other "expression_list"
(Identifier)
(Identifier))
(Other "expression_list"
(NumberLiteral)
(NumberLiteral)))
(Assignment
(Other "expression_list"
(Identifier))
(Other "expression_list"
(NumberLiteral)))
(Assignment
(Other "expression_list"
(Identifier))
(Other "expression_list"
(NumberLiteral)))))

View File

@ -0,0 +1,7 @@
package main
func main() {
x(b, c...)
y(b, c,)
z(b,c...,)
}

View File

@ -0,0 +1,7 @@
package main
func main() {
a(b, c...)
b(b, c,)
c(b,c...,)
}

View File

@ -0,0 +1,20 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(FunctionCall
{ (Identifier)
->(Identifier) }
(Identifier)
(Identifier))
(FunctionCall
{ (Identifier)
->(Identifier) }
(Identifier)
(Identifier))
(FunctionCall
{ (Identifier)
->(Identifier) }
(Identifier)
(Identifier))))

View File

@ -0,0 +1,20 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(FunctionCall
{ (Identifier)
->(Identifier) }
(Identifier)
(Identifier))
(FunctionCall
{ (Identifier)
->(Identifier) }
(Identifier)
(Identifier))
(FunctionCall
{ (Identifier)
->(Identifier) }
(Identifier)
(Identifier))))

View File

@ -0,0 +1,17 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(FunctionCall
(Identifier)
(Identifier)
(Identifier))
(FunctionCall
(Identifier)
(Identifier)
(Identifier))
(FunctionCall
(Identifier)
(Identifier)
(Identifier))))

View File

@ -0,0 +1,17 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(FunctionCall
(Identifier)
(Identifier)
(Identifier))
(FunctionCall
(Identifier)
(Identifier)
(Identifier))
(FunctionCall
(Identifier)
(Identifier)
(Identifier))))

5
test/fixtures/go/case-statements.A.go vendored Normal file
View File

@ -0,0 +1,5 @@
package main
func main() {
switch { }
}

5
test/fixtures/go/case-statements.B.go vendored Normal file
View File

@ -0,0 +1,5 @@
package main
func main() {
switch { case foo: f1() }
}

View File

@ -0,0 +1,12 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(Switch
{+(Case
(Case
(Other "expression_list"
(Identifier)))
(FunctionCall
(Identifier)))+})))

View File

@ -0,0 +1,12 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(Switch
{-(Case
(Case
(Other "expression_list"
(Identifier)))
(FunctionCall
(Identifier)))-})))

View File

@ -0,0 +1,6 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(Switch)))

View File

@ -0,0 +1,12 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(Switch
(Case
(Case
(Other "expression_list"
(Identifier)))
(FunctionCall
(Identifier))))))

9
test/fixtures/go/channel-types.A.go vendored Normal file
View File

@ -0,0 +1,9 @@
package main
func main() {
type (
c1 chan<- chan int
c2 chan<- chan<- struct{}
c3 chan<- <-chan int
)
}

9
test/fixtures/go/channel-types.B.go vendored Normal file
View File

@ -0,0 +1,9 @@
package main
func main() {
type (
c2 chan<- chan string
c3 chan<- chan<- struct{}
c4 chan<- <-chan string
)
}

View File

@ -0,0 +1,26 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(Other "type_declaration"
(TypeDecl
{ (Identifier)
->(Identifier) }
(ChannelTy
(ChannelTy
{ (Identifier)
->(Identifier) })))
(TypeDecl
{ (Identifier)
->(Identifier) }
(ChannelTy
(ChannelTy
(StructTy))))
(TypeDecl
{ (Identifier)
->(Identifier) }
(ChannelTy
(ChannelTy
{ (Identifier)
->(Identifier) }))))))

View File

@ -0,0 +1,26 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(Other "type_declaration"
(TypeDecl
{ (Identifier)
->(Identifier) }
(ChannelTy
(ChannelTy
{ (Identifier)
->(Identifier) })))
(TypeDecl
{ (Identifier)
->(Identifier) }
(ChannelTy
(ChannelTy
(StructTy))))
(TypeDecl
{ (Identifier)
->(Identifier) }
(ChannelTy
(ChannelTy
{ (Identifier)
->(Identifier) }))))))

View File

@ -0,0 +1,21 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(Other "type_declaration"
(TypeDecl
(Identifier)
(ChannelTy
(ChannelTy
(Identifier))))
(TypeDecl
(Identifier)
(ChannelTy
(ChannelTy
(StructTy))))
(TypeDecl
(Identifier)
(ChannelTy
(ChannelTy
(Identifier)))))))

View File

@ -0,0 +1,21 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(Other "type_declaration"
(TypeDecl
(Identifier)
(ChannelTy
(ChannelTy
(Identifier))))
(TypeDecl
(Identifier)
(ChannelTy
(ChannelTy
(StructTy))))
(TypeDecl
(Identifier)
(ChannelTy
(ChannelTy
(Identifier)))))))

5
test/fixtures/go/comment.A.go vendored Normal file
View File

@ -0,0 +1,5 @@
package main
func main() {
// this is a comment
}

7
test/fixtures/go/comment.B.go vendored Normal file
View File

@ -0,0 +1,7 @@
package main
func main() {
/*
this is a block comment
*/
}

7
test/fixtures/go/comment.diffA-B.txt vendored Normal file
View File

@ -0,0 +1,7 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
{ (Comment)
->(Comment) }))

7
test/fixtures/go/comment.diffB-A.txt vendored Normal file
View File

@ -0,0 +1,7 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
{ (Comment)
->(Comment) }))

6
test/fixtures/go/comment.parseA.txt vendored Normal file
View File

@ -0,0 +1,6 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(Comment)))

6
test/fixtures/go/comment.parseB.txt vendored Normal file
View File

@ -0,0 +1,6 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(Comment)))

View File

@ -0,0 +1,5 @@
package main
func main() {
const zero int = 0
}

View File

@ -0,0 +1,5 @@
package main
func main() {
const one, two uiint64 = 1, 2
}

View File

@ -0,0 +1,17 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(Other "const_declaration"
(VarAssignment
(Other "identifier_list"
{ (Identifier)
->(Identifier) }
{+(Identifier)+})
{ (Identifier)
->(Identifier) }
(Other "expression_list"
{ (NumberLiteral)
->(NumberLiteral) }
{+(NumberLiteral)+})))))

View File

@ -0,0 +1,17 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(Other "const_declaration"
(VarAssignment
(Other "identifier_list"
{ (Identifier)
->(Identifier) }
{-(Identifier)-})
{ (Identifier)
->(Identifier) }
(Other "expression_list"
{ (NumberLiteral)
->(NumberLiteral) }
{-(NumberLiteral)-})))))

View File

@ -0,0 +1,12 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(Other "const_declaration"
(VarAssignment
(Other "identifier_list"
(Identifier))
(Identifier)
(Other "expression_list"
(NumberLiteral))))))

View File

@ -0,0 +1,14 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(Other "const_declaration"
(VarAssignment
(Other "identifier_list"
(Identifier)
(Identifier))
(Identifier)
(Other "expression_list"
(NumberLiteral)
(NumberLiteral))))))

View File

@ -0,0 +1,5 @@
package main
func main() {
const zero = 0
}

View File

@ -0,0 +1,5 @@
package main
func main() {
const one, two = 1, 2
}

View File

@ -0,0 +1,15 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(Other "const_declaration"
(VarAssignment
(Other "identifier_list"
{ (Identifier)
->(Identifier) }
{+(Identifier)+})
(Other "expression_list"
{ (NumberLiteral)
->(NumberLiteral) }
{+(NumberLiteral)+})))))

View File

@ -0,0 +1,15 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(Other "const_declaration"
(VarAssignment
(Other "identifier_list"
{ (Identifier)
->(Identifier) }
{-(Identifier)-})
(Other "expression_list"
{ (NumberLiteral)
->(NumberLiteral) }
{-(NumberLiteral)-})))))

View File

@ -0,0 +1,11 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(Other "const_declaration"
(VarAssignment
(Other "identifier_list"
(Identifier))
(Other "expression_list"
(NumberLiteral))))))

View File

@ -0,0 +1,13 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(Other "const_declaration"
(VarAssignment
(Other "identifier_list"
(Identifier)
(Identifier))
(Other "expression_list"
(NumberLiteral)
(NumberLiteral))))))

View File

@ -0,0 +1,9 @@
package main
func main() {
const (
zero = iota
one
two
)
}

View File

@ -0,0 +1,9 @@
package main
func main() {
const (
a = iota
b
c
)
}

View File

@ -0,0 +1,20 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(Other "const_declaration"
(VarAssignment
(Other "identifier_list"
{ (Identifier)
->(Identifier) })
(Other "expression_list"
(Identifier)))
(VarAssignment
(Other "identifier_list"
{ (Identifier)
->(Identifier) }))
(VarAssignment
(Other "identifier_list"
{ (Identifier)
->(Identifier) })))))

View File

@ -0,0 +1,20 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(Other "const_declaration"
(VarAssignment
(Other "identifier_list"
{ (Identifier)
->(Identifier) })
(Other "expression_list"
(Identifier)))
(VarAssignment
(Other "identifier_list"
{ (Identifier)
->(Identifier) }))
(VarAssignment
(Other "identifier_list"
{ (Identifier)
->(Identifier) })))))

View File

@ -0,0 +1,17 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(Other "const_declaration"
(VarAssignment
(Other "identifier_list"
(Identifier))
(Other "expression_list"
(Identifier)))
(VarAssignment
(Other "identifier_list"
(Identifier)))
(VarAssignment
(Other "identifier_list"
(Identifier))))))

View File

@ -0,0 +1,17 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(Other "const_declaration"
(VarAssignment
(Other "identifier_list"
(Identifier))
(Other "expression_list"
(Identifier)))
(VarAssignment
(Other "identifier_list"
(Identifier)))
(VarAssignment
(Other "identifier_list"
(Identifier))))))

8
test/fixtures/go/constructors.A.go vendored Normal file
View File

@ -0,0 +1,8 @@
package main
func main() {
make(chan<- int)
make(chan<- int, (new - old))
make(chan<- int, 5, 10)
new(map[string]string)
}

8
test/fixtures/go/constructors.B.go vendored Normal file
View File

@ -0,0 +1,8 @@
package main
func main() {
make(chan<- string)
make(chan<- string, (new - old))
make(chan<- string, 7, 11)
new(map[int]int)
}

View File

@ -0,0 +1,34 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(FunctionCall
(Identifier)
(ChannelTy
{ (Identifier)
->(Identifier) }))
(FunctionCall
(Identifier)
(ChannelTy
{ (Identifier)
->(Identifier) })
(RelationalOperator
(Identifier)
(Identifier)))
(FunctionCall
(Identifier)
(ChannelTy
{ (Identifier)
->(Identifier) })
{ (NumberLiteral)
->(NumberLiteral) }
{ (NumberLiteral)
->(NumberLiteral) })
(FunctionCall
(Identifier)
(DictionaryTy
{ (Identifier)
->(Identifier) }
{ (Identifier)
->(Identifier) }))))

View File

@ -0,0 +1,34 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(FunctionCall
(Identifier)
(ChannelTy
{ (Identifier)
->(Identifier) }))
(FunctionCall
(Identifier)
(ChannelTy
{ (Identifier)
->(Identifier) })
(RelationalOperator
(Identifier)
(Identifier)))
(FunctionCall
(Identifier)
(ChannelTy
{ (Identifier)
->(Identifier) })
{ (NumberLiteral)
->(NumberLiteral) }
{ (NumberLiteral)
->(NumberLiteral) })
(FunctionCall
(Identifier)
(DictionaryTy
{ (Identifier)
->(Identifier) }
{ (Identifier)
->(Identifier) }))))

View File

@ -0,0 +1,27 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(FunctionCall
(Identifier)
(ChannelTy
(Identifier)))
(FunctionCall
(Identifier)
(ChannelTy
(Identifier))
(RelationalOperator
(Identifier)
(Identifier)))
(FunctionCall
(Identifier)
(ChannelTy
(Identifier))
(NumberLiteral)
(NumberLiteral))
(FunctionCall
(Identifier)
(DictionaryTy
(Identifier)
(Identifier)))))

View File

@ -0,0 +1,27 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(FunctionCall
(Identifier)
(ChannelTy
(Identifier)))
(FunctionCall
(Identifier)
(ChannelTy
(Identifier))
(RelationalOperator
(Identifier)
(Identifier)))
(FunctionCall
(Identifier)
(ChannelTy
(Identifier))
(NumberLiteral)
(NumberLiteral))
(FunctionCall
(Identifier)
(DictionaryTy
(Identifier)
(Identifier)))))

9
test/fixtures/go/float-literals.A.go vendored Normal file
View File

@ -0,0 +1,9 @@
package main
func main() {
f1 = 1.5
f2 = 1.5e100
f3 = 1.5e+50
f4 = 1.5e-5
f5 = .5e-50
}

9
test/fixtures/go/float-literals.B.go vendored Normal file
View File

@ -0,0 +1,9 @@
package main
func main() {
f1 = 2.6
f2 = 2.6e211
f3 = 2.6e+60
f4 = 2.6e-7
f5 = .6e-60
}

View File

@ -0,0 +1,35 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(Assignment
(Other "expression_list"
(Identifier))
(Other "expression_list"
{ (FloatLiteral)
->(FloatLiteral) }))
(Assignment
(Other "expression_list"
(Identifier))
(Other "expression_list"
{ (FloatLiteral)
->(FloatLiteral) }))
(Assignment
(Other "expression_list"
(Identifier))
(Other "expression_list"
{ (FloatLiteral)
->(FloatLiteral) }))
(Assignment
(Other "expression_list"
(Identifier))
(Other "expression_list"
{ (FloatLiteral)
->(FloatLiteral) }))
(Assignment
(Other "expression_list"
(Identifier))
(Other "expression_list"
{ (FloatLiteral)
->(FloatLiteral) }))))

View File

@ -0,0 +1,35 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(Assignment
(Other "expression_list"
(Identifier))
(Other "expression_list"
{ (FloatLiteral)
->(FloatLiteral) }))
(Assignment
(Other "expression_list"
(Identifier))
(Other "expression_list"
{ (FloatLiteral)
->(FloatLiteral) }))
(Assignment
(Other "expression_list"
(Identifier))
(Other "expression_list"
{ (FloatLiteral)
->(FloatLiteral) }))
(Assignment
(Other "expression_list"
(Identifier))
(Other "expression_list"
{ (FloatLiteral)
->(FloatLiteral) }))
(Assignment
(Other "expression_list"
(Identifier))
(Other "expression_list"
{ (FloatLiteral)
->(FloatLiteral) }))))

View File

@ -0,0 +1,30 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(Assignment
(Other "expression_list"
(Identifier))
(Other "expression_list"
(FloatLiteral)))
(Assignment
(Other "expression_list"
(Identifier))
(Other "expression_list"
(FloatLiteral)))
(Assignment
(Other "expression_list"
(Identifier))
(Other "expression_list"
(FloatLiteral)))
(Assignment
(Other "expression_list"
(Identifier))
(Other "expression_list"
(FloatLiteral)))
(Assignment
(Other "expression_list"
(Identifier))
(Other "expression_list"
(FloatLiteral)))))

View File

@ -0,0 +1,30 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(Assignment
(Other "expression_list"
(Identifier))
(Other "expression_list"
(FloatLiteral)))
(Assignment
(Other "expression_list"
(Identifier))
(Other "expression_list"
(FloatLiteral)))
(Assignment
(Other "expression_list"
(Identifier))
(Other "expression_list"
(FloatLiteral)))
(Assignment
(Other "expression_list"
(Identifier))
(Other "expression_list"
(FloatLiteral)))
(Assignment
(Other "expression_list"
(Identifier))
(Other "expression_list"
(FloatLiteral)))))

24
test/fixtures/go/for-statements.A.go vendored Normal file
View File

@ -0,0 +1,24 @@
package main
func main() {
for {
a()
goto loop
}
for i := 0; i < 5; i++ {
a()
break loop
}
for ; i < 10; i++ {
a()
continue loop2
}
for ;; {
a()
continue
}
for x := range y {
a(x)
break
}
}

24
test/fixtures/go/for-statements.B.go vendored Normal file
View File

@ -0,0 +1,24 @@
package main
func main() {
for ;; {
a()
goto loop
}
for x := range y {
a()
break loop
}
for ;; {
a()
continue loop2
}
for ; i < 10; i++ {
a()
continue
}
for {
a(x)
break
}
}

View File

@ -0,0 +1,74 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
{+(For
(FunctionCall
(Identifier))
(Other "goto_statement"
(Identifier)))+}
{+(For
(Other "expression_list"
(Identifier))
(Identifier)
(FunctionCall
(Identifier))
(Break
(Identifier)))+}
{+(For
(FunctionCall
(Identifier))
(Continue
(Identifier)))+}
{+(For
(RelationalOperator
(Identifier)
(NumberLiteral))
(IncrementStatement)
(FunctionCall
(Identifier))
(Continue))+}
(For
(ExpressionStatements
(FunctionCall
(Identifier)
{+(Identifier)+})
{+(Break)+}
{-(Other "goto_statement"
(Identifier))-}))
{-(For
(VarDecl
(Other "expression_list"
(Identifier))
(Other "expression_list"
(NumberLiteral)))
(RelationalOperator
(Identifier)
(NumberLiteral))
(IncrementStatement)
(FunctionCall
(Identifier))
(Break
(Identifier)))-}
{-(For
(RelationalOperator
(Identifier)
(NumberLiteral))
(IncrementStatement)
(FunctionCall
(Identifier))
(Continue
(Identifier)))-}
{-(For
(FunctionCall
(Identifier))
(Continue))-}
{-(For
(Other "expression_list"
(Identifier))
(Identifier)
(FunctionCall
(Identifier)
(Identifier))
(Break))-}))

View File

@ -0,0 +1,71 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
{+(For
(ExpressionStatements
(FunctionCall
(Identifier))
(Other "goto_statement"
(Identifier))))+}
{+(For
(VarDecl
(Other "expression_list"
(Identifier))
(Other "expression_list"
(NumberLiteral)))
(RelationalOperator
(Identifier)
(NumberLiteral))
(IncrementStatement)
(FunctionCall
(Identifier))
(Break
(Identifier)))+}
{+(For
(RelationalOperator
(Identifier)
(NumberLiteral))
(IncrementStatement)
(FunctionCall
(Identifier))
(Continue
(Identifier)))+}
{ (For
(FunctionCall
(Identifier))
(Other "goto_statement"
(Identifier)))
->(For
(FunctionCall
(Identifier))
(Continue)) }
(For
(Other "expression_list"
(Identifier))
(Identifier)
(FunctionCall
(Identifier)
{+(Identifier)+})
(Break
{-(Identifier)-}))
{-(For
(FunctionCall
(Identifier))
(Continue
(Identifier)))-}
{-(For
(RelationalOperator
(Identifier)
(NumberLiteral))
(IncrementStatement)
(FunctionCall
(Identifier))
(Continue))-}
{-(For
(ExpressionStatements
(FunctionCall
(Identifier)
(Identifier))
(Break)))-}))

View File

@ -0,0 +1,46 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(For
(ExpressionStatements
(FunctionCall
(Identifier))
(Other "goto_statement"
(Identifier))))
(For
(VarDecl
(Other "expression_list"
(Identifier))
(Other "expression_list"
(NumberLiteral)))
(RelationalOperator
(Identifier)
(NumberLiteral))
(IncrementStatement)
(FunctionCall
(Identifier))
(Break
(Identifier)))
(For
(RelationalOperator
(Identifier)
(NumberLiteral))
(IncrementStatement)
(FunctionCall
(Identifier))
(Continue
(Identifier)))
(For
(FunctionCall
(Identifier))
(Continue))
(For
(Other "expression_list"
(Identifier))
(Identifier)
(FunctionCall
(Identifier)
(Identifier))
(Break))))

View File

@ -0,0 +1,37 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(For
(FunctionCall
(Identifier))
(Other "goto_statement"
(Identifier)))
(For
(Other "expression_list"
(Identifier))
(Identifier)
(FunctionCall
(Identifier))
(Break
(Identifier)))
(For
(FunctionCall
(Identifier))
(Continue
(Identifier)))
(For
(RelationalOperator
(Identifier)
(NumberLiteral))
(IncrementStatement)
(FunctionCall
(Identifier))
(Continue))
(For
(ExpressionStatements
(FunctionCall
(Identifier)
(Identifier))
(Break)))))

View File

@ -0,0 +1,8 @@
package main
func main() {
func f1() {}
func f2(a int, b, c, d string) int {}
func f2() (int, error) {}
func f2() (result int, err error) {}
}

View File

@ -0,0 +1,8 @@
package main
func main() {
func fa() {}
func fb(a int, b, c, d string) int {}
func fc() (int, error) {}
func fd() (result int, err error) {}
}

View File

@ -0,0 +1,38 @@
(ParseError
(Program
(Module
(Identifier))
(Function
(Identifier)
(ParseError
(FunctionCall
{ (Identifier)
->(Identifier) })))
(Function
{ (Identifier)
->(Identifier) }
(ParameterDecl
(Identifier)
(Identifier))
(Identifier)
(Identifier)
(ParameterDecl
(Identifier)
(Identifier))
(Identifier))
(Function
{ (Identifier)
->(Identifier) }
(Args
(Identifier)
(Identifier)))
(Function
{ (Identifier)
->(Identifier) }
(Args
(ParameterDecl
(Identifier)
(Identifier))
(ParameterDecl
(Identifier)
(Identifier))))))

View File

@ -0,0 +1,38 @@
(ParseError
(Program
(Module
(Identifier))
(Function
(Identifier)
(ParseError
(FunctionCall
{ (Identifier)
->(Identifier) })))
(Function
{ (Identifier)
->(Identifier) }
(ParameterDecl
(Identifier)
(Identifier))
(Identifier)
(Identifier)
(ParameterDecl
(Identifier)
(Identifier))
(Identifier))
(Function
{ (Identifier)
->(Identifier) }
(Args
(Identifier)
(Identifier)))
(Function
{ (Identifier)
->(Identifier) }
(Args
(ParameterDecl
(Identifier)
(Identifier))
(ParameterDecl
(Identifier)
(Identifier))))))

View File

@ -0,0 +1,34 @@
(ParseError
(Program
(Module
(Identifier))
(Function
(Identifier)
(ParseError
(FunctionCall
(Identifier))))
(Function
(Identifier)
(ParameterDecl
(Identifier)
(Identifier))
(Identifier)
(Identifier)
(ParameterDecl
(Identifier)
(Identifier))
(Identifier))
(Function
(Identifier)
(Args
(Identifier)
(Identifier)))
(Function
(Identifier)
(Args
(ParameterDecl
(Identifier)
(Identifier))
(ParameterDecl
(Identifier)
(Identifier))))))

View File

@ -0,0 +1,34 @@
(ParseError
(Program
(Module
(Identifier))
(Function
(Identifier)
(ParseError
(FunctionCall
(Identifier))))
(Function
(Identifier)
(ParameterDecl
(Identifier)
(Identifier))
(Identifier)
(Identifier)
(ParameterDecl
(Identifier)
(Identifier))
(Identifier))
(Function
(Identifier)
(Args
(Identifier)
(Identifier)))
(Function
(Identifier)
(Args
(ParameterDecl
(Identifier)
(Identifier))
(ParameterDecl
(Identifier)
(Identifier))))))

View File

@ -0,0 +1,7 @@
package main
func main() {
const s1 = func(s string) (int, int) {
return 1, 2
}
}

View File

@ -0,0 +1,7 @@
package main
func main() {
const s1 = func(b int) (string, string) {
return 1, 2
}
}

View File

@ -0,0 +1,19 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(Other "const_declaration"
(VarAssignment
(Other "identifier_list"
(Identifier))
(Other "expression_list"
(AnonymousFunction
{ (Identifier)
->(Identifier) }
{ (Identifier)
->(Identifier) }
(Return
(Other "expression_list"
(NumberLiteral)
(NumberLiteral)))))))))

View File

@ -0,0 +1,19 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(Other "const_declaration"
(VarAssignment
(Other "identifier_list"
(Identifier))
(Other "expression_list"
(AnonymousFunction
{ (Identifier)
->(Identifier) }
{ (Identifier)
->(Identifier) }
(Return
(Other "expression_list"
(NumberLiteral)
(NumberLiteral)))))))))

View File

@ -0,0 +1,17 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(Other "const_declaration"
(VarAssignment
(Other "identifier_list"
(Identifier))
(Other "expression_list"
(AnonymousFunction
(Identifier)
(Identifier)
(Return
(Other "expression_list"
(NumberLiteral)
(NumberLiteral)))))))))

View File

@ -0,0 +1,17 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(Other "const_declaration"
(VarAssignment
(Other "identifier_list"
(Identifier))
(Other "expression_list"
(AnonymousFunction
(Identifier)
(Identifier)
(Return
(Other "expression_list"
(NumberLiteral)
(NumberLiteral)))))))))

8
test/fixtures/go/function-types.A.go vendored Normal file
View File

@ -0,0 +1,8 @@
package main
func main() {
type (
a func(int) int
b func(int, string) (bool, error)
)
}

8
test/fixtures/go/function-types.B.go vendored Normal file
View File

@ -0,0 +1,8 @@
package main
func main() {
type (
x func(string) string
y func(string, int) (chan, error)
)
}

View File

@ -0,0 +1,30 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(Other "type_declaration"
(TypeDecl
{ (Identifier)
->(Identifier) }
(FunctionTy
(Args
{ (Identifier)
->(Identifier) })
{ (Identifier)
->(Identifier) }))
(TypeDecl
{ (Identifier)
->(Identifier) }
(FunctionTy
(Args
{-(Identifier)-}
(Identifier)
{+(Identifier)+})
(Args
{+(ParameterDecl
(ChannelTy
(ParseError)
(Identifier)))+}
{-(Identifier)-}
{-(Identifier)-}))))))

View File

@ -0,0 +1,30 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(Other "type_declaration"
(TypeDecl
{ (Identifier)
->(Identifier) }
(FunctionTy
(Args
{ (Identifier)
->(Identifier) })
{ (Identifier)
->(Identifier) }))
(TypeDecl
{ (Identifier)
->(Identifier) }
(FunctionTy
(Args
{-(Identifier)-}
(Identifier)
{+(Identifier)+})
(Args
{+(Identifier)+}
{+(Identifier)+}
{-(ParameterDecl
(ChannelTy
(ParseError)
(Identifier)))-}))))))

View File

@ -0,0 +1,21 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(Other "type_declaration"
(TypeDecl
(Identifier)
(FunctionTy
(Args
(Identifier))
(Identifier)))
(TypeDecl
(Identifier)
(FunctionTy
(Args
(Identifier)
(Identifier))
(Args
(Identifier)
(Identifier)))))))

View File

@ -0,0 +1,23 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(Other "type_declaration"
(TypeDecl
(Identifier)
(FunctionTy
(Args
(Identifier))
(Identifier)))
(TypeDecl
(Identifier)
(FunctionTy
(Args
(Identifier)
(Identifier))
(Args
(ParameterDecl
(ChannelTy
(ParseError)
(Identifier)))))))))

View File

@ -0,0 +1,6 @@
package main
func main() {
defer x.y()
go x.y()
}

View File

@ -0,0 +1,6 @@
package main
func main() {
defer a.b()
go c.d()
}

View File

@ -0,0 +1,19 @@
(Program
(Module
(Identifier))
(Function
(Identifier)
(Defer
(FunctionCall
(SubscriptAccess
{ (Identifier)
->(Identifier) }
{ (Identifier)
->(Identifier) })))
(Go
(FunctionCall
(SubscriptAccess
{ (Identifier)
->(Identifier) }
{ (Identifier)
->(Identifier) })))))

Some files were not shown because too many files have changed in this diff Show More