llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.4k stars 12.15k forks source link

[ELF] A new Lexer for Linker Script #99920

Open hongyu-dev opened 4 months ago

hongyu-dev commented 4 months ago

We want to replace current lexer with a stateful one to report more errors and get rid of many hacks in current lexer such as (ScriptLexer::maybeSplitExpr is removed in https://github.com/llvm/llvm-project/issues/93947). The list of items is the plan to update lexer gradually.

llvmbot commented 4 months ago

@llvm/issue-subscribers-lld-elf

Author: Hongyu Chen (yugier)

- [x] ~~delete peek2~~ https://github.com/llvm/llvm-project/pull/99790 - [ ] delete consumeLabel - [ ] add `struct Token {StringRef str; TokenKind kind;}; vector<StringRef> tokens;` => `vector<Token> token;` change next/peek to return Token - [ ] add a consume overload to accept Token. The existing consume(StringRef) is be a special case that expects identifier/quoted_string. - [ ] introduce state to remove some unquote and https://github.com/llvm/llvm-project/pull/84130 hack - [ ] introduce state to replace inExpr - [ ] fully stateful lexer; replace eager tokenize with on-demand lexing;with on-demand lexing, replace getColumnNumber (from Token) with Lexer::getColumnNumber - [ ] replace mbs with an include stack (INCLUDE); replace getCurrentMB() We want to replace current lexer with a stateful one to report more errors and get rid of many hacks in current lexer such as `ScriptLexer::maybeSplitExpr`. The list of items is the plan to update lexer gradually.