Lexer.tokenize constructor
Lexer.tokenize(
- String content
Implementation
factory Lexer.tokenize(String content) {
final Lexer t = Lexer._(content);
int prev = t.curr;
while (!t.eof()) {
if (prev != t.curr) {
throw 'Unknown character in tokenizer on line ${t.line}, col ${t.col}. Cannot recover.';
}
switch (t.peek().lexeme) {
case '<':
t.lt();
case '>':
t.gt();
case '=':
t.eq();
case '~':
t.bitNot();
case '|':
t.bitOr();
case '&':
t.bitAnd();
case '[':
t.lbracket();
case ']':
t.rbracket();
case '(':
t.lparen();
case ')':
t.rparen();
case '{':
t.lcurly();
case '}':
t.rcurly();
case '*':
t.mult();
case '%':
t.mod();
case '/':
t.div();
case '+':
t.add();
case '-':
t.sub();
case ':':
t.colon();
case ';':
t.semicolon();
case '.':
t.dot();
case ',':
t.comma();
case '#':
t.hashtag();
case '^':
t.carrot();
case '"':
t.str(start: '"', end: '"');
case '\'':
t.str(start: '\'', end: '\'');
case '\t' || '\r' || ' ':
t.advance();
case '\n':
t.newline();
default:
t.raw();
}
prev = t.curr;
}
return t;
}