Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Writing Interpreter in Rust — Repl, Files, and Comments (Part 4)

Member-only storyPavel DurovFollowBetter Programming--ShareWe’re continuing our journey implementing our interpreter, Coconut.In this article, we will implement the Repl (Read-Eval-Print Loop), reorganise the project, and add file and comments support. It will be a collection of small changes that will extend the usability of our interpreter.If you haven’t already, I recommend checking out my previous article, Writing an Interpreter in Rust: Bytecode and Stack-Based VM (Part 3).REPL (Read-Eval-Print Loop) allows users to execute code and see the results immediately interactively.Not all interpreters have REPL, but having REPL allows them to prototype and test ideas and language features quickly.REPL is very handy, especially when I am not 100% familiar with the language interface.I have restructured the code, but nothing fundamentally changed from the last implementation. I just moved the code from the main to separate modules to have a clear separation of concerns.Here’s our src directory’s content:Our main.rs file is very simple:The main responsibility of main.rs is to get the program input, call the…----Better ProgrammingSoftware Engineer. Human. I write about techy stuff I find interesting. @pav3ldurovPavel DurovinBetter Programming--1VinitainBetter Programming--36Benoit RuizinBetter Programming--206Pavel DurovinBetter Programming--Amine Dirhoussi--4Bruce WeninCode.Art--2Chad Johnson--53Luis SoaresinDev Genius--Dotan Nahum--1Edouard Courty--7HelpStatusAboutCareersBlogPrivacyTermsText to speechTeams



This post first appeared on VedVyas Articles, please read the originial post: here

Share the post

Writing Interpreter in Rust — Repl, Files, and Comments (Part 4)

×

Subscribe to Vedvyas Articles

Get updates delivered right to your inbox!

Thank you for your subscription

×