PacktPublishing / Learn-LLVM-12

Learn LLVM 12, published by Packt
MIT License
474 stars 103 forks source link

Why `CASE('(', Token::Token::l_paren);` is used ? Is the code repeated? #28

Open XDUqinian opened 11 months ago

XDUqinian commented 11 months ago
#define CASE(ch, tok) \
case ch: formToken(token, BufferPtr + 1, tok); break
CASE('+', Token::plus);
CASE('-', Token::minus);
CASE('*', Token::star);
CASE('/', Token::slash);
CASE('(', Token::Token::l_paren);
CASE(')', Token::Token::r_paren);
CASE(':', Token::Token::colon);
CASE(',', Token::Token::comma);
#undef CASE

This is the code in the Lexer::next function in the lexer.cpp in Chapter 03. I want to know why Token::Token::op is used, is the code repeated?