Commit Graph

155 Commits

Author SHA1 Message Date
Alexander Patel
90f95391b3 Makefile: compile objects individually, then link
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
2021-06-17 00:56:09 -07:00
Thakee Nathees
1e6fd9de5e
Merge pull request #87 from ThakeeNathees/minor-refactors
Renamed GC functions rename for documenting.
2021-06-17 01:13:14 +05:30
Thakee Nathees
d0229a9744 minor refactors for internal documenting. 2021-06-17 01:05:37 +05:30
Thakee Nathees
2b92758b83
Merge pull request #83 from xSavitar/fix-issue-79
Improve REPL to use a byte buffer with `fgetc()` to read line
2021-06-16 17:30:16 +05:30
Derick Alangi
c7a6bdec49 Improve REPL to use a byte buffer with fgetc() to read line
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.
2021-06-16 12:14:23 +01:00
Thakee Nathees
d8f1ee8fe3
Merge pull request #75 from ekinbarut/master
Changed the elif notation to else if
2021-06-16 14:04:34 +05:30
Ekin
22669bc226 changed the keyword in unit tests, prism and in the md 2021-06-16 11:14:35 +03:00
Thakee Nathees
8bfe0930c5
Merge pull request #82 from alexcpatel/add-alexcpatel-author
AUTHORS: add alexcpatel to authors
2021-06-16 10:42:08 +05:30
Thakee Nathees
1d8cd13d4e
Merge pull request #81 from alexcpatel/tests-from-anywhere
tests: allow tests to be called from anywhere
2021-06-16 10:40:42 +05:30
Alexander Patel
3a83b8aca3 AUTHORS: add alexcpatel to authors 2021-06-15 22:09:08 -07:00
Alexander Patel
d830a59c7c tests: allow tests to be called from anywhere
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.

┏( ͡❛ ͜ʖ ͡❛)┛
2021-06-15 21:41:36 -07:00
Thakee Nathees
03f3f3dc80
Merge pull request #80 from alexcpatel/list-addition
pk_core: implement list addition
2021-06-16 09:59:46 +05:30
Alexander Patel
59333177cd pk_core: implement list addition
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
2021-06-15 20:44:10 -07:00
Thakee Nathees
5f6f66517f Merge pull request #77 from ThakeeNathees/ci-workflow2
ci workflow script (build.yml) created [2/2]
2021-06-16 05:19:19 +05:30
Thakee Nathees
ccb1ae4151 ci workflow script (build.yml) created 2021-06-16 03:33:13 +05:30
Thakee Nathees
e2d8533e27 Merge pull request #76 from ThakeeNathees/ci-workflow
CI-workflow implemented [1/2]
2021-06-16 03:28:30 +05:30
Thakee Nathees
945af460e0 CI-workflow implemented 2021-06-16 02:57:01 +05:30
Thakee Nathees
7ab4e55d6e
bin hex literals implemented (#72) 2021-06-16 00:24:30 +05:30
Ekin
8c51133cf1 Changed the else if notation to elsif, and the keyword count 2021-06-15 12:04:27 +03:00
Ekin
1f91d1ee81 changed the elif notation to else if 2021-06-15 11:27:19 +03:00
Alexander Patel
c58159b63d
Fix typos + rename variables (#73)
* 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>
2021-06-15 13:07:49 +05:30
Thakee Nathees
da5d5d6993
Merge pull request #71 from alexcpatel/op-oreq-xoreq
Operators |= and ^= implemented
2021-06-15 10:25:27 +05:30
Alexander Patel
ae4d2971c1 operator oreq and xoreq implemented 2021-06-14 21:36:10 -07:00
Thakee Nathees
ba66b04f3f
Merge pull request #69 from ThakeeNathees/op-andeq
Operator &= implemented
2021-06-14 21:57:21 +05:30
Thakee Nathees
72e7522c12 operator andeq implemented 2021-06-14 21:50:07 +05:30
Thakee Nathees
1ea9e4c5c7
Merge pull request #67 from ThakeeNathees/import-name-bug
import name bind bug fix
2021-06-14 10:16:17 +05:30
Thakee Nathees
558241a77b import name bind bug fix
stack curreption (due to stack missing parameters)
fixed, and some assertion macros added.
2021-06-14 09:55:18 +05:30
Thakee Nathees
848e4c338b
Merge pull request #66 from xSavitar/typo-cleanup-pocketlang.h
Cleanup some typos from the `include/pocketlang.h` header file
2021-06-14 00:42:16 +05:30
Derick Alangi
f1ac31953a Cleanup some typos from the include/pocketlang.h header file 2021-06-13 19:22:57 +01:00
Thakee Nathees
e90763c878 Merge pull request #65 from xSavitar/attr-range-start-end
Add support for `.start` and `.end` attributes on Range objects
2021-06-13 22:30:16 +05:30
Derick Alangi
ece87384ab Add support for .start and .end attributes on Range objects
This is an attempt to implement `.start` and `.end` on range objects
to fix issue #60.
2021-06-13 17:30:22 +01:00
Thakee Nathees
d7f7c21081
Merge pull request #62 from ThakeeNathees/tco
Tail call optimization implemented
2021-06-13 21:58:36 +05:30
Thakee Nathees
6992f54ef3 Tail call optimization implemented 2021-06-13 21:57:54 +05:30
Derick Alangi
22be6af376 Add support for bitwise XOR, LSHIFT and RSHIFT operators (#63)
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.
2021-06-13 20:27:48 +05:30
Thakee Nathees
9b2d28ef45 docs update after lang.disas 2021-06-13 11:03:18 +05:30
Derick Alangi
2707c1eec3
Fix #54: Add bitwise OR operator and make it available in PKVM (#59)
* 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
2021-06-13 09:43:05 +05:30
Thakee Nathees
04bc61e93d
Merge pull request #61 from ThakeeNathees/disas
Disassembler public api for debugging.
2021-06-12 16:40:56 +05:30
Thakee Nathees
17df5eb1e4 disassemble implemented 2021-06-12 16:34:10 +05:30
Thakee Nathees
473daa4716
Merge pull request #58 from xSavitar/cos-and-tan
Fix #56: Implement the `cos()` and `tan()` math functions
2021-06-11 23:00:02 +05:30
Derick Alangi
15716de9ce Fix #56: Implement the cos() and tan() math functions
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 ]
2021-06-11 18:14:20 +01:00
Thakee Nathees
749456e215 some (minor) code cleanups 2021-06-11 13:16:55 +05:30
Thakee Nathees
4bf045bcac
Merge pull request #52 from ThakeeNathees/authors-file-created
created an AUTHORS file.
2021-06-11 01:15:14 +05:30
Thakee Nathees
4d2fc474f9 created an AUTHORS file. 2021-06-11 01:14:14 +05:30
Thakee Nathees
484aa5d88f
Merge pull request #51 from ThakeeNathees/core-attrib
Core attributes refactored and added tests
2021-06-10 23:55:05 +05:30
Thakee Nathees
9fdab23a94 core attributes refactored and added tests 2021-06-10 23:12:04 +05:30
Derick Alangi
3a7ffc7cf1
Cleanup more typos from cli/ source files (#50) 2021-06-10 07:53:16 +05:30
Derick Alangi
fd6d2412ee
Fix more typos in cli/common.h (#49) 2021-06-10 04:27:28 +05:30
Derick Alangi
04c333a15e
Set pointer to first byte of mem block when realloc()'d (#48)
* 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.
2021-06-10 04:10:24 +05:30
Thakee Nathees
49c1fec85f
REPL implementation. (#47) 2021-06-09 16:12:26 +05:30
Derick Alangi
1a60646e38
Fix minor typos, while reading codebase (#46)
* Fix minor typos, while reading codebase

* Fix typo in common.h comment

* Fix typo in src/common.h
2021-06-08 22:19:58 +05:30