FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
gpython/parser/testparser/testparser.go at main · go-python/gpython · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
go-python
/
gpython
Public
Notifications
You must be signed in to change notification settings
Fork
105
Star
1k
Code
Issues
49
Pull requests
5
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
gpython
/
parser
/
testparser
/
testparser.go
Copy path
More file actions
More file actions
Latest commit
History
History
History
69 lines (64 loc) · 1.51 KB
Breadcrumbs
gpython
/
parser
/
testparser
/
testparser.go
Copy path
File metadata and controls
69 lines (64 loc) · 1.51 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Copyright 2018 The go-python Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
main
import
(
"flag"
"fmt"
"io"
"log"
"os"
"github.com/go-python/gpython/compile"
"github.com/go-python/gpython/parser"
)
var
(
lexFile
=
flag
.
Bool
(
"l"
,
false
,
"Lex the file only"
)
compileFile
=
flag
.
Bool
(
"c"
,
false
,
"Lex, Parse and compile the file"
)
debugLevel
=
flag
.
Int
(
"d"
,
0
,
"Debug level 0-4"
)
)
func
main
() {
flag
.
Parse
()
parser
.
SetDebug
(
*
debugLevel
)
if
len
(
flag
.
Args
())
==
0
{
log
.
Printf
(
"Need files to parse"
)
os
.
Exit
(
1
)
}
for
_
,
path
:=
range
flag
.
Args
() {
if
*
lexFile
{
fmt
.
Printf
(
"Lexing %q
\n
"
,
path
)
}
else
if
*
compileFile
{
fmt
.
Printf
(
"Compiling %q
\n
"
,
path
)
}
else
{
fmt
.
Printf
(
"Parsing %q
\n
"
,
path
)
}
in
,
err
:=
os
.
Open
(
path
)
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
if
*
debugLevel
>
0
{
fmt
.
Printf
(
"-----------------
\n
"
)
}
if
*
lexFile
{
_
,
err
=
parser
.
Lex
(
in
,
path
,
"exec"
)
}
else
if
*
compileFile
{
var
input
[]
byte
input
,
err
=
io
.
ReadAll
(
in
)
if
err
!=
nil
{
log
.
Fatalf
(
"Failed to read %q: %v"
,
path
,
err
)
}
_
,
err
=
compile
.
Compile
(
string
(
input
),
path
,
"exec"
,
0
,
false
)
}
else
{
_
,
err
=
parser
.
Parse
(
in
,
path
,
"exec"
)
}
if
*
debugLevel
>
0
{
fmt
.
Printf
(
"-----------------
\n
"
)
}
closeErr
:=
in
.
Close
()
if
err
!=
nil
{
log
.
Fatalf
(
"Failed on %q: %v"
,
path
,
err
)
}
if
closeErr
!=
nil
{
log
.
Fatalf
(
"Failed to close %q: %v"
,
path
,
closeErr
)
}
}
}
Back
|
FazBrowse Home
|
New Git URL