Skip to content

token definitions #2

Description

@colin-kiegel

Tokens: I like it, that you are only storing references instead of strings. This is something that I tried to, but I postponed it. I think we would need some helper object to support mutability.

I was experimenting with something like this - but I decided it would be way too complex right now to implement a nice + safe interface for it: https://gist.github.com/colin-kiegel/735df3ddb40da853c923.

This is my current definition in lexer/token/mod.rs:

  • renamed Var to Expression
  • split Number to Integer vs. Floating without keeping the string
  • using owned String right now (idea to generalize later - see gist)
pub enum Token {
    _Eof,
    Text(String),
    BlockStart,
    ExpressionStart, // orig. Var
    BlockEnd,
    ExpressionEnd,
    Name(String),
    IntegerNumber(u64), // orig. Number
    FloatingNumber(f64), // orig. Number
    String(String),
    Operator(String),
    Punctuation(Punctuation),
    _InterpolationStart,
    _InterpolationEnd,
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions