expose token flags and numeric flags (#29897)

* expose token flags and numeric flags

* hide hide useless token flags
This commit is contained in:
Wenlu Wang
2019-02-22 07:09:37 +08:00
committed by Wesley Wigham
parent ae836eb854
commit 592396d40a
4 changed files with 27 additions and 5 deletions

View File

@@ -89,10 +89,10 @@ namespace ts {
return createLiteralFromNode(value);
}
export function createNumericLiteral(value: string): NumericLiteral {
export function createNumericLiteral(value: string, numericLiteralFlags: TokenFlags = TokenFlags.None): NumericLiteral {
const node = <NumericLiteral>createSynthesizedNode(SyntaxKind.NumericLiteral);
node.text = value;
node.numericLiteralFlags = 0;
node.numericLiteralFlags = numericLiteralFlags;
return node;
}

View File

@@ -1648,20 +1648,26 @@ namespace ts {
kind: SyntaxKind.NoSubstitutionTemplateLiteral;
}
/* @internal */
export const enum TokenFlags {
None = 0,
/* @internal */
PrecedingLineBreak = 1 << 0,
/* @internal */
PrecedingJSDocComment = 1 << 1,
/* @internal */
Unterminated = 1 << 2,
/* @internal */
ExtendedUnicodeEscape = 1 << 3,
Scientific = 1 << 4, // e.g. `10e2`
Octal = 1 << 5, // e.g. `0777`
HexSpecifier = 1 << 6, // e.g. `0x00000000`
BinarySpecifier = 1 << 7, // e.g. `0b0110010000000000`
OctalSpecifier = 1 << 8, // e.g. `0o777`
/* @internal */
ContainsSeparator = 1 << 9, // e.g. `0b1100_0101`
/* @internal */
BinaryOrOctalSpecifier = BinarySpecifier | OctalSpecifier,
/* @internal */
NumericLiteralFlags = Scientific | Octal | HexSpecifier | BinaryOrOctalSpecifier | ContainsSeparator
}