diff --git a/generate/parse.go b/generate/parse.go index e6e1ca3..f389772 100644 --- a/generate/parse.go +++ b/generate/parse.go @@ -116,6 +116,7 @@ func (this *parser) parseType() (Type, error) { case "String": return TypeString { }, this.Next() case "Buffer": return TypeBuffer { }, this.Next() case "Table": return TypeTable { }, this.Next() + case "Any": return TypeAny { }, this.Next() } return this.parseTypeNamed() case TokenLBracket: diff --git a/generate/parse_test.go b/generate/parse_test.go index a447ebb..c65c906 100644 --- a/generate/parse_test.go +++ b/generate/parse_test.go @@ -31,6 +31,7 @@ func TestParse(test *testing.T) { 0x0002: Field { Name: "Followers", Type: TypeInt { Bits: 32 } }, }, } + correct.Types["Anything"] = TypeAny { } test.Log("CORRECT:", &correct) got, err := ParseReader("test.pdl", strings.NewReader(` @@ -48,6 +49,8 @@ func TestParse(test *testing.T) { 0001 Bio String, 0002 Followers U32, } + + Anything Any `)) if err != nil { test.Fatal(parse.Format(err)) } test.Log("GOT: ", got) diff --git a/generate/protocol.go b/generate/protocol.go index 1610c86..0e214b9 100644 --- a/generate/protocol.go +++ b/generate/protocol.go @@ -99,6 +99,12 @@ func (typ TypeNamed) String() string { return typ.Name } +type TypeAny struct { } + +func (typ TypeAny) String() string { + return "Any" +} + func HashType(typ Type) [16]byte { // TODO: if we ever want to make the compiler more efficient, this would // be a good place to start, complex string concatenation in a hot path