Skip to content

Commit 7746530

Browse files
committed
Merge branch 'go'
2 parents 2fff43c + 1a44e23 commit 7746530

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+8150
-108
lines changed

autoload/vimlparser.vim

+230-108
Large diffs are not rendered by default.

cmd/vimlparser/main.go

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package main
2+
3+
import (
4+
"flag"
5+
"fmt"
6+
"log"
7+
"os"
8+
9+
"github.com/haya14busa/go-vimlparser"
10+
)
11+
12+
func main() {
13+
flag.Parse()
14+
15+
r := os.Stdin
16+
17+
if p := flag.Arg(0); p != "" {
18+
f, err := os.Open(p)
19+
if err != nil {
20+
log.Fatal(err)
21+
}
22+
r = f
23+
}
24+
25+
node, err := vimlparser.Parse(r)
26+
if err != nil {
27+
log.Fatal(err)
28+
}
29+
if err := vimlparser.Compile(os.Stdout, node); err != nil {
30+
log.Fatal(err)
31+
}
32+
fmt.Printf("\n")
33+
}

go/_test/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.out

go/_test/comment.go

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// this is comment
2+
var x = 1
3+
// cannot keep inline comment

go/_test/comment.vim

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
" this is comment
2+
let x = 1 " cannot keep inline comment

go/_test/dict.go

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
var x = map[string]interface{}{}
2+
var y = map[string]interface{}{"a":1, "b":"string"}

go/_test/dict.vim

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
let x = {}
2+
let y = { 'a': 1, 'b': 'string'}

go/_test/empty.go

Whitespace-only changes.

go/_test/empty.vim

Whitespace-only changes.

go/_test/for.go

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
for _, x := range xs {
2+
var y = x
3+
x = 1
4+
}
5+
func Func() {
6+
for _, y := range ys {
7+
}
8+
// for creates scope
9+
var y = 1
10+
}
11+
12+
for k, v := range kv {
13+
var s = k
14+
k = 1
15+
v = 1
16+
}

go/_test/for.vim

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
for x in xs
2+
let y = x
3+
let x = 1
4+
endfor
5+
6+
function! Func() abort
7+
for y in ys
8+
endfor
9+
" for creates scope
10+
let y = 1
11+
endfunction
12+
13+
for [k,v] in kv
14+
let s = k
15+
let k = 1
16+
let v = 1
17+
endfor

go/_test/function.go

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
func Funcname() {
2+
}
3+

go/_test/function.vim

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
function! Funcname()
2+
endfunction

go/_test/if.go

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
if 1 {
2+
var a = 1
3+
}
4+
if 2 {
5+
} else {
6+
var b = 1
7+
}
8+
if 3 {
9+
var c = 1
10+
} else if 4 {
11+
var d = 1
12+
} else {
13+
var e = 1
14+
}
15+
if 4 {
16+
var f = 1
17+
} else if 5 {
18+
var g = 1
19+
}
20+
if 6 {
21+
if 7 {
22+
var h = 1
23+
}
24+
}

go/_test/if.vim

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
if 1
2+
let a = 1
3+
endif
4+
if 2
5+
else
6+
let b = 1
7+
endif
8+
if 3
9+
let c = 1
10+
elseif 4
11+
let d = 1
12+
else
13+
let e = 1
14+
endif
15+
if 4
16+
let f = 1
17+
elseif 5
18+
let g = 1
19+
endif
20+
if 6
21+
if 7
22+
let h = 1
23+
endif
24+
endif

go/_test/let.go

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
var x = 1
2+
func Funcname() {
3+
var y = 1
4+
y = 2
5+
x = 1
6+
}
7+
8+
func Funcname(z) {
9+
z = z
10+
}
11+
12+
func (self *VimLParser) hoge(a) {
13+
a = a
14+
}
15+
16+
var b, c = d
17+
b, c = d
18+
node.pattern, b = hoge
19+
node.pattern, _ = hoge
20+
var e = 1
21+
if f {
22+
e = g
23+
var h = 0
24+
if i {
25+
h = 1
26+
}
27+
}
28+
var xs = 1
29+
if x {
30+
xs[0] = 1
31+
}

go/_test/let.vim

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
let x = 1
2+
function! Funcname() abort
3+
let y = 1
4+
let y = 2
5+
let x = 1
6+
endfunction
7+
8+
function! Funcname(z) abort
9+
let z = a:z
10+
endfunction
11+
12+
function! s:VimLParser.hoge(a)
13+
let a = a:a
14+
endfunction
15+
16+
let [b, c] = d
17+
let [b, c] = d
18+
let [node.pattern, b] = hoge
19+
let [node.pattern, _] = hoge
20+
21+
let e = 1
22+
if f
23+
let e = g
24+
let h = 0
25+
if i
26+
let h = 1
27+
endif
28+
endif
29+
30+
let xs = 1
31+
if x
32+
let xs[0] = 1
33+
endif

go/_test/list.go

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
var x = []interface{}{1, 2, 3}
2+
var y = []interface{}{}

go/_test/list.vim

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
let x = [1,2,3]
2+
let y = []

go/_test/return.go

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
func f() {
2+
return 1, 2
3+
}
4+

go/_test/return.vim

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
function! s:f()
2+
return [1, 2]
3+
endfunction

go/_test/special.go

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
func (self *VimLParser) __init__() {
2+
var x = 1
3+
}
4+
5+
var y = &ExArg{}
6+
self.hoge = 1
7+
self.ea.range_ = 1
8+
xxx.x = 1
9+
var z = self.ea.range_
10+
var xs = viml_range(10)
11+
Node()
12+
var type_ = 1
13+
var t = type_
14+
var at = type_
15+
var lhs = &lhs{}
16+
var lhs = hoge()
17+
for _, x := range builtin_commands {
18+
}
19+
func (self *LvalueParser) pos1() {
20+
var pos = self.reader.tell()
21+
}
22+
23+
func (self *LvalueParser) pos2() {
24+
var pos = self.reader.tell()
25+
}
26+
27+
self.ea.forceit = true
28+
self.ea.forceit = false
29+
self.ea.usefilter = true
30+
self.ea.usefilter = false
31+
node.attr.range_ = true
32+
node.attr.abort = true
33+
node.attr.dict = true
34+
// skip
35+
// end skip
36+
// do not skip
37+
node.list = self.parse_lvaluelist()
38+
node.depth = hoge
39+
node.rlist = []*VimNode{nil, nil}
40+
node.rlist = []*VimNode{right, nil}
41+
node.rlist = F()
42+
// end do not skip
43+
var p = NewVimLParser()
44+
var et = NewExprTokenizer(r)
45+
var ep = NewExprParser(r)
46+
var lp = NewLvalueParser(r)
47+
var r = NewStringReader(lines)
48+
var nl = nil
49+
var list []*VimNode
50+
var curly_parts []*VimNode
51+
var cmd *Cmd = nil
52+
cmd = &Cmd{name: name, flags: "USERCMD", parser: "parse_cmd_usercmd"}
53+
// type assertion
54+
var s = left.value.(string)
55+
var vn = isvarname(node.value.(string))
56+
func cache() {
57+
self.reader.seek_set(x[0].(int))
58+
return x[1].(*ExprToken)
59+
}
60+
61+
F(self.compile(node.left).(string))
62+
F(self.compile(node.rest).(string))
63+
func F() {
64+
return node.value.(string)
65+
}
66+
67+
// end type assertion
68+
xs = append(xs, x)
69+
node.value = append(node.value.([]interface{}), []interface{}{key, val})
70+
if cnode.pattern != "" {
71+
}
72+
if node.depth != 0 {
73+
}
74+
var rlist = func() []string {;var ss []string;for _, vval := range node.rlist {;ss = append(ss, self.compile(vval).(string));};return ss;}()
75+
F(func() string { if node.rlist[0] == nil {return "nil"} else {return self.compile(node.rlist[0]).(string)} }())
76+
F(func() string { if node.rlist[1] == nil {return "nil"} else {return self.compile(node.rlist[1]).(string)} }())

0 commit comments

Comments
 (0)