A LOLCODE interpreter written in C.
Go to file
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
cmake sanitize outside inputs 2015-07-29 21:53:03 -07:00
test relax numeric conversions from string 2015-08-30 15:45:53 -07:00
.gitignore updated .gitignore with tags 2013-03-02 12:44:44 -05:00
.travis.yml minor formatting changes; adding unit tests to Travis CI 2015-03-08 17:22:36 -04:00
CMakeLists.txt added SOCKS library for socket I/O 2014-05-05 01:46:00 -04:00
COPYING added GPLv3 2014-04-21 00:08:26 -04:00
Doxyfile updated Doxygen info 2012-12-26 12:46:07 -08:00
README fix command to make documentation in README 2015-05-10 10:03:13 -07:00
README.md fix command to make documentation in README 2015-05-10 10:03:13 -07:00
binding.c interpolate SCRIBBEL operand 2015-08-14 19:44:38 -04:00
binding.h minor cleanup 2014-08-31 14:36:07 -07:00
error.c patched ElColmo's system command code with some minor style changes 2014-05-09 23:59:18 -04:00
error.h patched ElColmo's system command code with some minor style changes 2014-05-09 23:59:18 -04:00
inet.c added SOCKS library for socket I/O 2014-05-05 01:46:00 -04:00
inet.h fix implicit declaration of close with unistd.h 2014-10-24 22:02:26 -07:00
install.py fixed install script 2013-03-17 19:38:33 -04:00
interpreter.c relax numeric conversions from string 2015-08-30 15:45:53 -07:00
interpreter.h relax numeric conversions from string 2015-08-30 15:45:53 -07:00
lci.png Added basic array functionality and cleaned up documentation. 2011-06-14 23:54:12 -07:00
lexer.c cleaning up binding code 2013-02-24 15:44:33 -05:00
lexer.h minor bookkeeping changes 2012-12-13 00:02:17 -05:00
main.c bumping version for new release 2014-12-12 15:09:31 -08:00
parser.c add INVISIBLE operator for writing to stderr 2015-08-30 15:45:26 -07:00
parser.h add INVISIBLE operator for writing to stderr 2015-08-30 15:45:26 -07:00
tokenizer.c use long long integers instead of ints 2013-12-19 12:51:13 -05:00
tokenizer.h add INVISIBLE operator for writing to stderr 2015-08-30 15:45:26 -07:00
unicode.c fixed string interpolation during comparison (as pointed out by @Lucki, thanks) 2015-07-19 11:22:56 -07:00
unicode.h scope storage and access performance optimizations 2014-10-26 20:16:26 -07:00

README.md

lci

Build status

lci is a LOLCODE (http://lolcode.org) interpreter written in C and is designed to be correct, portable, fast, and precisely documented.

  • Correct: Every effort has been made to test lci's conformance to the LOLCODE language specification. Unit tests come packaged with the lci source code.

  • Portable: lci follows the widely ported ANSI C specification allowing it to compile on a broad range of systems.

  • Fast: Much effort has gone into producing simple and efficient code whenever possible to the extent that the above points are not compromized.

  • Precisely documented: lci uses Doxygen to generate literate code documentation, browsable here.

This project's homepage is at http://lolcode.org. For help, visit http://groups.google.com/group/lci-general. To report a bug, go to http://github.com/justinmeza/lci/issues.

Created and maintained by Justin J. Meza (http://justinmeza.com).

Prerequisites

  1. You must have CMake installed (http://www.cmake.org).
  • If you're using a Linux distro with package managment CMake should be in your repositories.
  1. Python 2.7+ or Python 2.x with the argparse module installed.

Installation: The Easy Way on Linux or OSX

Run the script install.py. Note that

$ ./install.py -h

will display a list of relavent install options. For example, to install lci to the directory /home/foo/opt, run:

$ ./install.py --prefix="/home/foo/opt"

Installation: The More Involved Way on Linux or OSX

  1. Configure lci using CMake. This can be as simple as opening up the terminal, navigating to the directory containing lci and typing:

$ cmake .

You can also provide any other argument to the CMake configuration process you'd like. To enable Memory testing turn the PERFORM_MEM_TESTS option on like so:

$ cmake -DPERFORM_MEM_TESTS:BOOL=ON .

You can also use the ccmake command or the CMake GUI if you prefer. See the cmake documentation for more details.

  1. Build the project:

$ make

  1. Install

$ make install

  1. (Optional) Build documentation:

$ make docs

  1. (Optional) Run tests:

$ ctest

License

Copyright (C) 2010-2015 Justin J. Meza

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.