Commit Graph

33 Commits

Author SHA1 Message Date
Victor Akpan
9635c223b1
Added new Math functions (#160)
* Added log and round functions to math module

* Added log and round functions to math module

* Added a few math functions

* Static checks

* Maybe this will fix linux

* Fixed errors with styles and tests
2022-03-30 23:14:01 +05:30
Thakee Nathees
89f8b77bb6
imported scripts were initialized (#158) 2021-07-02 21:32:30 +05:30
Thakee Nathees
6ad5dfe9f7
native api function improvements (#153) 2021-06-30 12:09:17 +05:30
Derick Alangi
f1bbafaa28
Introduce support for substring function - str_sub() (#152)
This function takes in 3 arguments: the string, the position and the
length (of the substring). As a quick example, a call to the function

`str_sub('c programming', 3, 11)`

will return the string 'programming' as the substring to the string
that is provisioned to the function call.
2021-06-29 18:18:41 +05:30
Derick Alangi
e74e209b7c
Add support for hyperbolic & arc trigonometric functions (#126)
Functions added are: `sinh(x)`, `cosh(x)`, `tanh(x)`, `asin(x)`,
`acos(x)`, and `atan(x)`.

In addition, basic tests added in core.pk for these functions.
2021-06-26 18:13:29 +05:30
Jordan Ellis Coppard
39c5fba9d9
add elem in map (#121) 2021-06-23 21:03:26 +05:30
Tiago Cavalcante Trindade
6d434db0cb
Add <<= and >>= operators (#119)
* Add <<= and >>=
2021-06-23 19:54:20 +05:30
Thakee Nathees
64bf27674a
in test (ie. elem in container) implemented. (#117)
in keyword will invoke varContains(), the for now the list contains
implemented.
2021-06-23 15:51:59 +05:30
Dmitry Guzeev
dbdb43b8ed
Number literal parsing (#106)
* Implement proper number literal parsing

- Scientific notation support
- Correct error handling in cases of invalid digits present in binary or
  hex literals (0b123, 0x013FK).

* Fix style linter issues

* Support +/- in number literal exponent, add tests

- Add tests for scientific notation number literal parsing
- Add support for +/- in scientific notation exponents
2021-06-23 10:30:06 +05:30
Tiago Cavalcante Trindade
792d08eae7
Move fiber functions to module Fiber (#113) 2021-06-23 09:48:15 +05:30
Tiago Cavalcante Trindade
fe45ba3485
Numeric literal starts with decimal point implementation (Fix: #97) 2021-06-23 00:51:19 +05:30
Takashi Idobe
c0f00f6cae
add modeq implementation (#108)
* add modeq implementation

* code review feedback
2021-06-22 17:49:52 +05:30
Thakee Nathees
41ed7dd991 class implemented 2021-06-21 12:13:37 +05:30
Thakee Nathees
733f006b03
Merge pull request #95 from ThakeeNathees/pk_doc
[WIP] Docstring extracted and `help()` function added
2021-06-18 15:45:19 +05:30
Thakee Nathees
e1628f1a73 docstring for pocket functions implemented 2021-06-18 14:52:24 +05:30
Derick Alangi
fbcf6fc1a1 use PEEK() so we don't loose reference 2021-06-17 13:43:09 +01:00
Derick Alangi
ac1d825f13 Add support for bitwise NOT (~) operator to pocketlang
Like other bitwise operators like: &, ^, >>, << etc, add support
for the bitwise NOT (~) operator.
2021-06-17 13:40:56 +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
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
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
Alexander Patel
ae4d2971c1 operator oreq and xoreq implemented 2021-06-14 21:36:10 -07:00
Thakee Nathees
72e7522c12 operator andeq implemented 2021-06-14 21:50:07 +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
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
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
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
17df5eb1e4 disassemble implemented 2021-06-12 16:34:10 +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
9fdab23a94 core attributes refactored and added tests 2021-06-10 23:12:04 +05:30