Add Tag decoding
parent
9c5afcd34d
commit
4872fc4471
|
@ -79,6 +79,8 @@ class CBOR::Lexer
|
|||
map_start(read_size(byte - 0xa0))
|
||||
when 0xbf
|
||||
Token::MapT.new
|
||||
when 0xc0..0xdb
|
||||
consume_tag(read_size(byte - 0xc0))
|
||||
##################
|
||||
when 0xf4
|
||||
Token::BoolT.new(value: false)
|
||||
|
@ -170,6 +172,11 @@ class CBOR::Lexer
|
|||
Token::MapT.new(size: size.to_i32)
|
||||
end
|
||||
|
||||
private def consume_tag(size) : Token::TagT
|
||||
raise ParseError.new("Maximum size for tag exceeded") if size > UInt32::MAX
|
||||
Token::TagT.new(id: size.to_u32)
|
||||
end
|
||||
|
||||
# Creates a method overloaded for each UInt sizes to convert the UInt into
|
||||
# the respective Int capable of containing the value
|
||||
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
module CBOR::Tag
|
||||
enum Kind
|
||||
Unassigned
|
||||
RFC3339Time
|
||||
EpochTime
|
||||
PositiveBigNum
|
||||
NegativeBigNum
|
||||
DecimalFraction
|
||||
BigFloat
|
||||
ExpectBase64URLConversion
|
||||
ExpectBase64Conversion
|
||||
ExpectBase16Conversion
|
||||
EncodedCBOR
|
||||
URI
|
||||
Base64URL
|
||||
Base64
|
||||
RegularExpresion
|
||||
MIME
|
||||
SelfDescribeCBOR
|
||||
end
|
||||
end
|
|
@ -7,6 +7,7 @@ module CBOR::Token
|
|||
record StringT, value : String, chunks : Array(Int32)? = nil
|
||||
record ArrayT, size : Int32? = nil
|
||||
record MapT, size : Int32? = nil
|
||||
record TagT, id : UInt32
|
||||
|
||||
alias T = NullT |
|
||||
BoolT |
|
||||
|
@ -15,5 +16,6 @@ module CBOR::Token
|
|||
BytesT |
|
||||
StringT |
|
||||
ArrayT |
|
||||
MapT
|
||||
MapT |
|
||||
TagT
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue