8000 Wrap token iterators in an abstraction · Issue #100 · uliwitness/Stacksmith · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Wrap token iterators in an abstraction #100
Open
@uliwitness

Description

@uliwitness

Right now, we have free GoNextToken()/GoPrevToken() functions and lots of if( tokenItty != tokens.end() ) checks in the parser.

If it wouldn't add much code/overhead, could we maybe change the parser to not directly use std::vector iterators and instead wrap them in an object that performs these checks and (instead of crashing) would just throw when someone tries to advance past the end. Similarly, it should provide a dummy token that doesn't match any other token type or identifier type when de-referenced while we're at tokens.end().

The idea behind this is to make the parser code easier to follow by being able to omit more code.

Of course this would mean we'd have to religiously follow RAII while parsing so we don't leak resources (Can we use std::unique_ptrs?).

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreterHammer programming language: Parser, tokenizer, interpreter.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0