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.
Documentation
Group Members
Summary
This pull request implements Read-Eval-Print Loop (REPL) and Command Line Interface (CLI) to the R-Python language.
cargo run --release
and the generated executable is inr-python-REPL/target/release
cargo run -- --exec path_to_r-python_file
or./r-python --exec path_to_r-python_file
. The cli outputs by default the environment before and after execution, since the 'print' statement was not yet available../r-python
and expects ';' as end character to every line provided to the program. This decision was used so that REPL supports multiline statements like 'IfThenElse'.cargo run -- -h
or./r-python -h
shows all available options to run.Functions
repl()
orcli()
depending on the arguments provided.pub fn repl( env: Option<Environment<EnvValue>>,env_type: Option<Environment<Type>>) -> io::Result<()>
pub fn cli(file_path: &String) -> io::Result<()>
REPL functions
fn repl_parse_expression(input: &str,current_env: &Environment<EnvValue>,current_env_type: &Environment<Type>) -> Result<String, String>
fn repl_parse_statements(input: &str, mut current_env: Environment<EnvValue>, mut current_env_type: Environment<Type>) -> Result<(Environment<EnvValue>, Environment<Type>), String>
Each function takes an input string, along with two environments: one for variable names and values (
Environment<EnvValue>
) and one for variable types (Environment<Type>
). Since only assignments modify the environment, only the second function arguments are mutable.The repl_parse_statement returns a tuple (Environment <EnvValue>, Environment<Type>), which is verified in tests.
Features
Inline rpython via CLI
Usage:
cargo run -- -c "10+10"
or./rpython -c "10+10"
Executes file and loads environment in REPL
Usage:
cargo run -- --exec path_to_rpython_file -i
or./rpython --exec path_to_rpython_file -i
Supports internal commands in REPL preceded by
!
:!exit
: Terminates the REPL session.!reset
: Resets the execution environment.!clear
: Clears the screen.!help
: Displays available commands.Tests
repl.rs
, which integrates both interpreter and type checker verifications.a=10
followed bya=True
will result in a type mismatch error.Other fixes
test_propagation_parsing_statements()
andcheck_assignment_error1()
have been modified to ensure that types are handled by the type checker (inference), rather than by the parser.