This commit updates the Makefile to complile each .c source file into
an object before linking. The benefit of this is that only the necessary
files will be recompiled when modifying the code.
We also move the Makefile and build.bat up to the root directory of the
repo. This is so that calling make directly builds the binaries.
Both files are updated to adapt to the new directory structure.
With this change, initial build times are increased from ~3s to ~10s on
my machine. However, subsequent build times are improved.
As a result of this change, SConstruct is somewhat deprecated. We can
update this as well if necessary in a future change.
I verified that the build completes successfully and tests pass for
both ubuntu and windows 10.
A future change could compile src/ files into a static library to be
linked with cli/, if necessary.
Issue: #64
Introduced a new function `readLine()` that utilizes the byte buffer
together with `fgetc()` to read input from the STDIN. This enables
the REPL to read characters one at a time for validation & in a
safer manner where the buffer gets to be resized if it's full.
Currently, it is required for the shell's working directory to be in
the repo's test/ directory in order for the tests to run correctly.
This also applies for the static analysis checker.
The reason for this is that paths in the test orchestration code are
defined relative to the test directory. Instead, and since none of
these scripts are modules that will in the forseeable future be
imported into other files, we update all paths to be relative
to the absolute path of the script's file itself.
┏( ͡❛ ͜ʖ ͡❛)┛
This commit implements list addition. A new list is allocated, and
the contents of l1 and l2 are concatenated onto the list.
This is done by extending the buffer template macro to support a
`concat` operation, which given an `other` buffer, appends all
elements of the `other` buffer to the end of the `self` buffer.
Allocations are done as needed.
We implement this additional operation, since the alternative would
be to call `reserve()` for each `write()` operation, which doesn't
seem ideal.
Issue: #55
* fixed typos in src/
* fixed typos in docs/
* fixed typos in README and tests/
* rename INITALIZE to INITIALIZE
* rename PRIMITE to PRIMITIVE
* rename moudle to module
Co-authored-by: Alexander Patel <acpatel@andrew.cmu.edu>
This commit addresses issue #54 in an attempt to add more bitwise
operators to pocketlang. Tests have also been written to verify that
the operators indeed works as expected.
To add, I also introduced a macro PK_RIGHT_OP that just aliases the
string "Right operand" which was already getting too hardcoded and
appearing too much in the pk_core.c file.
* Fix#54: Add bitwise OR operator and make it available in PKVM
Like the bitwise AND, this is an implementation for pocketlang to
support the bitwise OR operation. In addition, updated "value" ->
"result" in other operation to correctly reflect the container's
purpose. It's indeed the result after the operation, which is a value
too.
In addition, add tests for bitwise AND (&) and bitwise OR (|). Add a
print statement in test file with message that all tests passed with
no errors.
* Fix typo in comment
* Cleanup fixes
I've also written tests in the corresponding test files, please have
a look. But on the command line (after compiling the source), do:
>>> from math import *
>>> print(cos(1))
[ results will be displayed here ]
>>> print(tan(1))
[ results will be displayed here ]
* While reading various files in the repo, just going ahead to
clean up some typos (for clarity of text).
* When calling `realloc()`, let the pointer be returned to the
first byte of the memory block after resize. Compiler warns against
not doing this too.
* In addition, rename the file uitls.c to "utils.c" which seems to
be the correct name in this case.
NOTE: I recompiled and tested the `./pocket` intepreter and it still
works as expected.