Parse units on numeric literals and keep them in the AST (#5061)
* Code changes Signed-off-by: Nick Cameron <nrc@ncameron.org> * test changes Signed-off-by: Nick Cameron <nrc@ncameron.org> * Frontend changes Signed-off-by: Nick Cameron <nrc@ncameron.org> * Refactor asNum Co-authored-by: Jonathan Tran <jonnytran@gmail.com> --------- Signed-off-by: Nick Cameron <nrc@ncameron.org> Co-authored-by: Jonathan Tran <jonnytran@gmail.com>
This commit is contained in:
@ -743,14 +743,18 @@ export function splitPathAtPipeExpression(pathToNode: PathToNode): {
|
||||
return splitPathAtPipeExpression(pathToNode.slice(0, -1))
|
||||
}
|
||||
|
||||
export function createLiteral(value: LiteralValue): Node<Literal> {
|
||||
export function createLiteral(value: LiteralValue | number): Node<Literal> {
|
||||
const raw = `${value}`
|
||||
if (typeof value === 'number') {
|
||||
value = { value, suffix: 'None' }
|
||||
}
|
||||
return {
|
||||
type: 'Literal',
|
||||
start: 0,
|
||||
end: 0,
|
||||
moduleId: 0,
|
||||
value,
|
||||
raw: `${value}`,
|
||||
raw,
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user