Commit Graph

16 Commits

Author SHA1 Message Date
D.E. Akers f5f5edb889 relax numeric conversions from string
The spec does not establish any particular constraints to observe in
casting from `YARN` to `NUMB(A)R`. Presently, `lci` checks that the
string consists only of numeric characters prior to attempting the
conversion, halting with an error if it's found not to be the case.

This behavior is often more inconvenient than helpful. Many numeric
strings encountered in the wild are "roughly numeric", and it would be
wise to account for this observation. As a simple example, a user may
be prompted to input a number; in the case of their inadvertently
providing leading or trailing whitespace, a naive program will crash
rather than gracefully extracting the otherwise sensible input.

This patch removes the `isDecString()` function and instead leverages
the `strtoll()` and `strtof()` functions to handle casts from `YARN`
to `NUMBR` and `NUMBAR`, respectively. Thus, strings to be converted
are permitted to contain leading whitespace, and trailing non-numeric
characters are ignored. Additionally, `YARN`s to be cast to `NUMBR`
may lead with `"0"` or `"0x"` to indicate that the string should be
interpreted as an octal or hexadecimal value, respectively.

This change required the modification of several tests which previously
checked that casting an empty or completely non-numeric `YARN` resulted
in an error. These now verify that such a conversion results in a zero
of the appropriate type.
2015-08-30 15:45:53 -07:00
Justin Meza c412ec117a patched ElColmo's system command code with some minor style changes 2014-05-09 23:59:18 -04:00
Justin Meza 33691687d5 removed more Clang warnings 2013-12-30 12:55:39 -05:00
Justin Meza e2c479de2e removed Clang warnings 2013-12-30 12:46:49 -05:00
Mark J. Reed 343d661a4d use long long integers instead of ints 2013-12-19 12:51:13 -05:00
Justin Meza 5337b65513 cleaning up binding code 2013-02-24 15:44:33 -05:00
Justin Meza 38e67f8287 basic support for binding to libraries 2013-02-24 02:40:58 -05:00
Justin Meza 2014412d5b barely working bindings 2013-02-23 19:51:07 -05:00
Justin J. Meza 5751d3fd42 minor bookkeeping changes 2012-12-13 00:02:17 -05:00
Justin J. Meza 9ab725d97d Added support for array initialization. 2011-09-26 16:16:19 -04:00
Justin J. Meza 35750a835d Added basic support for the calling object reference variable, "ME". 2011-07-19 00:02:43 -07:00
Justin J. Meza a6ef5811e8 Added basic array functionality and cleaned up documentation. 2011-06-14 23:54:12 -07:00
Justin J. Meza 78456aabfd Merged SRS and de-linted code 2010-12-21 03:20:31 -05:00
Justin J. Meza 93a0e9c1be Minor documentation fixes 2010-11-16 01:12:08 -05:00
Justin J. Meza a90bf070f0 Added new functions, stored as values; updated EBNF 2010-11-16 00:25:51 -05:00
Justin J. Meza 2e14ac0b3f Initial project import 2010-08-09 00:01:59 -07:00