Parsing the An+B microsyntax
Hey,
I'm curious to know if you are open to a change to help aid in parsing the An+B microsyntax as I am having some trouble filtering out invalid values due to the defined grammar assuming that the language can distinguish between signed and unsigned numbers.
The grammar refers to <signed-integers> and <signless-integers>, but it currently isn't possible to tell them apart when consuming tokens containing positive numbers or -0, as any explicitly provided sign gets lost when converting the string to a number. Additionally, it would be helpful to be able to access the Dimension token's numeric and unit values separately, so that the user doesn't have to try to parse the combined value.
I am proposing the following:
- Store the sign found in Step 2. of consume a number, or null if no sign was explicitly given, on
TNumberand add a new method along the lines ofgetSign(): ?string, which returns the sign or null if it was unsigned. A method such asisSigned(): boolis another option, assuming that no other part of the spec needs to know what the sign is, just that the number is signed or not. - Add a new method to
Dimensionthat exposes theTNumbertoken allowing the user to access its value and sign and determine the type of number.- I'm open to suggestions for the method name; maybe something like
getToken,getNumber, orgetNumberToken?
- I'm open to suggestions for the method name; maybe something like
- Add a new method such as
getUnit(): stringtoDimensionthat exposes the unit portion of the dimension.
Basically, I need to be able to tell the difference between "4n - 4" and "4n - +4", as the former string is valid, but the later one is not.