dherman / esprit

A JavaScript parser written in Rust

Home Page:https://esprit.surge.sh

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

make saving raw source of literals optional

dherman opened this issue · comments

Make StringLiteral and NumberLiteral parameterized types to allow making it configurable whether to save the raw source. Probably something like

struct StringLiteral<T: Display, StringLiteralParser> {
    pub source: T,
    pub value: String
}

where StringLiteralParser is a custom trait that modularizes the parsing logic for string literals. This lets you construct a parser at compile time with the literal parsing logic you want.