File tree 2 files changed +45
-0
lines changed
2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -166,3 +166,11 @@ Introspection idea
166
166
fmt.Printf("*** method not found\n")
167
167
}
168
168
169
+
170
+ Parser
171
+ ======
172
+
173
+ Use Python's Grammar file - converted into parser/grammar.y
174
+
175
+ Use go tool yacc and a hand built lexer in parser/lexer.go
176
+
Original file line number Diff line number Diff line change
1
+ package main
2
+
3
+ import (
4
+ "flag"
5
+ "fmt"
6
+ "log"
7
+ "os"
8
+
9
+ "github.com/ncw/gpython/parser"
10
+ )
11
+
12
+ var (
13
+ lex = flag .Bool ("l" , false , "Lex the file only" )
14
+ )
15
+
16
+ func main () {
17
+ flag .Parse ()
18
+ for _ , path := range flag .Args () {
19
+ if * lex {
20
+ fmt .Printf ("Lexing %q\n " , path )
21
+ } else {
22
+ fmt .Printf ("Parsing %q\n " , path )
23
+ }
24
+ in , err := os .Open (path )
25
+ if err != nil {
26
+ log .Fatal (err )
27
+ }
28
+ fmt .Printf ("-----------------\n " )
29
+ if * lex {
30
+ parser .Lex (in )
31
+ } else {
32
+ parser .Parse (in )
33
+ }
34
+ fmt .Printf ("-----------------\n " )
35
+ in .Close ()
36
+ }
37
+ }
You can’t perform that action at this time.
0 commit comments