Commit 9bc7b08a authored by Robert Griesemer's avatar Robert Griesemer

- changed literal syntax to use the convert notation

- fixed issued with function declarations/function literals
- added more tests and fixed existing tests

SVN=118167
parent 7fbe486b
......@@ -7,7 +7,8 @@
package main
func main() {
[ ' ',
[]int(
' ',
'a',
'ä',
'本',
......@@ -30,5 +31,5 @@ func main() {
'\ubabe',
'\U0123ABCD',
'\Ucafebabe'
]
);
}
......@@ -7,7 +7,8 @@
package main
func main() {
[ 0.,
[]float(
0.,
+10.,
-210.,
......@@ -66,5 +67,5 @@ func main() {
0.0E123,
+10.01e234,
-210.012e345
]
);
}
......@@ -7,7 +7,8 @@
package main
func main() {
[ 0,
[]int(
0,
123,
0123,
0000,
......@@ -15,5 +16,5 @@ func main() {
0x123,
0X0,
0X123
];
);
}
......@@ -7,7 +7,8 @@
package main
func main() {
[ "",
[]string(
"",
" ",
"'`",
"a",
......@@ -25,5 +26,5 @@ func main() {
`\a\b\f\n\r\t\v\\\'\"`,
`\000\123\x00\xca\xFE\u0123\ubabe\U0123ABCD\Ucafebabe`,
`\x\u\U\`
]
);
}
......@@ -67,7 +67,8 @@ func control_structs() {
var x float
}
foo: // a label
switch {
var j int;
switch y := 0; true {
case i < y:
fallthrough;
case i < j:
......
// $G $F.go && $L $F.$A && ./$A.out
// Copyright 2009 The Go 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
// brainfuck
func main() {
var a [30000]byte;
prog := "++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.";
p := 0;
pc := 0;
for {
switch prog[pc] {
case '>':
p++;
case '<':
p--;
case '+':
a[p]++;
case '-':
a[p]--;
case '.':
print string(a[p]);
case '[':
if a[p] == 0 {
for nest := 1; nest > 0; pc++ {
if prog[pc+1] == ']' {
nest--;
}
if prog[pc+1] == '[' {
nest++;
}
}
}
case ']':
if a[p] != 0 {
for nest := -1; nest < 0; pc-- {
if prog[pc-1] == ']' {
nest--;
}
if prog[pc-1] == '[' {
nest++;
}
}
}
default:
return;
}
pc++;
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment