Compare commits

...

67 Commits

Author SHA1 Message Date
Justin J. Meza 6762b72436 Merge pull request #41 from talonbragg/patch-1
Make readme look better
2017-04-13 14:43:55 -07:00
Talon Bragg e4d6a8e6e1 Make readme look better 2017-04-13 12:32:42 -07:00
Justin J. Meza 8a06bf0111 Merge pull request #16 from danielpronych/master
Update README
2017-04-11 15:45:33 -07:00
Justin J. Meza 181f4b3a23 Merge pull request #40 from RedBow/master
Gitignore the generated files
2017-04-11 15:44:26 -07:00
Kimberlee Model ea761978fc Manually removed some of the rsync output that isnt file names 2017-04-11 18:17:33 -04:00
Kimberlee Model 808f122661 so the first one didn't work exactly right so this is it now 'rsync -rv --size-only --dry-run lci2/ lci/ >> lci/.gitignore' 2017-04-11 18:14:25 -04:00
Kimberlee Model a415a82e8b adding a .gitignore file generated to hide files made during build. generated using rsync -rv --dry-run lci2/ lci/ >> lci/.gitignore where PWD is the parent directory of lci/ and lci2/ (which are both copies of the lci repo), and lci2 has been built, and lci is completely clean. 2017-04-11 17:54:20 -04:00
Justin J. Meza d42043c33b fixing interpolated string assignment 2016-03-27 14:01:37 -07:00
Justin J. Meza 4a33fc0df4 Merge pull request #31 from donabrams/master
fix read for input length 2^n, n > 4
2016-03-27 13:10:19 -07:00
Don fb0f233a90 fix write out of bounds where \0 was written outside of allocated memory if input length was exactly 2^n where n > 4 2015-12-14 22:26:17 -07:00
Justin J. Meza 11acb971f4 Merge pull request #30 from 0x0dea/has-an-alternative-article
add HAS AN keyword for grammatically correct declarations
2015-08-30 15:38:24 -07:00
Justin J. Meza 9173a12080 Merge pull request #29 from 0x0dea/relaxed-numeric-conversion
relax numeric conversions from string
2015-08-30 15:37:35 -07:00
Justin J. Meza b1ae721da5 Merge pull request #27 from 0x0dea/invisible
add INVISIBLE operator for writing to stderr
2015-08-30 15:36:27 -07:00
D.E. Akers 31168c6b93 add HAS AN keyword for grammatically correct declarations
http://forum.lolcode.org/viewtopic.php?f=4&t=13#p19
2015-08-15 23:19:36 -04:00
D.E. Akers f48feda78a 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-15 19:43:05 -04:00
D.E. Akers ffbee16a2d 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-13 18:24:26 -04:00
Justin J. Meza 75b2b31eed Merge pull request #25 from Quiri/master
typo make docs
2015-05-10 10:01:54 -07:00
kirill Mint c472961679 typo make docs 2015-05-02 21:56:38 +02:00
Justin Meza 60bb38a1f0 adding Travis CI configuration file 2015-04-12 16:29:59 -07:00
Justin Meza 7200aa9308 adding unhandled string detection error type 2015-04-12 16:28:56 -07:00
Justin Meza 30301eb2a9 Merge branch 'technion-versioncrash' 2015-04-12 16:22:59 -07:00
Technion 8c66da0667 Defensive strategy that prevents a range of possible null pointer errors from causing crashes
This allows a graceful failure in the event of several identified invalid inputs.
2015-04-12 22:38:18 +00:00
Justin J. Meza e017dc68c0 Merge pull request #22 from ord-nas/master
Fixed problem with ME when using alternate method calling syntax
2014-11-26 21:09:49 -08:00
OrdNas 3fe31d043d Fixed problem with ME when using alternate method calling syntax 2014-11-26 17:58:53 -08:00
Justin Meza 00fb94d9b3 fix missing runtime array type check identified by LeartS 2014-10-24 21:57:44 -07:00
Justin Meza 9420332149 fix induction variable update bug identified by LeartS 2014-10-23 22:59:53 -07:00
Daniel Pronych 4c2425e028 Update README
Submit fix to a minor spelling error in the README file.
2014-08-29 12:00:39 -06:00
Justin Meza a315f2bac3 updated webpage 2014-04-21 00:51:10 -04:00
Justin Meza ffdcf19de2 updating README and bumping version 2014-04-21 00:47:04 -04:00
Justin Meza 9381c726b5 added GPLv3 2014-04-21 00:07:12 -04:00
Justin Meza 29677d77ed removed Clang warnings 2013-12-30 12:45:34 -05:00
Justin Meza 0aaa1c9767 added support for Unicode v6.3 2013-12-19 13:35:59 -05:00
Justin Meza 13b08ef469 fixed function resolution issue pointed out by markjreed 2013-10-05 15:09:30 -04:00
Justin Meza d842000e01 minor comment formatting 2013-10-04 23:18:03 -04:00
Mark J. Reed 4cf3583c63 use long long integers instead of ints 2013-10-04 12:17:19 -04:00
Justin Meza e30981166d fixed install script 2013-03-17 19:34:48 -04:00
Justin Meza 483c70d50e added support for Unicode v6.2 2013-03-12 11:04:57 -04:00
Justin Meza 72a524a78c minor infrastructure updates 2013-03-02 12:52:32 -05:00
Justin Meza f5e02cb20c updating license info 2013-01-29 23:53:01 -05:00
Justin Meza f19e8b7ec1 fixed some merge issues 2013-01-29 23:49:42 -05:00
Justin J. Meza 21359c04ef removing old test files 2012-12-26 14:21:43 -08:00
Justin J. Meza 80a4bd083c finally switching master over to future 2012-12-26 13:12:12 -08:00
Justin J. Meza 04702308c8 updated release version 2012-02-17 23:22:25 -05:00
Justin J. Meza ce747b9f09 added support for Unicode v6.1.0 2012-02-03 21:44:48 -05:00
Justin J. Meza c95d6f730c Merge branch 'master' of github.com:justinmeza/lci 2011-06-29 13:27:24 -07:00
Justin J. Meza 7e5912432f Fixed input EOF bug. 2011-06-29 13:27:05 -07:00
Justin J. Meza 6251d087d0 Merge pull request #5 from klnusbaum/master
A new build system
2011-06-14 21:17:12 -07:00
Kurtis Nusbaum 2428030643 Added some documentation to the install script.
-Kurtis
2011-05-25 15:56:40 -06:00
Kurtis Nusbaum 54b07ba4d5 Added documenation on how to build with the new CMake system.
Also modified the CMakeLists so that it actually installs lci.
Modified testDriver.py to throw an error if a Memory Leak is detected.

-Kurtis
2011-05-25 15:52:26 -06:00
Kurtis Nusbaum 40e30c165d Merge branch 'master' of https://github.com/justinmeza/lci 2011-05-25 13:45:49 -06:00
Justin J. Meza d3e80e636e Added parser error for duplicate switch statement literals. 2011-05-22 15:21:53 -04:00
Kurtis Nusbaum 987dc39d13 Added a doxygen target
-Kurtis
2011-05-20 01:15:24 -05:00
Kurtis Nusbaum 36df46ff06 Modified CMakeLists to give a better formated error when it's unable to
find valgrind.

-Kurtis
2011-05-20 00:53:42 -05:00
Kurtis Nusbaum 4b00f1eb75 Test driver can now check for memory leaks. To enable memory leak checking
a CMake option called PERFORM_MEM_TESTS has been added.

-Kurtis
2011-05-20 00:42:40 -05:00
Kurtis Nusbaum 69c673c979 Added support for memory testing but haven't checked to see if it works yet.
-Kurtis
2011-05-19 18:25:43 -05:00
Kurtis Nusbaum d42fd9ce02 Scratch that. The program did actually fail to execute it's just that no error was output. That said, the running of that bad lolcode did return a non-zero return value thus
indicating the program did not succefully run.

-Kurtis
2011-05-19 17:50:42 -05:00
Kurtis Nusbaum 6971ba074c Test driver now more robust. Also found that one of the tests is actually
legitamently failing. There's an error that is supposed to get produced that doesn't.

-Kurtis
2011-05-19 17:46:29 -05:00
Kurtis Nusbaum 491a3fac77 Cleaned up test driver 2011-05-19 16:52:48 -05:00
Kurtis Nusbaum 812b8cd463 All the tests are pasing now.
-Kurtis
2011-05-19 16:48:23 -05:00
Kurtis Nusbaum 47301d8b8a CMakeified everything. Most tests are working with the exception of 2.
-Kurtis
2011-05-19 15:36:46 -05:00
Justin J. Meza 0aa0132dbb Removed GNU Make specific feature from Makefile 2011-03-13 17:31:35 -04:00
Justin J. Meza bfe73bf400 Fixed CAN HAS STDIO? bug 2010-10-15 09:17:48 -07:00
Justin J. Meza 2fe8ec204a Updated make target install 2010-09-19 11:56:28 -07:00
Justin J. Meza b824b16bb0 Minor documentation fixes 2010-09-19 11:40:39 -07:00
Justin J. Meza 4006382ed4 Minor documentation revision 2010-09-02 04:34:27 -07:00
Justin J. Meza 2156f3d997 Minor documentation revision 2010-09-01 20:58:16 -07:00
Justin J. Meza d1b9c07e00 Minor debug output fix 2010-08-30 08:09:24 -07:00
111 changed files with 3399 additions and 179 deletions

2335
.gitignore vendored Normal file

File diff suppressed because it is too large Load Diff

6
.travis.yml Normal file
View File

@ -0,0 +1,6 @@
language: c
compiler:
- gcc
- clang
# Change this to your needs
script: cmake . && make && ctest

674
COPYING Normal file
View File

@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
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/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

View File

@ -1,8 +1,8 @@
lci - a LOLCODE interpreter written in C
# lci - a LOLCODE interpreter written in C
LICENSE
# LICENSE
Copyright (C) 2010-2012 Justin J. Meza
Copyright (C) 2010-2014 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
@ -17,7 +17,7 @@ LICENSE
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
ABOUT
# ABOUT
lci is a LOLCODE interpreter written in C and is designed to be correct,
portable, fast, and precisely documented.
@ -29,17 +29,17 @@ portable, fast, and precisely documented.
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.
compromised.
- precisely documented: lci uses Doxygen to generate literate code
documentation, browsable here.
This project's homepage is at http://icanhaslolcode.org. For help, visit
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 <justin.meza@gmail.com>.
PREREQUISITES
# PREREQUISITES
1. You must have CMake installed (www.cmake.org).
a) If you're using a Linux distro with package managment CMake should be in
@ -47,7 +47,7 @@ PREREQUISITES
2. Python 2.7+ or Python 2.x with the argparse module installed.
INSTALLATION: THE EASY WAY ON LINUX OR MAC OSX
# INSTALLATION: THE EASY WAY ON LINUX OR MAC OSX
1. run the script install.py. Note that
@ -60,7 +60,7 @@ INSTALLATION: THE EASY WAY ON LINUX OR MAC OSX
$ ./install.py --prefix="/home/kurtis/opt"
INSTALLATION: THE MORE INVOLVED WAY ON LINUX OR MAC OSX
# INSTALLATION: THE MORE INVOLVED WAY ON LINUX OR MAC OSX
1. Configure lci using CMake. This can be as simple as opening up the terminal,
navigating to the directory containing lci and typing:
@ -86,13 +86,13 @@ INSTALLATION: THE MORE INVOLVED WAY ON LINUX OR MAC OSX
4. (Optional) Build documentation:
$ make doc
$ make docs
5. (Optional) Run tests:
$ ctest
INSTALLATION ON WINDOWS
# INSTALLATION ON WINDOWS
(Note that the instructions were written from the point of view of Windows 7,
but in practice, any modern version will work.)

View File

@ -64,6 +64,8 @@ static const char *err_msgs[] = {
"%s:%u: expected matching loop name at: %s\n",
/* PR_EXPECTED_STATEMENT */
"%s:%u: expected statement at: %s\n",
/* PR_UNHANDLED_STRING */
"unhandled string detected\n",
/* IN_INVALID_IDENTIFIER_TYPE */
"%s:%u invalid identifier type at: %s\n",
@ -143,6 +145,8 @@ static const char *err_msgs[] = {
"Invalid type\n",
/* IN_FUNCTION_NAME_USED_BY_VARIABLE */
"%s:%u: function name already used by existing variable at: %s\n",
/* IN_CANNOT_CAST_VALUE_TO_ARRAY */
"%s:%u: cannot cast value to array at: %s\n",
};
static const int err_codes[] = {
@ -224,6 +228,7 @@ static const int err_codes[] = {
536, /* IN_INVALID_DECLARATION_TYPE */
537, /* IN_INVALID_TYPE */
538, /* IN_FUNCTION_NAME_USED_BY_VARIABLE */
539, /* IN_CANNOT_CAST_VALUE_TO_ARRAY */
};
void error(ErrorType e, ...)

View File

@ -62,6 +62,7 @@ typedef enum {
PR_EXPECTED_UNARY_FUNCTION,
PR_EXPECTED_MATCHING_LOOP_NAME,
PR_EXPECTED_STATEMENT,
PR_UNHANDLED_STRING,
IN_INVALID_IDENTIFIER_TYPE,
IN_UNABLE_TO_STORE_VARIABLE,
@ -102,6 +103,7 @@ typedef enum {
IN_INVALID_DECLARATION_TYPE,
IN_INVALID_TYPE,
IN_FUNCTION_NAME_USED_BY_VARIABLE,
IN_CANNOT_CAST_VALUE_TO_ARRAY,
} ErrorType;
void error(ErrorType, ...);

View File

@ -4,7 +4,7 @@ import argparse
import sys
import os
#Checks if a string is a positive integer
# Checks if a string is a positive integer
def positiveInt(string):
value = int(string)
if not value >= 1:
@ -16,7 +16,7 @@ def positiveInt(string):
Runs a subprocess using the command parameter.
Before running the command it displays a message
that contains the provided description and where
the output will be sent. If an error occurs,
the output will be sent. If an error occurs,
the errorMsg is displayed.
"""
def runSubProc(command, description, errorMsg, output):
@ -28,13 +28,13 @@ def runSubProc(command, description, errorMsg, output):
if os.name == "nt":
proc = subprocess.Popen(command, stdout=outputFile, stderr=subprocess.STDOUT, shell=True)
else:
proc = subprocess.Popen(command, stdout=outputFile, stderr=subprocess.STDOUT)
proc = subprocess.Popen(command, stdout=outputFile, stderr=subprocess.STDOUT, shell=True)
proc.wait()
if proc.returncode != 0:
print("Error installing: " + errorMsg)
sys.exit(1)
#Remove the CMakeCache.txt so we can garuntee a fresh configure
# Remove the CMakeCache.txt so we can garuntee a fresh configure
if os.path.exists("CMakeCache.txt"):
os.remove("CMakeCache.txt")
@ -72,7 +72,7 @@ runSubProc(
"configure.out")
runSubProc(
[makeCommand, "-j"+j],
[makeCommand, "-j"+j],
"Running make ",
"There was a make error",
"make.out")
@ -80,20 +80,20 @@ runSubProc(
if args.buildDocs:
runSubProc(
[makeCommand, "-j"+j, "docs"],
[makeCommand, "-j"+j, "docs"],
"Building documentation ",
"There was a documentation building error",
"docs.out")
runSubProc(
[makeCommand, "install"],
makeCommand + " install",
"Installing ",
"There was an installation error",
"install.out")
if args.runTests:
runSubProc(
["ctest", "-j"+j],
["ctest", "-j"+j],
"Testing ",
"There was a testing error",
"test.out")

View File

@ -20,34 +20,6 @@ char *copyString(char *data)
return p;
}
/**
* Checks if a string follows the format of a decimal number.
*
* \param [in] data The string to check the format of.
*
* \retval 0 The string is not a decimal number.
*
* \retval 1 The string is a decimal number.
*/
unsigned int isDecString(const char *data)
{
size_t n;
size_t len = strlen(data);
/* Check for an empty string */
if (len == 0) return 0;
/* Check for non-digit, non-hyphen, and non-period characters */
for (n = 0; n < len; n++) {
if (!isdigit(data[n])
&& data[n] != '.'
&& data[n] != '-')
return 0;
}
return 1;
}
/**
* Checks if a string follows the format of a hexadecimal number.
*
@ -111,8 +83,7 @@ char *resolveIdentifierName(IdentifierNode *id,
const char *temp = (char *)(id->id);
ret = malloc(sizeof(char) * (strlen(temp) + 1));
strcpy(ret, temp);
}
else if (id->type == IT_INDIRECT) {
} else if (id->type == IT_INDIRECT) {
ExprNode *expr = (ExprNode *)(id->id);
/* Interpret the identifier expression */
@ -128,8 +99,7 @@ char *resolveIdentifierName(IdentifierNode *id,
ret = copyString(getString(str));
if (!ret) goto resolveIdentifierNameAbort;
deleteValueObject(str);
}
else {
} else {
char *name = resolveIdentifierName(id, scope);
error(IN_INVALID_IDENTIFIER_TYPE, id->fname, id->line, name);
free(name);
@ -197,7 +167,7 @@ ValueObject *createBooleanValueObject(int data)
*
* \retval NULL Memory allocation failed.
*/
ValueObject *createIntegerValueObject(int data)
ValueObject *createIntegerValueObject(long long data)
{
ValueObject *p = malloc(sizeof(ValueObject));
if (!p) {
@ -666,6 +636,10 @@ ScopeObject *getScopeObjectLocal(ScopeObject *src,
/* Check for value in current scope */
for (n = 0; n < current->numvals; n++) {
if (!strcmp(current->names[n], name)) {
if (current->values[n]->type != VT_ARRAY) {
error(IN_VARIABLE_NOT_AN_ARRAY, target->fname, target->line, name);
goto getScopeObjectLocalAbort;
}
free(name);
return getArray(current->values[n]);
}
@ -686,6 +660,81 @@ getScopeObjectLocalAbort: /* In case something goes wrong... */
return NULL;
}
/**
* Gets a scope (possibly by casting a function) without accessing any arrays.
*
* \param [in] src The scope to evaluate \a target under.
*
* \param [in,out] dest The scope to update the value in.
*
* \param [in] target The name of the value containing the scope to get.
*
* \return The scope contained in the value in \a dest, named by evaluating \a
* target under \a src, without accessing any arrays.
*
* \retval NULL Either \a target could not be evaluated in \a src or \a target
* could not be found in \a dest.
*/
/** \todo Add this definition to interpreter.h */
ScopeObject *getScopeObjectLocalCaller(ScopeObject *src,
ScopeObject *dest,
IdentifierNode *target)
{
ScopeObject *current = dest;
char *name = NULL;
/* Look up the identifier name */
name = resolveIdentifierName(target, src);
if (!name) goto getScopeObjectLocalCallerAbort;
/* Check for calling object reference variable */
if (!strcmp(name, "ME")) {
/* Traverse upwards through callers */
for (current = dest;
current->caller;
current = current->caller);
free(name);
return current;
}
/* Traverse upwards through scopes */
do {
unsigned int n;
/* Check for value in current scope */
for (n = 0; n < current->numvals; n++) {
if (!strcmp(current->names[n], name)) {
if (current->values[n]->type != VT_ARRAY
&& current->values[n]->type != VT_FUNC) {
error(IN_VARIABLE_NOT_AN_ARRAY, target->fname, target->line, name);
goto getScopeObjectLocalCallerAbort;
}
free(name);
if (current->values[n]->type == VT_ARRAY)
{
return getArray(current->values[n]);
}
else
{
return dest;
}
}
}
} while ((current = current->parent));
{
char *name = resolveIdentifierName(target, src);
error(IN_VARIABLE_DOES_NOT_EXIST, target->fname, target->line, name);
free(name);
}
getScopeObjectLocalCallerAbort: /* In case something goes wrong... */
/* Clean up any allocated structures */
if (name) free(name);
return NULL;
}
/**
* Gets a value from a scope without accessing its ancestors.
*
@ -1188,38 +1237,20 @@ ValueObject *castIntegerExplicit(ValueObject *node,
case VT_INTEGER:
return createIntegerValueObject(getInteger(node));
case VT_FLOAT:
return createIntegerValueObject((int)getFloat(node));
return createIntegerValueObject((long long)getFloat(node));
case VT_STRING:
if (strstr(getString(node), ":{")) {
/* Perform interpolation */
ValueObject *ret = NULL;
ValueObject *interp = castStringExplicit(node, scope);
int value;
if (!interp) return NULL;
if (!isDecString(getString(interp))) {
error(IN_UNABLE_TO_CAST_VALUE);
deleteValueObject(interp);
return NULL;
}
if (sscanf(getString(interp), "%i", &value) != 1) {
error(IN_EXPECTED_INTEGER_VALUE);
deleteValueObject(interp);
return NULL;
}
long long value = strtoll(getString(interp), NULL, 0);
ret = createIntegerValueObject(value);
deleteValueObject(interp);
return ret;
}
else {
int value;
if (!isDecString(getString(node))) {
error(IN_UNABLE_TO_CAST_VALUE);
return NULL;
}
if (sscanf(getString(node), "%i", &value) != 1) {
error(IN_EXPECTED_INTEGER_VALUE);
return NULL;
}
long long value = strtoll(getString(node), NULL, 0);
return createIntegerValueObject(value);
}
case VT_FUNC:
@ -1265,32 +1296,14 @@ ValueObject *castFloatExplicit(ValueObject *node,
/* Perform interpolation */
ValueObject *ret = NULL;
ValueObject *interp = castStringExplicit(node, scope);
float value;
if (!interp) return NULL;
if (!isDecString(getString(interp))) {
error(IN_UNABLE_TO_CAST_VALUE);
deleteValueObject(interp);
return NULL;
}
if (sscanf(getString(interp), "%f", &value) != 1) {
error(IN_EXPECTED_DECIMAL);
deleteValueObject(interp);
return NULL;
}
float value = strtof(getString(interp), NULL);
ret = createFloatValueObject(value);
deleteValueObject(interp);
return ret;
}
else {
float value;
if (!isDecString(getString(node))) {
error(IN_UNABLE_TO_CAST_VALUE);
return NULL;
}
if (sscanf(getString(node), "%f", &value) != 1) {
error(IN_EXPECTED_DECIMAL);
return NULL;
}
float value = strtof(getString(node), NULL);
return createFloatValueObject(value);
}
case VT_FUNC:
@ -1347,10 +1360,10 @@ ValueObject *castStringExplicit(ValueObject *node,
* One character per integer bit plus one more for the
* null character
*/
size_t size = sizeof(int) * 8 + 1;
size_t size = sizeof(long long) * 8 + 1;
data = malloc(sizeof(char) * size);
if (!data) return NULL;
sprintf(data, "%i", getInteger(node));
sprintf(data, "%lli", getInteger(node));
return createStringValueObject(data);
}
case VT_FLOAT: {
@ -1658,14 +1671,14 @@ ValueObject *interpretFuncCallExprNode(ExprNode *node,
ScopeObject *dest = NULL;
ScopeObject *target = NULL;
target = getScopeObjectLocal(scope, scope, expr->name);
dest = getScopeObject(scope, scope, expr->scope);
target = getScopeObjectLocalCaller(scope, dest, expr->name);
if (!target) return NULL;
outer = createScopeObjectCaller(scope, target);
if (!outer) return NULL;
dest = getScopeObject(scope, scope, expr->scope);
def = getScopeValue(scope, dest, expr->name);
if (!def || def->type != VT_FUNC) {
@ -2966,6 +2979,16 @@ ReturnObject *interpretCastStmtNode(StmtNode *node,
case CT_STRING:
if (!(cast = castStringExplicit(val, scope))) return NULL;
break;
case CT_ARRAY: {
IdentifierNode *id = (IdentifierNode *)(stmt->target);
char *name = resolveIdentifierName(id, scope);
if (name) {
error(IN_CANNOT_CAST_VALUE_TO_ARRAY, id->fname, id->line, name);
free(name);
}
return NULL;
break;
}
}
if (!updateScopeValue(scope, scope, stmt->target, cast)) {
deleteValueObject(cast);
@ -3000,12 +3023,12 @@ ReturnObject *interpretPrintStmtNode(StmtNode *node,
deleteValueObject(use);
return NULL;
}
printf("%s", getString(use));
fprintf(stmt->file, "%s", getString(use));
deleteValueObject(val);
deleteValueObject(use);
}
if (!stmt->nonl)
printf("\n");
putc('\n', stmt->file);
return createReturnObject(RT_DEFAULT, NULL);
}
@ -3039,6 +3062,8 @@ ReturnObject *interpretInputStmtNode(StmtNode *node,
* but do not store it.
*/
if (c == EOF || c == (int)'\r' || c == (int)'\n') break;
temp[cur] = (char)c;
cur++;
if (cur > size - 1) {
/* Increasing buffer size. */
size *= 2;
@ -3050,8 +3075,6 @@ ReturnObject *interpretInputStmtNode(StmtNode *node,
}
temp = mem;
}
temp[cur] = (char)c;
cur++;
}
temp[cur] = '\0';
val = createStringValueObject(temp);
@ -3085,6 +3108,13 @@ ReturnObject *interpretAssignmentStmtNode(StmtNode *node,
AssignmentStmtNode *stmt = (AssignmentStmtNode *)node->stmt;
ValueObject *val = interpretExprNode(stmt->expr, scope);
if (!val) return NULL;
/* interpolate assigned strings */
if (val->type == VT_STRING) {
ValueObject *use = castStringImplicit(val, scope);
deleteValueObject(val);
if (!use) return NULL;
val = use;
}
if (!updateScopeValue(scope, scope, stmt->target, val)) {
deleteValueObject(val);
return NULL;
@ -3461,12 +3491,19 @@ ReturnObject *interpretLoopStmtNode(StmtNode *node,
* variable.
*/
if (stmt->update->type == ET_OP) {
ValueObject *updated = NULL;
var = getScopeValue(scope, outer, stmt->var);
OpExprNode *op = (OpExprNode *)stmt->update->expr;
if (op->type == OP_ADD)
var->data.i++;
updated = createIntegerValueObject(var->data.i + 1);
else if (op->type == OP_SUB)
var->data.i--;
updated = createIntegerValueObject(var->data.i - 1);
if (!updateScopeValue(scope, outer, stmt->var, updated)) {
deleteValueObject(updated);
deleteScopeObject(outer);
return NULL;
}
}
else {
ValueObject *update = interpretExprNode(stmt->update, outer);

View File

@ -63,7 +63,7 @@ typedef enum {
* Stores value data.
*/
typedef union {
int i; /**< Integer data. */
long long i; /**< Integer data. */
float f; /**< Decimal data. */
char *s; /**< String data. */
FuncDefStmtNode *fn; /**< Function data. */
@ -126,9 +126,9 @@ typedef struct scopeobject {
/**@{*/
void printInterpreterError(const char *, IdentifierNode *, ScopeObject *);
char *copyString(char *);
unsigned int isDecString(const char *);
unsigned int isHexString(const char *);
char *resolveIdentifierName(IdentifierNode *, ScopeObject *);
int resolveTerminalSlot(ScopeObject *, ScopeObject *, IdentifierNode *, ScopeObject **, IdentifierNode **);
/**@}*/
/**
@ -139,7 +139,7 @@ char *resolveIdentifierName(IdentifierNode *, ScopeObject *);
/**@{*/
ValueObject *createNilValueObject(void);
ValueObject *createBooleanValueObject(int);
ValueObject *createIntegerValueObject(int);
ValueObject *createIntegerValueObject(long long);
ValueObject *createFloatValueObject(float);
ValueObject *createStringValueObject(char *);
ValueObject *createFunctionValueObject(FuncDefStmtNode *);

4
main.c
View File

@ -4,7 +4,7 @@
* \section license License
*
* lci - a LOLCODE interpreter written in C.
* Copyright (C) 2010-2012 Justin J. Meza
* Copyright (C) 2010-2014 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
@ -151,7 +151,7 @@ int main(int argc, char **argv)
FILE *file = NULL;
int ch;
char *revision = "v0.10.3";
char *revision = "v0.10.5";
program_name = argv[0];
while ((ch = getopt_long(argc, argv, shortopt, longopt, NULL)) != -1) {

View File

@ -176,7 +176,7 @@ ConstantNode *createBooleanConstantNode(int data)
*
* \retval NULL Memory allocation failed.
*/
ConstantNode *createIntegerConstantNode(int data)
ConstantNode *createIntegerConstantNode(long long data)
{
ConstantNode *p = malloc(sizeof(ConstantNode));
if (!p) {
@ -629,6 +629,8 @@ void deleteCastStmtNode(CastStmtNode *node)
*
* \param [in] args The expressions to print.
*
* \param [in] file Where to print (\c stdout or \c stderr).
*
* \param [in] nonl Whether an ending newline should be surpressed.
*
* \return A pointer to the print statement with the desired properties.
@ -636,6 +638,7 @@ void deleteCastStmtNode(CastStmtNode *node)
* \retval NULL Memory allocation failed.
*/
PrintStmtNode *createPrintStmtNode(ExprNodeList *args,
FILE *file,
int nonl)
{
PrintStmtNode *p = malloc(sizeof(PrintStmtNode));
@ -644,6 +647,7 @@ PrintStmtNode *createPrintStmtNode(ExprNodeList *args,
return NULL;
}
p->args = args;
p->file = file;
p->nonl = nonl;
return p;
}
@ -1368,6 +1372,7 @@ int acceptToken(Token ***tokenp,
TokenType token)
{
Token **tokens = *tokenp;
if (!(*tokens)) return 0;
if ((*tokens)->type != token) return 0;
tokens++;
*tokenp = tokens;
@ -1427,7 +1432,11 @@ int nextToken(Token ***tokenp,
void parser_error(ErrorType type,
Token **tokens)
{
error(type, (*tokens)->fname, (*tokens)->line, (*tokens)->image);
if (!(*tokens)) {
error(PR_UNHANDLED_STRING);
} else {
error(type, (*tokens)->fname, (*tokens)->line, (*tokens)->image);
}
}
/**
@ -2472,6 +2481,7 @@ StmtNode *parsePrintStmtNode(Token ***tokenp)
{
ExprNode *arg = NULL;
ExprNodeList *args = NULL;
FILE *file = stdout;
int nonl = 0;
PrintStmtNode *stmt = NULL;
StmtNode *ret = NULL;
@ -2484,13 +2494,21 @@ StmtNode *parsePrintStmtNode(Token ***tokenp)
debug("ST_PRINT");
#endif
/* Remove the print keyword from the token stream */
/**
* Remove the print keyword from the token stream
* A "quad-bool" is used to indicate whether we succeeded or failed to
* accept either a \c TT_VISIBLE or \c TT_INVISIBLE token.
*/
status = acceptToken(&tokens, TT_VISIBLE);
if (!status) {
parser_error_expected_token(TT_VISIBLE, tokens);
if (!status) status = acceptToken(&tokens, TT_INVISIBLE) ? 2 : -1;
if (status < 1) {
parser_error_expected_token(TT_VISIBLE - status, tokens);
goto parsePrintStmtNodeAbort;
}
/* Use standard error if we accepted a \c TT_INVISIBLE above */
if (status == 2) file = stderr;
/* Parse the arguments to the print statement */
args = createExprNodeList();
if (!args) goto parsePrintStmtNodeAbort;
@ -2510,7 +2528,7 @@ StmtNode *parsePrintStmtNode(Token ***tokenp)
&& !peekToken(&tokens, TT_BANG));
/* Check for the no-newline token */
if(acceptToken(&tokens, TT_BANG)) nonl = 1;
if (acceptToken(&tokens, TT_BANG)) nonl = 1;
/* Make sure the statement ends with a newline */
status = acceptToken(&tokens, TT_NEWLINE);
@ -2520,7 +2538,7 @@ StmtNode *parsePrintStmtNode(Token ***tokenp)
}
/* Create the new PrintStmtNode structure */
stmt = createPrintStmtNode(args, nonl);
stmt = createPrintStmtNode(args, file, nonl);
if (!stmt) goto parsePrintStmtNodeAbort;
/* Create the new StmtNode structure */
@ -2720,8 +2738,10 @@ StmtNode *parseDeclarationStmtNode(Token ***tokenp)
if (!scope) goto parseDeclarationStmtNodeAbort;
/* Remove the declaration keywords from the token stream */
if (!acceptToken(&tokens, TT_HASA)) {
parser_error_expected_token(TT_HASA, tokens);
status = acceptToken(&tokens, TT_HASA);
if (!status) status = acceptToken(&tokens, TT_HASAN) || -1;
if (status < 1) {
parser_error_expected_token(TT_HASA - status, tokens);
goto parseDeclarationStmtNodeAbort;
}
@ -3916,7 +3936,7 @@ StmtNode *parseStmtNode(Token ***tokenp)
ret = parseAssignmentStmtNode(tokenp);
}
/* Variable declaration */
else if (peekToken(&tokens, TT_HASA)) {
else if (peekToken(&tokens, TT_HASA) || peekToken(&tokens, TT_HASAN)) {
ret = parseDeclarationStmtNode(tokenp);
}
/* Deallocation */
@ -3958,6 +3978,10 @@ StmtNode *parseStmtNode(Token ***tokenp)
else if (peekToken(&tokens, TT_VISIBLE)) {
ret = parsePrintStmtNode(tokenp);
}
/* Warn */
else if (peekToken(&tokens, TT_INVISIBLE)) {
ret = parsePrintStmtNode(tokenp);
}
/* Input */
else if (peekToken(&tokens, TT_GIMMEH)) {
ret = parseInputStmtNode(tokenp);

View File

@ -70,6 +70,7 @@
*
* \par
* PrintStmtNode ::= \c TT_VISIBLE ExprNodeList \c TT_BANG ? \c TT_NEWLINE
* | \c TT_INVISIBLE ExprNodeList \c TT_BANG ? \c TT_NEWLINE
*
* \par
* InputStmtNode ::= \c TT_GIMMEH IdentifierNode \c TT_NEWLINE
@ -79,7 +80,8 @@
*
* \par
* DeclarationStmtNode ::= IdentifierNode \c TT_HASA IdentifierNode
* Initialization ? \c TT_NEWLINE
* Initialization ? \c TT_NEWLINE | IdentifierNode \c TT_HASAN
* IdentifierNode Initialization ? \c TT_NEWLINE
*
* \par
* Initialization ::= \c TT_ITZ ExprNode | \c TT_ITZA TypeNode | \c TT_ITZLIEKA IdentifierNode
@ -332,9 +334,9 @@ typedef enum {
* Stores constant data.
*/
typedef union {
int i; /**< Integer data. */
float f; /**< Decimal data. */
char *s; /**< String data. */
long long i; /**< Integer data. */
float f; /**< Decimal data. */
char *s; /**< String data. */
} ConstantData;
/**
@ -395,6 +397,7 @@ typedef struct {
*/
typedef struct {
ExprNodeList *args; /**< The expressions to print. */
FILE *file; /**< Where to print (\c stdout or \c stderr). */
int nonl; /**< Whether to print an ending newline. */
} PrintStmtNode;
@ -612,7 +615,7 @@ void deleteCastStmtNode(CastStmtNode *);
* Functions for creating and deleting PrintStmtNodes.
*/
/**@{*/
PrintStmtNode *createPrintStmtNode(ExprNodeList *, int);
PrintStmtNode *createPrintStmtNode(ExprNodeList *, FILE *, int);
void deletePrintStmtNode(PrintStmtNode *);
/**@}*/
@ -810,7 +813,7 @@ StmtNode *parseAltArrayDefStmtNode(Token ***);
*/
/**@{*/
ConstantNode *createBooleanConstantNode(int);
ConstantNode *createIntegerConstantNode(int);
ConstantNode *createIntegerConstantNode(long long);
ConstantNode *createFloatConstantNode(float);
ConstantNode *createStringConstantNode(char *);
void deleteConstantNode(ConstantNode *);

View File

@ -1,12 +1,4 @@
add_subdirectory(1-EmptyMainBlock)
add_subdirectory(10-CommasSeparate)
add_subdirectory(11-EllipsesJoinLF)
add_subdirectory(12-EllipsesJoinCR)
add_subdirectory(13-EllipsesJoinCRLF)
add_subdirectory(14-NoNewlineAfterJoinLF)
add_subdirectory(15-NoNewlineAfterJoinCR)
add_subdirectory(16-NoNewlineAfterJoinCRLF)
add_subdirectory(17-Includes)
add_subdirectory(2-MustBeginWithHAI)
add_subdirectory(3-MustIncludeVersion)
add_subdirectory(4-MustEndWithKTHXBYE)
@ -15,3 +7,11 @@ add_subdirectory(6-WhitespaceBetweenTokens)
add_subdirectory(7-NewlineLF)
add_subdirectory(8-NewlineCR)
add_subdirectory(9-NewlineCRLF)
add_subdirectory(10-CommasSeparate)
add_subdirectory(11-EllipsesJoinLF)
add_subdirectory(12-EllipsesJoinCR)
add_subdirectory(13-EllipsesJoinCRLF)
add_subdirectory(14-NoNewlineAfterJoinLF)
add_subdirectory(15-NoNewlineAfterJoinCR)
add_subdirectory(16-NoNewlineAfterJoinCRLF)
add_subdirectory(17-Includes)

View File

@ -1,2 +0,0 @@
INCLUDE(AddLolTest)
ADD_LOL_TEST(11-AlternateSyntax OUTPUT test.out)

View File

@ -0,0 +1,2 @@
INCLUDE(AddLolTest)
ADD_LOL_TEST(11-CallingObjectAlternateSyntax OUTPUT test.out)

View File

@ -0,0 +1,15 @@
HAI 1.3
I HAS A foo ITZ A BUKKIT
foo HAS A bar ITZ 123
HOW IZ foo fun1
I HAS A bar ITZ 4.567
VISIBLE bar
VISIBLE ME'Z bar
ME'Z bar R 890
VISIBLE ME'Z bar
IF U SAY SO
foo IZ fun1 MKAY
VISIBLE foo'Z bar
KTHXBYE

View File

@ -0,0 +1 @@
This test checks that the alternate syntax for calling a function in an array slot works.

View File

@ -0,0 +1,2 @@
INCLUDE(AddLolTest)
ADD_LOL_TEST(12-AlternateSyntax OUTPUT test.out)

View File

@ -0,0 +1,4 @@
4.56
123
890
890

View File

@ -1,7 +1,4 @@
add_subdirectory(1-EmptyArray)
add_subdirectory(10-CallingObjectInitialization)
add_subdirectory(11-AlternateSyntax)
add_subdirectory(12-Inheritance)
add_subdirectory(2-SlotCreation)
add_subdirectory(3-SlotInitialization)
add_subdirectory(4-SlotAssignment)
@ -10,3 +7,7 @@ add_subdirectory(6-FunctionDeclaration)
add_subdirectory(7-CallingObjectReference)
add_subdirectory(8-CallingObjectAssignment)
add_subdirectory(9-CallingObjectDeclaration)
add_subdirectory(10-CallingObjectInitialization)
add_subdirectory(13-Inheritance)
add_subdirectory(12-AlternateSyntax)
add_subdirectory(11-CallingObjectAlternateSyntax)

View File

@ -1,5 +1,4 @@
add_subdirectory(1-SeparateStartEndLines)
add_subdirectory(10-AfterKTHXBYE)
add_subdirectory(2-SeparateStartLineOnly)
add_subdirectory(3-SeparateEndLineOnly)
add_subdirectory(4-MustStartOnSeparateLine)
@ -8,3 +7,4 @@ add_subdirectory(6-BeginAfterLineSeparator)
add_subdirectory(7-EndBeforeLineSeparator)
add_subdirectory(8-IgnoreEmbeddedBTW)
add_subdirectory(9-BeforeHAI)
add_subdirectory(10-AfterKTHXBYE)

View File

@ -0,0 +1,6 @@
add_subdirectory(1-Output)
add_subdirectory(2-Initialization)
add_subdirectory(3-Assignment)
add_subdirectory(4-TypeInitialization)
add_subdirectory(5-Deallocation)
add_subdirectory(6-Functions)

View File

@ -0,0 +1,2 @@
INCLUDE(AddLolTest)
ADD_LOL_TEST(11-AlternativeArticle OUTPUT test.out)

View File

@ -0,0 +1,5 @@
HAI 1.3
I HAS AN array ITZ A BUKKIT
array HAS AN element ITZ "catmium"
VISIBLE array'Z element
KTHXBYE

View File

@ -0,0 +1 @@
catmium

View File

@ -0,0 +1,2 @@
This test checks that variables may be declared using the
grammatically appropriate indefinite article.

View File

@ -7,3 +7,5 @@ add_subdirectory(6-Assignment)
add_subdirectory(7-AssignmentSameVariable)
add_subdirectory(8-TypeInitialization)
add_subdirectory(9-Deallocation)
add_subdirectory(10-Indirect)
add_subdirectory(11-AlternativeArticle)

View File

@ -1,2 +1,2 @@
INCLUDE(AddLolTest)
ADD_LOL_TEST(2-EmptyString ERROR)
ADD_LOL_TEST(2-EmptyString OUTPUT test.out)

View File

@ -1,3 +1,3 @@
HAI 1.3
MAEK "" A NUMBR
VISIBLE MAEK "" A NUMBR
KTHXBYE

View File

@ -1,2 +1,2 @@
This test checks to make sure explicitly casting an empty string to an integer
type results in an error.
type results in 0.

View File

@ -1,2 +1,2 @@
INCLUDE(AddLolTest)
ADD_LOL_TEST(3-NonNumber ERROR)
ADD_LOL_TEST(3-NonNumber OUTPUT test.out)

View File

@ -1,3 +1,3 @@
HAI 1.3
MAEK "abc" A NUMBR
VISIBLE MAEK "abc" A NUMBR
KTHXBYE

View File

@ -1,2 +1,2 @@
This test checks to make sure explicitly casting a non-number string to an
integer type results in an error.
integer type results in 0.

View File

@ -0,0 +1,2 @@
INCLUDE(AddLolTest)
ADD_LOL_TEST(4-RelaxedNumbers OUTPUT test.out)

View File

@ -0,0 +1,6 @@
HAI 1.3
VISIBLE MAEK " 123" A NUMBR BTW leading whitespace is ignored
VISIBLE MAEK "123x" A NUMBR BTW parsing stops at the first non-digit
VISIBLE MAEK "0377" A NUMBR BTW octal prefix
VISIBLE MAEK "0xFF" A NUMBR BTW hexadecimal prefix
KTHXBYE

View File

@ -0,0 +1,2 @@
This test checks that the explicit cast operator correctly casts string values
to integer types as would be done by libc's strtoll() function.

View File

@ -1,3 +1,4 @@
add_subdirectory(1-Numbers)
add_subdirectory(2-EmptyString)
add_subdirectory(3-NonNumber)
add_subdirectory(4-RelaxedNumbers)

View File

@ -1,2 +1,2 @@
INCLUDE(AddLolTest)
ADD_LOL_TEST(2-EmptyString ERROR)
ADD_LOL_TEST(2-EmptyString OUTPUT test.out)

View File

@ -1,3 +1,3 @@
HAI 1.3
MAEK "" A NUMBAR
VISIBLE MAEK "" A NUMBAR
KTHXBYE

View File

@ -1,2 +1,2 @@
This test checks to make sure explicitly casting an empty string to a floating
point decimal type results in an error.
point decimal type results in 0.00.

View File

@ -1,2 +1,2 @@
INCLUDE(AddLolTest)
ADD_LOL_TEST(3-NonNumber ERROR)
ADD_LOL_TEST(3-NonNumber OUTPUT test.out)

View File

@ -1,3 +1,3 @@
HAI 1.3
MAEK "abc" A NUMBAR
VISIBLE MAEK "abc" A NUMBAR
KTHXBYE

View File

@ -1,2 +1,2 @@
This test checks to make sure explicitly casting a non-number string to a
floating point decimal type results in an error.
floating point decimal type results in 0.00.

View File

@ -0,0 +1,2 @@
INCLUDE(AddLolTest)
ADD_LOL_TEST(4-RelaxedNumbers OUTPUT test.out)

View File

@ -0,0 +1,4 @@
HAI 1.3
VISIBLE MAEK " 1.23" A NUMBAR BTW leading whitespace is ignored
VISIBLE MAEK "1.23x" A NUMBAR BTW parsing stops at the first non-digit
KTHXBYE

View File

@ -0,0 +1,2 @@
This test checks that the explicit cast operator correctly casts string values
to floating point decimal types as would be done by libc's strtof() function.

View File

@ -1,3 +1,4 @@
add_subdirectory(1-Numbers)
add_subdirectory(2-EmptyString)
add_subdirectory(3-NonNumber)
add_subdirectory(4-RelaxedNumbers)

View File

@ -1,2 +1,2 @@
INCLUDE(AddLolTest)
ADD_LOL_TEST(2-EmptyString ERROR)
ADD_LOL_TEST(2-EmptyString OUTPUT test.out)

View File

@ -1,4 +1,5 @@
HAI 1.3
I HAS A var ITZ ""
var IS NOW A NUMBR
VISIBLE var
KTHXBYE

View File

@ -1,2 +1,2 @@
This test checks to make sure explicitly recasting an empty string to an
integer type results in an error.
integer type results in 0.

View File

@ -1,2 +1,2 @@
INCLUDE(AddLolTest)
ADD_LOL_TEST(3-NonNumber ERROR)
ADD_LOL_TEST(3-NonNumber OUTPUT test.out)

View File

@ -1,4 +1,5 @@
HAI 1.3
I HAS A var ITZ "abc"
var IS NOW A NUMBR
VISIBLE var
KTHXBYE

View File

@ -1,2 +1,2 @@
This test checks to make sure explicitly recasting a non-number string to an
integer type results in an error.
integer type results in 0.

View File

@ -0,0 +1,2 @@
INCLUDE(AddLolTest)
ADD_LOL_TEST(4-RelaxedNumbers OUTPUT test.out)

View File

@ -0,0 +1,14 @@
HAI 1.3
I HAS A var1 ITZ " 123" BTW leading whitespace is ignored
I HAS A var2 ITZ "123x" BTW parsing stops at the first non-digit
I HAS A var3 ITZ "0377" BTW octal prefix
I HAS A var4 ITZ "0xFF" BTW hexadecimal prefix
var1 IS NOW A NUMBR
var2 IS NOW A NUMBR
var3 IS NOW A NUMBR
var4 IS NOW A NUMBR
VISIBLE var1
VISIBLE var2
VISIBLE var3
VISIBLE var4
KTHXBYE

View File

@ -0,0 +1,2 @@
This test checks that the explicit recast operator correctly casts string
values to integer types as would be done by libc's strtoll() function.

View File

@ -1,3 +1,4 @@
add_subdirectory(1-Numbers)
add_subdirectory(2-EmptyString)
add_subdirectory(3-NonNumber)
add_subdirectory(4-RelaxedNumbers)

View File

@ -1,2 +1,2 @@
INCLUDE(AddLolTest)
ADD_LOL_TEST(2-EmptyString ERROR)
ADD_LOL_TEST(2-EmptyString OUTPUT test.out)

View File

@ -1,4 +1,5 @@
HAI 1.3
I HAS A var ITZ ""
var IS NOW A NUMBAR
VISIBLE var
KTHXBYE

View File

@ -1,2 +1,2 @@
This test checks to make sure explicitly recasting an empty string to a
floating point decimal type results in an error.
floating point decimal type results in 0.00.

View File

@ -1,2 +1,2 @@
INCLUDE(AddLolTest)
ADD_LOL_TEST(3-NonNumber ERROR)
ADD_LOL_TEST(3-NonNumber OUTPUT test.out)

View File

@ -1,4 +1,5 @@
HAI 1.3
I HAS A var ITZ "abc"
var IS NOW A NUMBAR
VISIBLE var
KTHXBYE

View File

@ -1,2 +1,2 @@
This test checks to make sure explicitly recasting a non-number string to a
floating point decimal type results in an error.
floating point decimal type results in 0.00.

View File

@ -0,0 +1,2 @@
INCLUDE(AddLolTest)
ADD_LOL_TEST(4-RelaxedNumbers OUTPUT test.out)

View File

@ -0,0 +1,8 @@
HAI 1.3
I HAS A var1 ITZ " 1.23" BTW leading whitespace is ignored
I HAS A var2 ITZ "1.23x" BTW parsing stops at the first non-digit
var1 IS NOW A NUMBAR
var2 IS NOW A NUMBAR
VISIBLE var1
VISIBLE var2
KTHXBYE

Some files were not shown because too many files have changed in this diff Show More