generate: Add Any type to parser and syntax tree
This commit is contained in:
parent
8dac25035f
commit
419c3651bf
@ -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:
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user