Commit Graph

189 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
e9dc8a7e32 cl-repl: hack together some temporary file loading, to aid in standard library development 2024-02-28 06:02:00 -06:00
862d81a9d4 cl-repl: Rename from cl-frontend.
Also disable escape code printing when debug assertions are off
2024-02-28 05:32:10 -06:00
048e41836a cl-frontend: Create a repline demo that collects definitions and usages of identifiers 2024-02-28 05:25:55 -06:00
78b8d87408 cl-frontend: Embrace the crossterm jank 2024-02-28 05:11:06 -06:00
e01c71f9a7 lexer: implement std::error:;Error for Error (whoops!) 2024-02-28 05:00:39 -06:00
3785045989 cl-frontend: fix strange newline behavior in REPL 2024-02-28 01:21:50 -06:00
67bb3d4ae3 parser: Note intent to switch to a Pratt parser 2024-02-27 23:35:41 -06:00
ca51a35f5c ast: Reduce the number of chained references to 65535 2024-02-27 23:33:20 -06:00
04320de9a8 parser: Make delim, sep, and rep const 2024-02-27 23:32:32 -06:00
325498ac8b ast: Add metadata attributes on Items
TODO: decide what other places attributes belong
2024-02-27 23:31:49 -06:00
9806e95247 ast_impl: Forgot to impl From<Expr> for StmtKind (whoops!) 2024-02-27 22:49:14 -06:00
5484d96e7d ast: Add the "Self" type in preparation for cl-typeck 2024-02-27 22:48:24 -06:00
e3f08ac013 parser: Overhaul the semi-functional Parser::{delimited, separated, repeated} methods into real higher-order functions 2024-02-27 22:46:36 -06:00
978f5e40c1 conlang: Introduce type-alias/typedef syntax
`type T;` | `type T = U;`
2024-02-27 20:49:02 -06:00
0c1b3bfe39 ast: Do not promise PartialOrd/Ord (breaking change) 2024-02-27 20:41:15 -06:00
87c8d43d11 grammar.ebnf: Fix ModuleKind grammar 2024-02-26 16:19:21 -06:00
c36eec216a parser: Allow StmtKind to parse itself (whoops!) 2024-02-26 16:03:18 -06:00
66deb41301 grammar.ebnf: Sync changes with AST 2024-02-26 16:02:36 -06:00
9bde97942c ast: Enum variants can have no data, or have an associated integer. 2024-02-26 15:59:15 -06:00
bb3eecd190 interpreter: Allow statements to choose their own return value (reduces code duplication) 2024-02-26 15:53:45 -06:00
ffa313eea8 ast: Allow type specifier in let statement 2024-02-26 15:49:55 -06:00
490d320633 parser: allow end of input in binary and indexing operations.
This improves robustness and correctness of implementation.
2024-02-26 15:37:07 -06:00
13995259aa parser: use different wording when the expected value was an operator vs an expression 2024-02-26 15:35:07 -06:00
ae76df9c83 interpreter: Fix bug where a break instruction would instead signal a return from subroutine 2024-02-26 15:33:47 -06:00
1bfeeb1755 interpreter: shrink integers to pointer-size in temp type implementation, for speed 2024-02-26 15:32:49 -06:00
59b73f314a ast: Remove unary hash operator to reserve the symbol for use in attribute parsing 2024-02-26 15:30:50 -06:00
cdf283064e ast: Improve ExprKind descriptions 2024-02-26 15:25:49 -06:00
2095bfec80 Lexer tests: import formatting 2024-02-26 15:21:14 -06:00
3f8c2b6267 ast: remove done TODOs 2024-02-26 15:20:33 -06:00
77db95791a cl-frontend: Improve the line-editing capabilities in REPL mode.
- Note: This adds a dependency on Crossterm, to set the terminal into raw mode. This could be eliminated by linking the libraries Crossterm uses directly... Or I could embrace Crossterm, and use it for all escape sequences in the terminal, instead of assuming DEC VT500 compatibility.
2024-02-26 15:15:34 -06:00
5e4e70a72e fibonacci.cl: Move the input number out of the string 2024-02-26 15:11:28 -06:00
b8d70d3393 Cleanup: Break Loc out into a common module, rename WhileParsing => Parsing 2024-01-23 01:51:00 -06:00
c4a32895df conlang 0.3.0: Total grammar overhaul
- Rewrote the grammar
- Rewrote the AST
- Rewrote the Parser
- Removed pretty printer (now handled by ast::ast_impl::Pretty, a Writer wrapper)
- Added items, and new keywords to go with them
  - Syntax is ~maybe temporary, based on Rust syntax
2024-01-21 05:32:18 -06:00
5e2f365f45 conlang: deprecate the AST 2024-01-21 01:34:40 -06:00
6bb2f3774f interpreter: Add regression tests for operators and precedence 2024-01-09 23:52:48 -06:00
d9d8c70556 interpreter: revert storing environments in functions
This change broke recursion entirely
2024-01-09 22:42:15 -06:00
99ade72756 interpreter: fix variable resolution and assignment 2024-01-09 22:39:58 -06:00
56f0550829 resolver: remove unused, deprecated stack functions 2024-01-09 21:04:28 -06:00
15d7565703 token: Add new keywords in preparation for grammar update 2024-01-06 14:32:56 -06:00
77f7623041 resolver: Improve block scoping with a scope guard 2024-01-06 14:32:06 -06:00
53f9ec2356 interpreter: use an explicit stack, rather than a cons list
Also gets rid of some dead code
2024-01-05 22:47:16 -06:00
54bae6a9c5 cl-frontend: update doc comment for new behavior 2024-01-05 21:49:05 -06:00
8d03b8a8eb ast: update todo 2024-01-05 21:47:36 -06:00
d387e4dfd7 interpreter: rewrite interpreter
- Remove interpreter struct
- Replace with `Interpret` trait
- This separates concerns dramatically! Yay!
- Implement block scoping via `Frame` abstraction
  - TODO: is this the right abstraction?
  - TODO: Modules??
  - TODO: What environment should be passed into a function call?
ast:
- rename Name.name to Name.symbol (name.name.name.name.name.name.name is very readable, yes yes)
2024-01-05 17:48:19 -06:00
9eafae0757 resolver: Whoops! Commit early WIP resolver. 2024-01-05 17:44: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
9b7cf9c017 lexer: Add :: and #! tokens 2023-10-30 19:17:03 -05:00
c3e02d21ad sample-code: Add some sample Conlang programs :D 2023-10-30 00:23:43 -05:00
c1c834701a parser: Mockup type-expression syntax
- Allow `name: Type` notation for parameters
- Allow `fn x() -> RetVal` notation for return values
- TODO: Create syntax for type-expressions/paths
2023-10-30 00:07:27 -05:00