Skip to content

Commit b0c35d6

Browse files
authored
Merge pull request #1 from anc95/develop
feat: token ready
2 parents 13c21cb + edfd364 commit b0c35d6

File tree

14 files changed

+424
-113
lines changed

14 files changed

+424
-113
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@
1313

1414
# Dependency directories (remove the comment below to include it)
1515
# vendor/
16+
17+
/vendor

.vscode/launch.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Launch Package",
9+
"type": "go",
10+
"request": "launch",
11+
"mode": "auto",
12+
"program": "${workspaceRoot}/main.go"
13+
}
14+
]
15+
}

go.mod

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
11
module github.com/anc95/golang-enum-to-ts
22

33
go 1.17
4+
5+
require github.com/gkampitakis/go-snaps v0.2.3
6+
7+
require (
8+
github.com/gkampitakis/ciinfo v0.1.0 // indirect
9+
github.com/kr/pretty v0.3.0 // indirect
10+
github.com/kr/text v0.2.0 // indirect
11+
github.com/rogpeppe/go-internal v1.8.0 // indirect
12+
github.com/sergi/go-diff v1.2.0 // indirect
13+
)

go.sum

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
2+
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
4+
github.com/gkampitakis/ciinfo v0.1.0 h1:hPvgzhg7q6xlTNl4hWgEy13esbW847lWTREf0GoezRQ=
5+
github.com/gkampitakis/ciinfo v0.1.0/go.mod h1:PoTj49S/eZLL7PvEdBeu9D1qpd3JsEHOCyf5Y5hVYOs=
6+
github.com/gkampitakis/go-snaps v0.2.3 h1:4pQiQ9GbxlWps/LSR/I72CDWXVQs2lpxEHqhZi9pw4s=
7+
github.com/gkampitakis/go-snaps v0.2.3/go.mod h1:0HSAq6psKeEEgZJpcBcYjEwYVqCh4ZDHbSV2+SH0V84=
8+
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
9+
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
10+
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
11+
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
12+
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
13+
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
14+
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
15+
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
16+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
17+
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
18+
github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
19+
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
20+
github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
21+
github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
22+
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
23+
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
24+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
25+
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
26+
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
27+
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
28+
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
29+
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

main.go

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,9 @@ import (
77
)
88

99
func main() {
10-
// file, err := os.Open("./main.go")
11-
12-
// if err != nil {
13-
// panic(err)
14-
// }
15-
16-
// defer file.Close()
17-
// content, _ := ioutil.ReadAll(file)
18-
19-
// fmt.Print((string(content)))
20-
21-
a := token.Parse("1=a")
10+
parser := token.NewParser("func() {\n hell\n xxx\n dsdasdsa\n \n} \na=1\ntype C string //hello\nconst ( A C = 1 \n B \n D")
2211

12+
a := parser.Parse()
2313
for _, v := range a {
2414
fmt.Printf("[type: %d, value: %s]\n", int(v.Type), v.Value)
2515
}

src/ast/ast.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package ast

src/generator/generator.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package generator

src/test-cases/normal.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package some
2+
3+
type Status int
4+
5+
const (
6+
Todo Status = iota
7+
Done
8+
)
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
2+
[TestNormal - 1]
3+
[]token.Token{
4+
{
5+
Value: "package",
6+
Type: 20,
7+
Start: {0, 6},
8+
End: {0, 0},
9+
},
10+
{
11+
Value: "some",
12+
Type: 20,
13+
Start: {0, 11},
14+
End: {0, 0},
15+
},
16+
{
17+
Value: "type",
18+
Type: 1,
19+
Start: {2, 3},
20+
End: {0, 0},
21+
},
22+
{
23+
Value: "Status",
24+
Type: 20,
25+
Start: {2, 10},
26+
End: {0, 0},
27+
},
28+
{
29+
Value: "int",
30+
Type: 4,
31+
Start: {2, 14},
32+
End: {0, 0},
33+
},
34+
{
35+
Value: "const",
36+
Type: 3,
37+
Start: {4, 5},
38+
End: {0, 0},
39+
},
40+
{
41+
Value: "(",
42+
Type: 18,
43+
Start: {4, 6},
44+
End: {0, 0},
45+
},
46+
{
47+
Value: "Todo",
48+
Type: 20,
49+
Start: {5, 4},
50+
End: {0, 0},
51+
},
52+
{
53+
Value: "Status",
54+
Type: 20,
55+
Start: {5, 11},
56+
End: {0, 0},
57+
},
58+
{
59+
Value: "=",
60+
Type: 9,
61+
Start: {5, 13},
62+
End: {0, 0},
63+
},
64+
{
65+
Value: "iota",
66+
Type: 6,
67+
Start: {5, 18},
68+
End: {0, 0},
69+
},
70+
{
71+
Value: "Done",
72+
Type: 20,
73+
Start: {6, 4},
74+
End: {0, 0},
75+
},
76+
{
77+
Value: ")",
78+
Type: 19,
79+
Start: {7, 0},
80+
End: {0, 0},
81+
},
82+
}
83+
---

0 commit comments

Comments
 (0)