Rydgel / monkey-rust

An interpreter for the Monkey programming language written in Rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question

B-Teague opened this issue · comments

Curious, why is the lexer using array of bytes &[u8] instead of string slice &str? Was there a specific design reason for this?

I'm looking to use monkey-rust as a starting template for a custom language, but was wondering if I should keep &[u8] or just use &str for simplicity.

Found answer to my own question. &str are utf-8 which can be 1,2,3, or 4 &[u8] long. If we know the source code is all ASCII characters, then it is more efficient to parse using &[u8]