libgo: update to go1.9
[official-gcc.git] / libgo / go / text / scanner / example_test.go
blob9e2d5b7c733c895e8b9a2d4b07833fec53dea260
1 // Copyright 2015 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 // +build ignore
7 package scanner_test
9 import (
10 "fmt"
11 "strings"
12 "text/scanner"
15 func Example() {
16 const src = `
17 // This is scanned code.
18 if a > 10 {
19 someParsable = text
21 var s scanner.Scanner
22 s.Init(strings.NewReader(src))
23 s.Filename = "example"
24 for tok := s.Scan(); tok != scanner.EOF; tok = s.Scan() {
25 fmt.Printf("%s: %s\n", s.Position, s.TokenText())
28 // Output:
29 // example:3:1: if
30 // example:3:4: a
31 // example:3:6: >
32 // example:3:8: 10
33 // example:3:11: {
34 // example:4:2: someParsable
35 // example:4:15: =
36 // example:4:17: text
37 // example:5:1: }