format parser, add support for negative integers and return specifically

which type of number
This commit is contained in:
Elizabeth Hunt 2024-02-26 14:59:58 -07:00
parent e8e9ee18f2
commit c8336ee487
Signed by: simponic
GPG Key ID: 52B3774857EB24B1
2 changed files with 5205 additions and 4814 deletions

View File

@ -269,6 +269,7 @@ ArithmeticOperation
/ "/"
/ "*"
/ "**"
/ "%"
BitOperation
= ">>"
@ -285,17 +286,17 @@ ComparisonOperation
/ ">"
/ "<"
Integer = digits:[0-9]+ !"." { return parseInt(digits.join(''), 10); }
Integer = digits:("-"? [0-9]+) !"." { return { int: parseInt(digits.join(''), 10) }; }
QuotedString
= "'" content:[^']* "'" { return content.join(''); }
/ "\"" content:[^"]* "\"" { return content.join(''); }
Real
= value:("-"? [0-9]+ "." [0-9]+) {
return parseFloat(
= value:("-"? [0-9]+ ("." [0-9]+)?) {
return { real: parseFloat(
value.map(x => (Array.isArray(x) ? x.join('') : x)).join(''),
);
) };
}
Literal

File diff suppressed because it is too large Load Diff