Skip to content

Number Attributes Grammar Enhancement. #592

@sbernard31

Description

@sbernard31

Looking at specification LWM2M-v1.2.1@core§Table: 7.3.2.-1 class Attributes you could see that number grammar are :

// for positive Integer
1*DIGIT

// for positive decimal 
1*DIGIT ["." 1*DIGIT]

And with #563 maybe also :

// for Integer
["-"] 1*DIGIT

// for decimal 
["-"] 1*DIGIT ["." 1*DIGIT]

This grammar allow number like : 0012 or -000055 or 000.256 or -000130.235 ...
This is a small issue but could be improved by using Cardinal as defined in https://datatracker.ietf.org/doc/html/rfc6690#section-2

cardinal       = "0" / ( %x31-39 *DIGIT )

So fixed rules will look like that 👇 using cardinal rule (and so refer to https://datatracker.ietf.org/doc/html/rfc6690#section-2)

// for positive Integer
cardinal

// for Integer
["-"] cardinal

// for positive decimal 
cardinal ["." 1*DIGIT]

// for decimal 
["-"] cardinal ["." 1*DIGIT]

If it is wanted to not refer to cardinal and only use core rules from https://www.rfc-editor.org/rfc/rfc5234#appendix-B.1
Then it will look like :

// for positive Integer
"0" / ( %x31-39 *DIGIT )

// for Integer
["-"] ("0" / ( %x31-39 *DIGIT ))

// for positive decimal 
("0" / ( %x31-39 *DIGIT )) ["." 1*DIGIT]

// for decimal 
["-"] ("0" / ( %x31-39 *DIGIT )) ["." 1*DIGIT]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions