format parser, add support for negative integers and return specifically
which type of number
This commit is contained in:
parent
e8e9ee18f2
commit
c8336ee487
@ -269,6 +269,7 @@ ArithmeticOperation
|
|||||||
/ "/"
|
/ "/"
|
||||||
/ "*"
|
/ "*"
|
||||||
/ "**"
|
/ "**"
|
||||||
|
/ "%"
|
||||||
|
|
||||||
BitOperation
|
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
|
QuotedString
|
||||||
= "'" content:[^']* "'" { return content.join(''); }
|
= "'" content:[^']* "'" { return content.join(''); }
|
||||||
/ "\"" content:[^"]* "\"" { return content.join(''); }
|
/ "\"" content:[^"]* "\"" { return content.join(''); }
|
||||||
|
|
||||||
Real
|
Real
|
||||||
= value:("-"? [0-9]+ "." [0-9]+) {
|
= value:("-"? [0-9]+ ("." [0-9]+)?) {
|
||||||
return parseFloat(
|
return { real: parseFloat(
|
||||||
value.map(x => (Array.isArray(x) ? x.join('') : x)).join(''),
|
value.map(x => (Array.isArray(x) ? x.join('') : x)).join(''),
|
||||||
);
|
) };
|
||||||
}
|
}
|
||||||
|
|
||||||
Literal
|
Literal
|
||||||
|
1578
src/parser/parser.ts
1578
src/parser/parser.ts
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user