ch12: fix code path

This commit is contained in:
chai2010
2016-01-20 22:56:40 +08:00
parent 617ef87432
commit 0c1b9762d9
7 changed files with 7 additions and 32 deletions

View File

@@ -16,9 +16,8 @@ Unmarshal函數使用了反射機製類脩改movie變量的每個成員根據
因爲每個解析器可能需要多次使用當前的記號但是Scan會一直向前掃描所有我們包裝了一個lexer掃描器輔助類型用於跟蹤最近由Scan方法返迴的記號。
<u><i>gopl.io/ch12/sexpr</i></u>
```Go
gopl.io/ch12/sexpr
type lexer struct {
scan scanner.Scanner
token rune // the current token
@@ -158,5 +157,3 @@ func Unmarshal(data []byte, out interface{}) (err error) {
**練習 12.9** 編寫一個基於標記的API用於解碼S表達式參考xml.Decoder7.14的風格。你將需要五種類型的標記Symbol、String、Int、StartList和EndList。
**練習 12.10** 擴展sexpr.Unmarshal函數支持布爾型、浮點數和interface類型的解碼使用 **練習 12.3** 的方案。提示要解碼接口你需要將name映射到每個支持類型的reflect.Type。