summary refs log tree commit diff stats
path: root/lib/pure/parseutils.nim
Commit message (Collapse)AuthorAgeFilesLines
* fixes #23513, parseutils.nim: parseInt's doc example. (#23561)lit2024-06-121-8/+12
| | | | | | | | | | fixes #23513 Also, the old `runnableExample` is just a copy of `proc parseInt(openArray[char], var int, int)` variant (in Line 1000). --------- Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
* Markdown code blocks migration part 8 (#22478)Andrey Makarov2023-08-151-20/+19
|
* This adds `parseutils.parseSize`, an inverse to `strutils.formatSize` (#21349)c-blake2023-02-141-0/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * This adds `parseutils.parseSize`, an inverse to `strutils.formatSize` which has existed since 2017. It is useful for parsing the compiler's own output logs (like SuccessX) or many other scenarios where "human readable" units have been chosen. The doc comment and tests explain accepted syntax in detail. Big units lead to small numbers, often with a fractional part, but we parse into an `int64` since that is what `formatSize` stringifies and this is an inverse over partial function slots. Although metric prefixes z & y for zettabyte & yottabyte are accepted, these will saturate the result at `int64.high` unless the qualified number is a small fraction. This should not be much of a problem until such sizes are common (at which point another overload with the parse result either `float64` or `int128` could be added). Tests avoids `test()` because of a weakly related static: test() failure as mentioned in https://github.com/nim-lang/Nim/pull/21325. This is a more elemental VM failure. As such, it needs its own failure exhibition issue that is a smaller test case. (I am working on that, but unless there is a burning need to `parseSize` at compile-time before run-time it need not hold up this PR.) * This worked with `int` but fails with `int64`. Try for green tests. * Lift 2-result matching into a `checkParseSize` template and format as a table of input & 2 expected outputs which seems nicer and to address https://github.com/nim-lang/Nim/pull/21349#pullrequestreview-1294407679 * Fix (probably) the i386 trouble by using `int64` consistently. * Improve documentation by mentioning saturation. * Improve documentation with `runnableExamples` and a little more detail in the main doc comment based on excellent code review by @juancarlospaco: https://github.com/nim-lang/Nim/pull/21349#pullrequestreview-1294564155 * Address some more @juancarlospaco code review concerns. * Remove a stray space. * Mention milli-bytes in docs to maybe help clarify why wild conventions are so prone to going case-insensitive-metric. * Add some parens.
* Added 'openArray[char]' overloads to 'std/parseutils' (#20527)Jason Beetham2022-10-241-93/+443
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Added 'openarray[char]' overloads to 'std/parseutils' * Removed redundant `start` and `last` params from slice using procs * Fixed type for parseIdent overload * fixed one by off with 'substr' * removed missed start parameters for procedures * Added 'openarray[char]' overloads to 'std/parseutils' * Removed redundant `start` and `last` params from slice using procs * Fixed type for parseIdent overload * fixed one by off with 'substr' * removed missed start parameters for procedures * Fixed VM op to work with new 'opcSlice' * Corrected captureBetween's logic to work with openarray * js sys's parsefloat logic now uses openarray Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>
* parseutils: skipWhile: fix parameter name in doc comment (#20523)ee72022-10-091-1/+1
|
* Change stdlib imports to use std prefix in most examples (#17202)Danil Yarantsev2021-02-281-1/+1
|
* fix parseChar see #16240 (#16245)Pietro Peterlongo2020-12-061-3/+14
| | | | | * fix parseChar * do not introduce new double backticks
* add support for parsing chars in `scanf` macro (#16240)Miran2020-12-031-0/+4
|
* move tests to testament (#16101)flywind2020-11-241-43/+0
| | | | | | | | | * move tests to testament * minor * fix random * disable test random
* ORC and stdlib optimizations (#15362)Andreas Rumpf2020-09-191-4/+12
|
* init checks and 'out' parameters (#14521)Andreas Rumpf2020-06-231-5/+11
| | | | | | | | | | | * I don't care about observable stores * enforce explicit initializations * cleaner code for the stdlib * stdlib: use explicit initializations * make tests green * algorithm.nim: set result explicitly * remove out parameters and bring the PR into a mergable state * updated the changelog
* parseutils: integerOutOfRangeDefect => integerOutOfRangeError (#14627)Timothee Cour2020-06-091-7/+7
|
* Error -> Defect for defects (#13908)Jacek Sieka2020-04-281-7/+7
| | | | | | | | | | | | | | * Error -> Defect for defects The distinction between Error and Defect is subjective, context-dependent and somewhat arbitrary, so when looking at an exception, it's hard to guess what it is - this happens often when looking at a `raises` list _without_ opening the corresponding definition and digging through layers of inheritance. With the help of a little consistency in naming, it's at least possible to start disentangling the two error types and the standard lib can set a good example here.
* Deprecate DCE:on (#13839)Juan Carlos2020-04-021-3/+0
|
* fixes #13605 (#13611)Andreas Rumpf2020-03-091-4/+5
|
* [backport] Make all parseutils examples auto-checking (#13238)Kaushal Modi2020-01-231-32/+25
| | | - Also fix one example's output (ikString -> ikStr, ikVar instead of ikExpr)
* [backport] Fix typo and improve in code-block of 'lib/pure/parseutils.nim' ↵Mera2020-01-231-2/+3
| | | | (#13231) [ci skip]
* [backport] run nimpretty on parsersnarimiran2019-09-301-20/+20
|
* Fix spellings (#12277) [backport]Federico Ceratto2019-09-271-1/+1
|
* Fix: remove pragma inline from parseBin|Oct|Hex (#11105)Alvydas Vitkauskas2019-04-241-3/+3
|
* Make parseutils.parseBin|Oct|Hex generic (#11067)Alvydas Vitkauskas2019-04-241-69/+114
| | | | | | * make parsutils.parseBin generic and improve runnableExamples * reimplement parseBin/Oct/Hex and improve runnableExamples * update changelog.md file with parseBin/Oct/Hex and fix a typo
* Fix parseutils.parseBiggestInt regression (#10348)Oscar Nihlgård2019-01-181-2/+13
|
* better docs: parseutilsThomas T. Jarløv2019-01-181-35/+180
|
* Remove long deprecated stuff (#10332)Miran2019-01-181-12/+0
|
* parseutils.nim: help the codegen produce better codeAraq2019-01-161-11/+12
|
* Improve exception usage in parseutils (#10284)Oscar Nihlgård2019-01-151-24/+32
|
* Update parseutils.nimTimothee Cour2018-12-051-2/+2
|
* stdlib: documenation updates, the exception names have been changedAndreas Rumpf2018-10-251-1/+1
|
* parsutils: minor doc improvementsAndreas Rumpf2018-10-241-2/+2
|
* Add parse bin int, fixes #8018 (#8020)Vindaar2018-06-131-12/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * clarify `parseHexInt`, `parseOctInt` docstring and exception msgs * add `parseBinInt` based on `parseutil.parseBin` implementation Adds a `parseBinInt`, which parses a binary integer string and returns it as an integer. This is based on the implementation of `parseutil.parseBin`, removing the unnecessary parts. * add tests for all `parse(Hex|Oct|Bin)Int` procs * replace `parse*Int` proc impls by call to parseutil procs Replaces the `parse(Hex|Oct|Bin)Int` procedure implementation by calls to the `parseutil` procs, which receive a mutable argument. Has the main advantage that the empty string as well as a "prefix only" string, e.g. "0x" counts as an invalid integer. Also moves the `parseOctInt` proc further up in the file so that all `parse` procs are below one another. * replace `var L` by `let L` in `parse` procs There's no reason for the usage of `var` here. * add `maxLen` optional arg for `parseutil.parse(Oct|Bin)` Plus small change to test cases. * update changelog about `parse*Int` procs * fix `rejectParse` template in `tstrutils` * make sure only `s.len` chars are parsed, if `maxLen+start` > s.len Fixes a previous bug in `parseHex` (and now affected `parseOct` and `parseBin`), which allowed to set `start + maxLen` to be larger than the strings length. This resulted in an out of bounds access. * move `parse*Int` proc change to breaking changes, add double `
* Fixes for parseUntil when until.len == 0 (or nil)data-man2018-05-251-0/+3
|
* remove deprecated stuff from the stdlib; introduce better deprecation warningsAraq2018-05-051-2/+0
|
* parseutils does not depend on the zero terminator anymoreAndreas Rumpf2018-04-291-53/+54
|
* remove dead code elimination option (#7669)Jacek Sieka2018-04-231-1/+1
|
* Add a more number parsers to the scanf macro (#6985)Dmitry Atamanov2018-01-051-0/+17
|
* added parseutils.parseSaturatedNaturalAndreas Rumpf2017-11-191-4/+56
|
* Add link to streams moduleFederico Ceratto2017-10-211-0/+2
|
* Add space to fix RST in captureBetween docs (#5769)Matt Riggott2017-05-041-1/+1
|
* Added BiggestUInt (#5378)flyx2017-02-131-12/+12
|
* added strscans stdlib moduleAraq2016-05-101-0/+16
|
* split too long linesAraq2016-05-101-5/+9
|
* Remove dead codeAnatoly Galiulin2016-03-311-11/+1
|
* Add parseUInt and parseBiggestUInt functions to stdlib (parseutils, strutils)Anatoly Galiulin2016-03-301-0/+51
|
* fixes strutils.unescape; refs #3634Andreas Rumpf2016-01-171-2/+5
|
* fixes #2909Araq2015-06-151-16/+16
|
* Turn some test outputs into actual testsOleh Prypin2015-04-211-3/+5
|
* Don't run non-test code when defined(testing)Oleh Prypin2015-04-211-1/+3
|
* Fix typosFederico Ceratto2015-02-151-1/+1
|
* Fix typosFederico Ceratto2015-02-151-1/+1
|
* fixes #2041Araq2015-01-311-2/+2
|