Commit Graph

31 Commits

Author SHA1 Message Date
Sameer Rahmani 3f554445d8 Fix some the linters problems reported by the golang-cli 2021-01-22 20:37:44 +00:00
Sameer Rahmani 09a6d92c08 Replace Tre/False types with a Bool type 2021-01-14 18:17:38 +00:00
Sameer Rahmani f2241cc31f [Bootstrap] Add E0003 and the MakeRuntimeError to cover for MakeError 2021-01-10 18:30:48 +00:00
Sameer Rahmani c2d4273319 [Bootstrap] Fix the order and location on the traceback
In order to fix this issue I had to make many minor tweaks
including reordering the traceback and the way we pass down
nodes.
2021-01-07 19:45:07 +00:00
Sameer Rahmani 9be27c124a [Bootstrap] Use Serene itself to load and run the main function
This commit consist a series of fixes to make the reach the main
goal of the commit:

* Fix the 'MakeNodeFromExprs' behavior so it returns a pointer
  to a node and if the number of input exprs is zero then nil.

* Fix all the eval loop to return immediately in case of any error
  duh!

* Add a `errtype` field to `Error` with an `ErrType` enum type
  that indicates the type of the error, the type being syntax,
  semantic and runtime error at the moment.

* Rename some of the Error functions to match the error type. For
  Exapmle `MakeSyntaxError` and `MakeSemanticError`
2021-01-02 21:04:35 +00:00
Sameer Rahmani e895377811 [Bootstrap] Update the call stack to container the caller and add a line index to the parser 2021-01-01 19:13:49 +00:00
Sameer Rahmani 9d106d4278 Record the caller details in the stack frame 2020-12-30 17:50:00 +00:00
Sameer Rahmani 8eef7d76ca [Bootstrap] Add minor comment to clearify 'instructions' 2020-12-25 23:20:15 +00:00
Sameer Rahmani 1447f8ac45 [Bootstrap] Implement a call stack to keep track of function calls
Add `ICallStack` as the interface to the call stack with a simple
FIFO implementation that tracks the recursive calls as well.
2020-12-25 22:03:21 +00:00
Sameer Rahmani cb96e15b9c [Bootstrap]: Add some comment explaining the tree rewriting approach 2020-12-25 01:40:13 +00:00
Sameer Rahmani 0b56906474 [Bootstra] Rethink the eval loop to rewrite evaluation tree
Implement a new algorithm to eliminate TCO while preventing
premature execution exit by rewriting the evaluation tree and
replacing old nodes with new set of forms, for example the result of
some old form's evaluation, a body of a function or anything in
that nature. Couple the new forms with a possible new execution scope.
2020-12-25 01:18:54 +00:00
Sameer Rahmani 699483e249 Add support for printable strings and 'pr', 'prn' functionalities.
Add 'pr' and 'prn' functions to print out the representation of an
string and 'print' and 'println' to print out the string.
2020-12-24 16:28:12 +00:00
Sameer Rahmani 3f6b9b6e29 [Bootstrap] Add the support for keywords
Both normal and ns qualified keywords with support for ns aliased
keywords.
2020-12-22 23:54:21 +00:00
Sameer Rahmani 1d66c2a56e Add support for very basic string implementation 2020-12-16 22:40:59 +00:00
Sameer Rahmani 578a771fa3 Improve the documentation of the bootstrap 2020-12-16 18:57:54 +00:00
Sameer Rahmani 42058568c7 Add support for native function, multi ns require fn and 'builtins'
* Implemented Native function as IExprs so we can refer to them
  like any other function. Checkout `NativeFunction`.

* `require` has been implemented as a native functions which
  accepts one or more namespace descriptions and load them.
  A namespace description is either a symbol with the ns name
  or an `IColl` in the following form `(some.ns.name alias).

* A hashmap of strings to native functions has been added to the Runtime
  which is used to resolve builtin functions.
2020-12-15 19:08:51 +00:00
Sameer Rahmani 21d15787c9 Add support for loading namespaces via 'require' (symbol only)
At this stage we only supports requiring a namespace via it's name
and only one namespace like `(require 'blah.blah)`. But the support
for name aliases and requiring more namespaces at once would be
easy enough.
2020-12-12 20:33:53 +00:00
Sameer Rahmani 31a4cfb765 Add support for macros via defmacro
Added the support for normal macro (in compare to reader macros and
other types) expansion with out quasiquote support. The quasiquote
will be added as a recursive macro itself.
2020-12-04 21:08:48 +00:00
Sameer Rahmani 211e977430 Add 'quote' special form 2020-11-26 12:03:46 +00:00
Sameer Rahmani 688d169286 Add the `let` special form alongside with locatable errors
Add the `let` sform not in the triditional way. In our case
the let scope is available to the bindings. Similar to clojure's let
and let* in triditional sense.

Also add the function `MakeErrorFor` which gets an extra arg, an
`IExpr` and returns an error with the location of that expression.
2020-11-25 19:19:48 +00:00
Sameer Rahmani d86b47c283 Change the `if` special form to use TCO
the bodies of `if` might be utilized for tail call recursion so we
need to run the body inside the TCO loop
2020-11-25 16:41:11 +00:00
Sameer Rahmani 0ef38cd9bd Add the 'do' special form 2020-11-25 16:18:38 +00:00
Sameer Rahmani c2326ae546 Add support for the IF special form 2020-11-25 13:15:19 +00:00
Sameer Rahmani d92150f0c3 Add IError interface to represent system errors 2020-11-24 18:27:48 +00:00
Sameer Rahmani a2725ba412 Add some documentation for the core package 2020-11-20 16:43:07 +00:00
Sameer Rahmani 468b446a4f Enable repl history 2020-11-20 12:33:15 +00:00
Sameer Rahmani 28d7be6efd Create the Block struct to accommodate function bodies 2020-11-19 22:17:50 +00:00
Sameer Rahmani 680017f0ce Add the Def, and Fn special forms 2020-11-19 19:14:06 +00:00
Sameer Rahmani ad37f02742 Restructure the source tree to get around circular dep issue 2020-11-15 22:16:48 +00:00
Sameer Rahmani cba74e29af Add the support for special forms 2020-11-15 21:38:09 +00:00
Sameer Rahmani 95ec031ce6 Add a very basic eval function for symbols 2020-11-15 19:30:07 +00:00