Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
3df8e0a1
Commit
3df8e0a1
authored
Jun 18, 2008
by
Rob Pike
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clean up ken/rob2.go to eliminate a few workarounds
SVN=123442
parent
74aa77fb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
8 deletions
+7
-8
golden.out
test/golden.out
+1
-1
rob2.go
test/ken/rob2.go
+6
-7
No files found.
test/golden.out
View file @
3df8e0a1
...
...
@@ -77,7 +77,7 @@ Hello World!
=========== ken/rob1.go
=========== ken/rob2.go
(
hello hello (hello
12 34))
(
defn foo (add
12 34))
=========== ken/robfor.go
...
...
test/ken/rob2.go
View file @
3df8e0a1
...
...
@@ -73,6 +73,7 @@ var lineno int32 = 1;
var
input
string
;
var
inputindex
int
=
0
;
var
tokenbuf
[
100
]
byte
;
var
tokenlen
int
=
0
;
const
EOF
int
=
-
1
;
...
...
@@ -135,7 +136,7 @@ func Get() int
peekc
=
-
1
;
}
else
{
c
=
convert
(
int
,
input
[
inputindex
]);
inputindex
=
inputindex
+
1
;
// BUG should be incr one expr
inputindex
++
if
c
==
'\n'
{
lineno
=
lineno
+
1
;
}
...
...
@@ -185,6 +186,7 @@ func NextToken()
if
i
>=
100
-
1
{
// sizeof tokenbuf - 1
panic
"atom too long
\n
"
;
}
tokenlen
=
i
;
tokenbuf
[
i
]
=
nilchar
;
if
'0'
<=
tokenbuf
[
0
]
&&
tokenbuf
[
0
]
<=
'9'
{
token
=
'0'
;
...
...
@@ -217,10 +219,7 @@ func ParseList() *Slist
retval
=
slist
;
for
;;
{
slist
.
list
.
car
=
Parse
();
if
token
==
')'
{
// empty cdr
break
;
}
if
token
==
EOF
{
// empty cdr BUG SHOULD USE ||
if
token
==
')'
||
token
==
EOF
{
// empty cdr
break
;
}
slist
.
list
.
cdr
=
new
(
Slist
);
...
...
@@ -239,7 +238,7 @@ func atom(i int) *Slist // BUG: uses tokenbuf; should take argument
slist
.
atom
.
integer
=
i
;
slist
.
isstring
=
false
;
}
else
{
slist
.
atom
.
str
=
"hello"
;
slist
.
atom
.
str
=
string
(
tokenbuf
)[
0
:
tokenlen
]
;
slist
.
isstring
=
true
;
}
slist
.
isatom
=
true
;
...
...
@@ -249,7 +248,7 @@ func atom(i int) *Slist // BUG: uses tokenbuf; should take argument
func
atoi
()
int
// BUG: uses tokenbuf; should take argument
{
var
v
int
=
0
;
for
i
:=
0
;
'0'
<=
tokenbuf
[
i
]
&&
tokenbuf
[
i
]
<=
'9'
;
i
=
i
+
1
{
for
i
:=
0
;
i
<
tokenlen
&&
'0'
<=
tokenbuf
[
i
]
&&
tokenbuf
[
i
]
<=
'9'
;
i
=
i
+
1
{
v
=
10
*
v
+
convert
(
int
,
tokenbuf
[
i
]
-
'0'
);
}
return
v
;
...
...
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