Commit Graph

45 Commits

Author SHA1 Message Date
Justin J. Meza 574f4bb175 fixing some NULL return checks 2016-03-27 14:03:39 -07:00
Justin J. Meza 2844f261f9 fixing interpolated string assignment 2016-03-27 13:56:22 -07:00
Justin J. Meza 84b5c623ff patching with @donabrams's fix 2016-03-27 13:23:57 -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
D.E. Akers f1881ad63f add INVISIBLE operator for writing to stderr
Printing warnings and the like to the standard error stream is common
courtesy, not least because it avoids cluttering the program's output
with diagnostic messages.

Neither the 1.2 specification nor any of the proposals for 1.3 mention
using `INVISIBLE` for this purpose. Nevertheless, the operator and the
behavior described herein have seen sufficiently wide adoption in other
LOLCODE interpreters that I believe `lci` would do well to follow suit.

This patch attempts to be minimally invasive. Rather than adding a new
node type and all that that entails, the `PrintStmtNode` structure now
has a `FILE *` field containing the file to which the node should print
during interpretation. This saves a branch in `interpretPrintStmtNode()`
at the cost of making the structure negligibly larger on most systems.

Adding tests for `INVISIBLE` would require rethinking the test driver,
which presently uses the existence of output on `stderr` to detect that
an "expected error" has occurred. I'll happily try my hand at making the
necessary modifications if this patch comes to be accepted.
2015-08-30 15:45:26 -07:00
D.E. Akers 63603ada2e interpolate system commands
It may be the case that operands to `I DUZ` should not undergo
interpolation, but I'm unable to perceive the rationale. In any case,
the fix is simply to pass the argument through `castStringExplicit()`,
which is unlikely to break any existing code.

I considered adding a test, only to discover that `I DUZ` itself is not
presently being tested. I suppose this is probably to do with its being
a future feature, or else that ensuring its proper functionality across
platforms wouldn't be trivial.

In the latter case, the `echo` command is likely to be available in the
vast majority of environments, and is probably the best candidate for
testing this facet of the language.
2015-08-13 15:27:31 -04: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 e500678dae scope storage and access performance optimizations 2014-10-26 20:16:26 -07:00
Justin Meza ef823bc1a0 fix missing runtime array type check identified by LeartS 2014-10-24 22:00:57 -07:00
Justin Meza 5627045d83 fix induction variable update bug identified by LeartS 2014-10-23 22:57:10 -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 74b80b4aca updated some library code 2014-05-05 11:30:35 -04: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 f4ba7daf49 fixed function resolution issue pointed out by markjreed 2013-10-05 15:24:00 -04:00
Justin Meza f5ac2751bf added experimental interactive mode 2013-03-10 17:23:53 -04: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 b74839d704 new error infrastructure added 2012-12-12 23:53:54 -05:00
Justin J. Meza 6d58808ba6 added support for alternate array declaration inheritance 2011-12-23 11:09:11 -05:00
Justin J. Meza 0a8d6d41c6 Merge branch 'future' of github.com:justinmeza/lci into future 2011-10-28 18:32:05 -04:00
Justin J. Meza 177466aac8 added basic support for array inheritance 2011-10-28 18:31:36 -04:00
Justin J. Meza b47eaa5a7b fixed memory leak with alternate array definition statements 2011-10-01 09:56:03 -07: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 35750a835d Added basic support for the calling object reference variable, "ME". 2011-07-19 00:02:43 -07:00
Justin J. Meza dd5622fbf8 Added an error message in certain cases when a variable is used before being declared. 2011-07-17 20:22:20 -07:00
Justin J. Meza 6bb4543682 Minor bookkeeping changes. 2011-07-02 17:42:07 -07:00
Justin J. Meza c4f564ec1f Added initial array unit tests. 2011-07-01 23:03:17 -07:00
Justin J. Meza c3ded8ddab Fixed a segfault when attempting to declare a function in a non-array type value. 2011-07-01 22:38:12 -07:00
Justin J. Meza 35e24ff5e9 Fixed input EOF bug and updated main documentation. 2011-06-29 13:25:56 -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 977e3dfde5 Merged cleaned up source code 2010-12-22 18:06:32 -05:00
Justin J. Meza 6ebeb26d18 Updated documentation 2010-12-21 22:16:22 -05:00
Justin J. Meza 78456aabfd Merged SRS and de-linted code 2010-12-21 03:20:31 -05:00
Justin J. Meza ec3a650876 Added SRS; made SMOOSH require MKAY 2010-12-20 18:30:37 -05:00
Justin J. Meza 93a0e9c1be Minor documentation fixes 2010-11-16 01:12:08 -05:00
Justin J. Meza 465152505d Minor documentation revision 2010-11-16 00:56:20 -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