(s string, roundTripOnly bool)
| 910 | } |
| 911 | |
| 912 | func isValidBigIntString(s string, roundTripOnly bool) bool { |
| 913 | if s == "" { |
| 914 | return false |
| 915 | } |
| 916 | scanner := scanner.NewScanner() |
| 917 | scanner.SetSkipTrivia(false) |
| 918 | success := true |
| 919 | scanner.SetOnError(func(diagnostic *diagnostics.Message, start, length int, args ...any) { |
| 920 | success = false |
| 921 | }) |
| 922 | scanner.SetText(s + "n") |
| 923 | result := scanner.Scan() |
| 924 | negative := result == ast.KindMinusToken |
| 925 | if negative { |
| 926 | result = scanner.Scan() |
| 927 | } |
| 928 | flags := scanner.TokenFlags() |
| 929 | // validate that |
| 930 | // * scanning proceeded without error |
| 931 | // * a bigint can be scanned, and that when it is scanned, it is |
| 932 | // * the full length of the input string (so the scanner is one character beyond the augmented input length) |
| 933 | // * it does not contain a numeric separator (the `BigInt` constructor does not accept a numeric separator in its input) |
| 934 | return success && result == ast.KindBigIntLiteral && scanner.TokenEnd() == len(s)+1 && flags&ast.TokenFlagsContainsSeparator == 0 && |
| 935 | (!roundTripOnly || s == pseudoBigIntToString(jsnum.NewPseudoBigInt(jsnum.ParsePseudoBigInt(scanner.TokenValue()), negative))) |
| 936 | } |
| 937 | |
| 938 | func isValidESSymbolDeclaration(node *ast.Node) bool { |
| 939 | if ast.IsVariableDeclaration(node) { |
no test coverage detected