option-type #23
@@ -214,12 +214,19 @@ func (this *parser) parseField(doc string) (uint16, Field, error) {
|
|||||||
name := this.Value()
|
name := this.Value()
|
||||||
err = this.Next()
|
err = this.Next()
|
||||||
if err != nil { return 0, Field { }, err }
|
if err != nil { return 0, Field { }, err }
|
||||||
|
option := false
|
||||||
|
if this.Kind() == TokenOption {
|
||||||
|
option = true
|
||||||
|
err = this.Next()
|
||||||
|
if err != nil { return 0, Field { }, err }
|
||||||
|
}
|
||||||
typ, err := this.parseType()
|
typ, err := this.parseType()
|
||||||
if err != nil { return 0, Field { }, err }
|
if err != nil { return 0, Field { }, err }
|
||||||
return uint16(key), Field {
|
return uint16(key), Field {
|
||||||
Name: name,
|
Name: name,
|
||||||
Doc: doc,
|
Doc: doc,
|
||||||
Type: typ,
|
Type: typ,
|
||||||
|
Option: option,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ func TestParse(test *testing.T) {
|
|||||||
0x0001: Field { Name: "Bio", Type: TypeString { } },
|
0x0001: Field { Name: "Bio", Type: TypeString { } },
|
||||||
0x0002: Field { Name: "Followers", Type: TypeInt { Bits: 32 } },
|
0x0002: Field { Name: "Followers", Type: TypeInt { Bits: 32 } },
|
||||||
0x0003: Field { Name: "Bouncy", Type: TypeBool { } },
|
0x0003: Field { Name: "Bouncy", Type: TypeBool { } },
|
||||||
|
0x0004: Field { Name: "Wings", Type: TypeInt { Bits: 32 } },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -63,6 +64,7 @@ func TestParse(test *testing.T) {
|
|||||||
0001 Bio String,
|
0001 Bio String,
|
||||||
0002 Followers U32,
|
0002 Followers U32,
|
||||||
0003 Bouncy Bool,
|
0003 Bouncy Bool,
|
||||||
|
0004 Wings ?U32,
|
||||||
}
|
}
|
||||||
|
|
||||||
Anything Any
|
Anything Any
|
||||||
|
|||||||
Reference in New Issue
Block a user