[lld] [ELF] Added `struct Token` and changed `next()` and `peek()` to return Token (PR #100180)

Hongyu Chen via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 23 16:53:37 PDT 2024


================
@@ -0,0 +1,177 @@
+//===- ScriptLexer.h --------------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the nums for LinkerScript lexer
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLD_ELF_SCRIPT_TOKENIZER_H
+#define LLD_ELF_SCRIPT_TOKENIZER_H
+
+namespace lld {
+namespace elf {
+enum class Tok {
+  Entry,
+
+  // Commands Files
+  Include,
+  Input,
+  Group,
+  Memory,
+  Output,
+  SearchDir,
+  Startup,
+
+  Insert,
+  After,
+
+  // Commands for object file formats
+  OutputFormat,
+  Target,
+
+  // Other linker script commands
+  Assert,
+  Constant,
+  Extern,
+  // FORCE_COMMON_ALLOCATION
+  // INHIBIT_COMMON_ALLOCATION
+  OutputArch,
+  Nocrossrefs,
+  NocrossrefsTo,
+
+  // Assignment
+  Provide,
+  Hidden,
+  ProvideHidden,
+
+  Sections,
+  Before,
+
+  // Input Section
+  ExcludeFile,
+  Keep,
+  InputSectionFlags,
+
+  // Read section
+  Overlay,
+  Noload,
+  Copy,
+  Info,
+
+  // Output Section
+  OverwriteSections,
+  Subalign,
+  OnlyIfRO,
+  OnlyIfRW,
+  Fill,
+  Sort,
+
+  // Builtin Functions
+  Absolute,
+  Addr,
+  Align,
+  Alignof,
+  // BLOCK, // synonym for ALIGN for compatibility with older linker script
+  DataSegmentAlign,
+  DataSegmentEnd,
+  DataSegmentRelroEnd,
+  Defined,
+  Length,
+  Loadaddr,
+
+  Log2ceil,
+  Max,
+  Min,
+  Origin,
+  SegmentStart,
+  // NEXT, // This function is closely related to ALIGN(exp); unless you use the
+  // MEMORY command to define discontinuous memory for the output file, the two
+  // functions are equivalent.
+  Sizeof,
+  SizeofHeaders,
+
+  // PHDRS Command
+  Filehdr,
+  Phdrs,
+  At,
+  Flags,
+
+  // Version Command
+  Version,
+
+  RegionAlias,
+  AsNeeded,
+  Constructors,
+
+  // Symbolic Constants
+  Maxpagesize,
+  Commonpagesize,
+
+  Error,
+  Eof,
+
+  Identifier,
+  Hexdecimal,  // 0x
+  HexdecimalH, // end with H/h
+  Decimal,
+  DecimalK, // end with K/k
+  DecimalM, // end with M/m
+
+  // Symbol tokens
+  CurlyBegin,   // {
----------------
yugier wrote:

Updated!

https://github.com/llvm/llvm-project/pull/100180


More information about the llvm-commits mailing list