Add runtime, REPL, and language features (conditionals, assignment, keywords)#6
Merged
Add runtime, REPL, and language features (conditionals, assignment, keywords)#6
Conversation
Added a Display implementation for the KeyValue struct to format key-value pairs in map literals, handling both quoted and unquoted keys. Refactored the Display implementation for the Expr enum to utilize the new KeyValue formatting, improving overall expression output consistency. Updated function call and map literal formatting for better readability.
Introduced a new `runtime` module to support the `flt` language, including core types such as `Value` and `Type`, as well as function definitions and signatures. This update lays the groundwork for runtime evaluation and function handling, enhancing the language's capabilities. Updated `lib.rs` to include the new module.
Refactored the FunctionDefinition struct to accept a string name using a generic type for improved flexibility. Introduced an `accepts` method to check if the function definition matches given arguments. Added convenience methods for creating Argument instances with built-in types (number, string, boolean). Updated tests to validate the new functionality.
Introduced a new FunctionCall struct to represent function calls in the AST, including positional and keyword arguments. Updated the expression parser to handle function calls, ensuring that positional arguments are processed before any keyword arguments. Refactored related parsing functions to accommodate the new structure and updated tests to validate the changes.
Introduced a new `Keyword` enum to represent reserved keywords in the language, including `if`, `else`, and `return`. Updated the `Expr` enum to include a `Keyword` variant and refactored the expression parser to handle keyword parsing. Implemented a new `parse_keyword` function to ensure proper recognition of keywords, including word-boundary checks. Added tests to validate keyword parsing functionality and updated the evaluator to handle keyword expressions appropriately.
Introduced the 'let' keyword to the Keyword enum and updated the expression and keyword parsers to recognize it. Added corresponding tests to ensure proper parsing functionality for the 'let' keyword in expressions and keywords, enhancing the language's capabilities.
Updated the `functions-and-pipe.md` documentation to explain the use of keyword arguments in function calls. Modified the `README.md` and `syntax.md` files to reflect these changes, ensuring clarity on the syntax and semantics of function calls with keyword arguments. Updated `runtime-and-limitations.md` to specify the current limitations regarding function calls with keyword arguments.
Introduced a new feature file for assignment scenarios, including tests for both 'let' and direct variable assignments. Updated the parser to handle assignments without the 'let' keyword, allowing for more flexible syntax. Enhanced the runtime trait to support evaluation of assignment statements, and modified related structures to accommodate these changes, ensuring comprehensive parsing and evaluation capabilities for variable assignments.
Enhanced the language by introducing `==` and `!=` as binary operators. Updated the parser to recognize these operators and modified the AST to include corresponding variants. Added tests to validate the functionality of equality and inequality expressions, ensuring proper evaluation and parsing behavior.
Introduced `<`, `>`, `<=`, and `>=` as binary operators in the language. Updated the parser and AST to recognize these operators, enhancing the expression evaluation capabilities. Added corresponding tests to validate the functionality of comparison expressions, ensuring accurate parsing and evaluation behavior.
Introduced a new `Expr` variant in the `Statement` enum to represent bare expressions as statements. Updated the parser to handle expression statements, allowing for direct parsing of expressions without the `let` keyword. Added feature tests to validate the parsing of number expressions and binary expressions with semicolons, ensuring correct output and behavior in the language.
…nce REPL functionality - Added `dirs-next` and `dirs-sys-next` packages for improved directory handling. - Updated `thiserror` dependency to version 2.0.9. - Introduced REPL history management in `flt.rs`, allowing users to save and load command history. - Modified feature tests to reflect changes in REPL command execution and output validation.
- Introduced a new `repl` module to handle Read-Eval-Print Loop functionality, including history management for user inputs. - Updated `lib.rs` to include the new `repl` module. - Refactored `flt.rs` to utilize the new REPL implementation, removing redundant code related to REPL history and execution. - Enhanced the `SimpleRuntime` to return evaluated values instead of a unit type for better usability in REPL context.
- Introduced a new `IfExpr` variant in the `Expr` enum to represent conditional expressions with optional else branches. - Updated the parser to handle the syntax for if expressions, allowing for both block and inline branches. - Enhanced the runtime to evaluate if expressions, returning the appropriate branch based on the condition. - Added tests to validate the parsing and evaluation of if expressions, ensuring correct behavior for various scenarios including conditions, branches, and error handling for non-boolean conditions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces a runtime layer, an interactive REPL, and several language features so the interpreter can evaluate expressions and run small programs.
Key changes
runtimemodule with core types (Value,SimpleRuntime) and function definitions; eval logic refactored to use it.replmodule and integration infltbinary for interactive evaluation.letbindings, and assignment.FunctionCallAST, keyword arguments, and enhancedFunctionDefinition/Argumentstructures.<,>,<=,>=) and equality/inequality (==,!=).ifexpressions.Commits (main..HEAD)
letkeyword supportMade with Cursor