Commit Graph

25 Commits

Author SHA1 Message Date
D.E. Akers bc32a948bf add HAS AN keyword for grammatically correct declarations
http://forum.lolcode.org/viewtopic.php?f=4&t=13#p19
2015-08-30 15:46:36 -07:00
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 4154149e45 sanitize outside inputs 2015-07-29 21:53:03 -07:00
Justin Meza e97cf5296b escaping the escape character on input (thanks for reporting, @Lucki!) 2015-07-26 21:39:37 -07:00
Justin Meza e3388d5fc7 fixed string interpolation during comparison (as pointed out by @Lucki, thanks) 2015-07-19 11:22:56 -07:00
OrdNas d95f751de5 cherry picking ord-nas's bug fix from master 2014-11-26 21:20:47 -08:00
Justin Meza e8dd671a27 adding some stdlib randomizaton functions 2014-08-31 15:40:21 -07:00
Justin Meza 4da096385e updated tests based on new library syntax 2014-05-05 02:12:29 -04:00
Justin Meza 816ffa2b5d added SOCKS library for socket I/O 2014-05-05 01:46:00 -04:00
Justin Meza 2f608d5150 reordered a couple of tests 2013-03-02 12:55:56 -05:00
Justin Meza e4c4b10504 minor infrastructure stuff 2013-03-02 12:38:49 -05:00
Justin J. Meza 6abb1015d4 added array inheritance alternate syntax test 2011-12-31 22:46:47 -08:00
Justin J. Meza 4d7883a3e7 fixed CMake tests for errors and with input; added BF interpreter benchmark 2011-12-31 22:37:43 -08:00
Justin J. Meza 0ec7a7f583 converted build toolchain to CMake 2011-12-31 20:53:54 -08:00
Justin J. Meza 177466aac8 added basic support for array inheritance 2011-10-28 18:31:36 -04:00
Justin J. Meza 9ab725d97d Added support for array initialization. 2011-09-26 16:16:19 -04:00
Justin J. Meza 72c983d066 Added the calling object reference variable, "ME", and some associated unit tests. 2011-07-19 22:44:42 -07:00
Justin J. Meza c4f564ec1f Added initial array unit tests. 2011-07-01 23:03:17 -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 233aa9481d Added exception handlers to the parser; made SMOOSH require MKAY 2010-12-20 01:17:11 -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 1736db5f0f Implemented variable deallocation 2010-09-02 01:37:20 -07:00
Justin J. Meza a2db1d932f Added variable type initialization 2010-09-01 20:53:46 -07:00
Justin J. Meza 2e14ac0b3f Initial project import 2010-08-09 00:01:59 -07:00