-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
44 lines (35 loc) · 776 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package main
import (
"fmt"
"os"
"time"
"github.com/t14raptor/go-fast/parser"
// "github.com/t14raptor/go-fast/resolver"
)
func main() {
dat, err := os.ReadFile("in.js")
if err != nil {
fmt.Println(err)
}
start := time.Now()
a, err := parser.ParseFile(string(dat))
elapsed := time.Since(start)
if err != nil {
fmt.Println(err)
}
fmt.Println(elapsed)
f, err := os.OpenFile("parsed.js", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
fmt.Println(err)
}
formattedString := fmt.Sprintf("%s\n\n", a)
if _, err := f.WriteString(formattedString); err != nil {
fmt.Println(err)
}
}
// type ExampleVisitor struct {
// ast.NoopVisitor
// }
// func (v *ExampleVisitor) VisitIdentifier(n *ast.Identifier) {
// fmt.Println(n.ToId())
// }