Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
c40be3b1
Commit
c40be3b1
authored
Jul 08, 2008
by
Robert Griesemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- go parser parses itself
SVN=126408
parent
6def94ad
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
341 additions
and
50 deletions
+341
-50
usr/gri/src/parser.go
usr/gri/src/parser.go
+328
-43
usr/gri/src/scanner.go
usr/gri/src/scanner.go
+5
-3
usr/gri/src/test_parser.go
usr/gri/src/test_parser.go
+8
-4
No files found.
usr/gri/src/parser.go
View file @
c40be3b1
This diff is collapsed.
Click to expand it.
usr/gri/src/scanner.go
View file @
c40be3b1
...
...
@@ -18,7 +18,7 @@ export
AND_ASSIGN
,
OR_ASSIGN
,
XOR_ASSIGN
,
SHL_ASSIGN
,
SHR_ASSIGN
,
CAND
,
COR
,
BREAK
,
CASE
,
CHAN
,
CONST
,
CONTINUE
,
DEFAULT
,
ELSE
,
EXPORT
,
FALLTHROUGH
,
FALSE
,
FOR
,
FUNC
,
GO
,
GOTO
,
IF
,
IMPORT
,
INTERFACE
,
MAP
,
NEW
,
NIL
,
PACKAGE
,
RANGE
,
FOR
,
FUNC
,
GO
,
GOTO
,
IF
,
IMPORT
,
INTERFACE
,
IOTA
,
MAP
,
NEW
,
NIL
,
PACKAGE
,
RANGE
,
RETURN
,
SELECT
,
STRUCT
,
SWITCH
,
TRUE
,
TYPE
,
VAR
...
...
@@ -103,6 +103,7 @@ const (
IF
;
IMPORT
;
INTERFACE
;
IOTA
;
MAP
;
NEW
;
NIL
;
...
...
@@ -140,8 +141,8 @@ func TokenName(tok int) string {
case
RPAREN
:
return
")"
;
case
LBRACK
:
return
"["
;
case
RBRACK
:
return
"]"
;
case
LBRACE
:
return
"
{
"
;
case
RBRACE
:
return
"
}
"
;
case
LBRACE
:
return
"
LBRACE
"
;
case
RBRACE
:
return
"
RBRACE
"
;
case
ASSIGN
:
return
"="
;
case
DEFINE
:
return
":="
;
...
...
@@ -203,6 +204,7 @@ func TokenName(tok int) string {
case
IF
:
return
"if"
;
case
IMPORT
:
return
"import"
;
case
INTERFACE
:
return
"interface"
;
case
IOTA
:
return
"iota"
;
case
MAP
:
return
"map"
;
case
NEW
:
return
"new"
;
case
NIL
:
return
"nil"
;
...
...
usr/gri/src/test_parser.go
View file @
c40be3b1
...
...
@@ -8,7 +8,7 @@ import Scanner "scanner"
import
Parser
"parser"
func
Parse
(
src
string
,
verbose
bool
)
{
func
Parse
(
src
string
,
verbose
int
)
{
S
:=
new
(
Scanner
.
Scanner
);
S
.
Open
(
src
);
...
...
@@ -20,10 +20,14 @@ func Parse(src string, verbose bool) {
func
main
()
{
verbose
:=
false
;
verbose
:=
0
;
for
i
:=
1
;
i
<
sys
.
argc
();
i
++
{
if
sys
.
argv
(
i
)
==
"-v"
{
verbose
=
true
;
switch
sys
.
argv
(
i
)
{
case
"-v"
:
verbose
=
1
;
continue
;
case
"-vv"
:
verbose
=
2
;
continue
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment