Skip to content

Chain of Responsability for lexer architecture? #1192

Open
@Schyerke

Description

@Schyerke

Hello, recently I created my own interpreter following the books' architecture for everything, lexer included.
After some time I realized maybe the approach the author took was against the open-closed principle, especially using an enum for rappresenting the tokens and a switch statement for lexing it, so the lexer class could be changed whether the enum gets changed as well.

So I was wondering if the author's approach on the lexer architecture was the best, and maybe applying the chain of responsability would have been a better approach in order to keep things consistent and not breaking the open-closed principle.

@munificent I would like to have your opinion on this matter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions