Commit Graph

19 Commits

Author SHA1 Message Date
5eb6411d53 interpreter: BuiltIn overhaul!
- Allowed builtins to self-describe
- Broke builtins into their own module
  - Created a macro to work with BuiltIns easier
  - Uses macro 2.0 syntax, so it requires passing in ALL externally referenced identifiers
    - Luckily, this is already a requirement of good, readable macro definitions!
- As a temporary hack, turn overloadable operators into function calls
  - This is kind of pointless at the moment, since there can only be one definition of a function per name (no ADL/function overloading/traits/type namespaces yet!)
  - This is also pretty slow, but benchmarking shows it's not as slow as I thought (~400x slower in release mode than a native Rust implementation when running `fib.cl`/`fib.rs`. Totally unacceptable for most work, but this is a tree walk interpreter.)
  - TODO: Remove this when desugaring from operators to function calls is implemented
2024-02-29 16:48:09 -06:00
79fda16788 cl 0.0.2: MAJOR ERGONOMIC BOOST
Broke frontend into its own library, "cl-frontend"
- Frontend is pretty :D
- Included sample fibonacci implementation

Deprecated conlang::ast::Visitor in favor of bespoke traits
- Rust traits are super cool.
- The Interpreter is currently undergoing a major rewrite

Added preliminary type-path support to the parser
- Currently incomplete: type paths must end in Never..?

Pretty printer is now even prettier
- conlang::ast now exports all relevant AST nodes, since there are no namespace collisions any more
2024-01-04 02:18:09 -06:00
374017d5e3 examples/interpret: Call main if loading from file 2023-10-29 23:48:38 -05:00
f3306e7ba4 examples/format: Rename from parse_input 2023-10-29 21:10:09 -05:00
9a6eb6b0f1 examples/interpret: Improve the repl's UX somewhat 2023-10-29 01:14:36 -05:00
f3aad36f32 examples/interpret: Multi-line input support 2023-10-26 22:33:31 -05:00
e22b1b7bfd examples/interpret: Misc cleanup 2023-10-26 22:13:48 -05:00
aead97e357 interpreter: Implement ranges and for loops 2023-10-26 21:51:18 -05:00
15a3d265df interpreter: Prototype interpreter
TODO: Type-checking, floats, variables & scope
TODO Later: A bytecode interpreter
2023-10-26 14:48:44 -05:00
5c4c8bcb80 lexer: Consume invalid characters 2023-10-25 19:28:54 -05:00
0e917837c0 identify_tokens: Use Display on token Data 2023-10-23 21:02:09 -05:00
b5abd2bff1 Lexer rewrite:
- Scan the input string *linearly*, without backtracking
  - Peek at most one character (unicode code-point) ahead
- Store data (unescaped string literals and chars, identifiers, integers, floats) inside Token
  - This unfortunately makes tokens non-Copy
- Refactor Parser to accommodate these changes
  - On the bright side, Parser no longer needs a reference to the text!
- Write a new set of lexer tests
  - TODO: write a new set of token tests using tokendata

Every day, we get closer to parsing `dummy.cl`!
2023-10-22 18:28:20 -05:00
feb5cc5dd0 AST: Refactor binary operations, fix Walk trait
- Unified math operations into a single self-referential enum
- Walk now visits the children of a node, rather than the node itself
  - The old behavior was super confusing, and led to numerous stack overflows.
2023-10-21 12:24:52 -05:00
a26a01fc17 constr: Misuse iterators to parse tokens 2023-10-20 15:33:02 -05:00
b707bcef81 examples: Add parse_input REPL for fun! 2023-10-16 22:51:59 -05:00
1f0725d2c8 examples/identify_tokens.rs: Overhaul user experience 2023-10-16 22:26:32 -05:00
545483dae6 token: Add Display impl for Type
This improves readability in identify_tokens
2023-09-28 01:34:56 -05:00
097e2c4f11 conlang: Rename literals; split, compose, and document Rules
- Renamed literal Types to reflect their literal nature
  - This allows for consistent naming across future non-literal Types
- Complicated lexer Rules have been split into composable sub-rules,
  and moved into the Rule struct.
  - This improves modularity, and allows sharing of sub-rules across rules.
- Documented each lexer rule with (at least) a one-line blurb
  describing its function
2023-09-27 18:13:01 -05:00
46e72e4889 conlang: add toy program to interact with the tokenizer 2023-09-25 18:06:03 -05:00