diff --git a/generate/parse.go b/generate/parse.go index 287a693..cb4a7a5 100644 --- a/generate/parse.go +++ b/generate/parse.go @@ -95,6 +95,28 @@ func (this *parser) parseType() (Type, error) { switch this.Kind() { case TokenIdent: + switch this.Value() { + case "U8": return TypeInt { Bits: 8 }, this.Next() + case "U16": return TypeInt { Bits: 16 }, this.Next() + case "U32": return TypeInt { Bits: 32 }, this.Next() + case "U64": return TypeInt { Bits: 64 }, this.Next() + case "U128": return TypeInt { Bits: 128 }, this.Next() + case "U256": return TypeInt { Bits: 256 }, this.Next() + case "I8": return TypeInt { Bits: 8, Signed: true }, this.Next() + case "I16": return TypeInt { Bits: 16, Signed: true }, this.Next() + case "I32": return TypeInt { Bits: 32, Signed: true }, this.Next() + case "I64": return TypeInt { Bits: 64, Signed: true }, this.Next() + case "I128": return TypeInt { Bits: 128, Signed: true }, this.Next() + case "I256": return TypeInt { Bits: 256, Signed: true }, this.Next() + case "F16": return TypeFloat { Bits: 16 }, this.Next() + case "F32": return TypeFloat { Bits: 32 }, this.Next() + case "F64": return TypeFloat { Bits: 64 }, this.Next() + case "F128": return TypeFloat { Bits: 128 }, this.Next() + case "F256": return TypeFloat { Bits: 256 }, this.Next() + case "String": return TypeString { }, this.Next() + case "Buffer": return TypeBuffer { }, this.Next() + case "Table": return TypeTable { }, this.Next() + } return this.parseTypeNamed() case TokenLBracket: return this.parseTypeArray() diff --git a/generate/parse_test.go b/generate/parse_test.go index 415fcf7..1916580 100644 --- a/generate/parse_test.go +++ b/generate/parse_test.go @@ -11,8 +11,8 @@ func TestParse(test *testing.T) { Name: "Connect", Type: TypeTableDefined { Fields: map[uint16] Field { - 0x0000: Field { Name: "Name", Type: TypeNamed { Name: "String" } }, - 0x0001: Field { Name: "Password", Type: TypeNamed { Name: "String" } }, + 0x0000: Field { Name: "Name", Type: TypeString { } }, + 0x0001: Field { Name: "Password", Type: TypeString { } }, }, }, } @@ -26,9 +26,9 @@ func TestParse(test *testing.T) { } correct.Types["User"] = TypeTableDefined { Fields: map[uint16] Field { - 0x0000: Field { Name: "Name", Type: TypeNamed { Name: "String" } }, - 0x0001: Field { Name: "Bio", Type: TypeNamed { Name: "String" } }, - 0x0002: Field { Name: "Followers", Type: TypeNamed { Name: "U32" } }, + 0x0000: Field { Name: "Name", Type: TypeString { } }, + 0x0001: Field { Name: "Bio", Type: TypeString { } }, + 0x0002: Field { Name: "Followers", Type: TypeInt { Bits: 32 } }, }, } test.Log("CORRECT:", &correct)