90 Commits

Author SHA1 Message Date
80d9b36901 Add test for stringstore 2022-02-11 19:08:08 +01:00
70c9d073f9 Add a few more comments 2022-02-11 18:34:46 +01:00
5f720ad7c3 Update README 2022-02-11 16:07:12 +01:00
748bd10dd9 Fix runtime error msg 2022-02-11 16:05:05 +01:00
1ade6cae50 Mention vsc extension 2022-02-11 13:31:48 +01:00
3e4ed82dc4 Update README 2022-02-11 13:04:45 +01:00
e5edc6b2ba Fix UB non top-level functions 2022-02-11 13:00:41 +01:00
f4286db21d Remove anyhow dependency 2022-02-11 12:36:36 +01:00
3892ea46e0 Update examples 2022-02-11 01:19:45 +01:00
8b7ed96e15 Update nice_panic macro 2022-02-11 01:19:34 +01:00
67b07dfd72 Fix typo 2022-02-11 01:01:31 +01:00
6c0867143b Add toc to README 2022-02-11 00:12:36 +01:00
abefe32300 Update README 2022-02-10 23:02:40 +01:00
742d6706b0 Array values are now pass-by-reference 2022-02-10 21:27:05 +01:00
3806a61756 Allow endless loops with no condition 2022-02-10 20:36:26 +01:00
2880ba81ab Implement break & continue
- Fix return propagation inside loops
2022-02-10 13:13:15 +01:00
4e92a416ed Improve CLI
- Remove unused flags
- Show more helpful error messages
2022-02-10 12:58:09 +01:00
c1bee69fa6 Simplify general program tests 2022-02-10 12:24:20 +01:00
f2331d7de9 Add general test for functions as example 2022-02-10 12:19:01 +01:00
c4d2f89d35 Fix function args 2022-02-10 12:13:30 +01:00
ab059ce18c Add recursive fibonacci as test 2022-02-10 01:32:07 +01:00
aeedfb4ef2 Implement functions
- Implement function declaration and call
- Change the precalculated variable stack positions to contain the
  offset from the end instead of the absolute position. This is
  important for passing fun args on the stack
- Add the ability to offset the stackframes. This is used to delete the
  stack where the fun args have been stored before the block executes
- Implement exit type for blocks in interpreter. This is used to get the
  return values and propagate them where needed
- Add recursive fibonacci examples
2022-02-10 01:26:11 +01:00
f0c2bd8dde Remove panics from interpreter, worse performance
- Replaced the interpreters panics with actual errors and results
- Added a few extra checks for arrays and div-by-zero
- These changes significantly reduced runtime performance, even without
  the extra checks
2022-02-09 18:18:21 +01:00
421fbbc873 Update euler5 example 2022-02-09 17:12:47 +01:00
383da4ae05 Rewrite declaration as statement instead of binop
- Declarations are now separate statements
- Generate unknown var errors when vars are not declared
- Replace Peekable by new custom PutBackIter type that allows for
  unlimited putback and therefore look-ahead
2022-02-09 16:54:06 +01:00
7ea5f67f9c Cleaner unop parsing 2022-02-09 14:23:24 +01:00
235eb460dc Replace panics with errors in parser 2022-02-09 13:49:14 +01:00
2312deec5b Small refactoring for parser 2022-02-09 01:13:22 +01:00
948d41fb45 Update lexer tests 2022-02-09 00:20:56 +01:00
fdef796440 Update token macros 2022-02-08 23:26:23 +01:00
926bdeb2dc Refactor lexer match loop 2022-02-08 22:54:41 +01:00
726dd62794 Big token refactoring
- Extract keywords, literals and combo tokens into separate sub-enums
- Add a macro for quickly generating all tokens including the sub-enum
  tokens. This also takes less chars to write
2022-02-08 18:56:17 +01:00
c723b1c2cb Rename var in parser 2022-02-06 15:31:41 +01:00
e7b67d85a9 Add game of life example 2022-02-05 11:53:01 +01:00
cf2e5348bb Implement arrays 2022-02-04 18:48:45 +01:00
8b67c4d59c Implement block scopes (code inside braces)
- Putting code in between braces will create a new scope
2022-02-04 17:30:23 +01:00
cbf31fa513 Implement simple AST optimizer
- Precalculate operations only containing literals
2022-02-04 17:06:38 +01:00
56665af233 Update examples 2022-02-04 14:25:25 +01:00
22634af554 Precalculate stack positions for variables
- Parser calculates positions for the variables
- This removes the lookup time during runtime
- Consistent high performance
2022-02-04 14:25:25 +01:00
d4c6f3d5dc Implement string interning 2022-02-04 14:25:23 +01:00
4dbc3adfd5 Refactor Ast to ScopedBlock 2022-02-04 14:24:03 +01:00
cbea567d65 Implement vec based scopes
- Replaced vartable hashmap with vec
- Use linear search in reverse to find the variables by name
- This is really fast with a small number of variables but tanks fast
  with more vars due to O(n) lookup times
- Implemented scopes by dropping all elements from the vartable at the
  end of a scope
2022-02-04 14:24:00 +01:00
e4977da546 Use euler examples as tests 2022-02-04 12:45:34 +01:00
588b3b5b2c Autoformat 2022-02-03 17:38:25 +01:00
f6152670aa Small refactor for lexer 2022-02-03 17:25:55 +01:00
c2b9ee71b8 Add project euler example 5 2022-02-03 16:16:38 +01:00
f8e5bd7423 Add comments to parser 2022-02-03 16:01:33 +01:00
d7001a5c52 Refactor, Comments, Bugfix for lexer
- Small refactoring in the lexer
- Added some more comments to the lexer
- Fixed endless loop when encountering comment in last line
2022-02-03 00:44:48 +01:00
bc68d9fa49 Add Result + Err to lexer 2022-02-02 21:59:46 +01:00
264d8f92f4 Update README 2022-02-02 19:40:10 +01:00