//===- Lexer.h - Lexer for the Toy language -------------------------------===// // // 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 implements a simple Lexer for the Toy language. // //===----------------------------------------------------------------------===// #ifndef TOY_LEXER_H #define TOY_LEXER_H #include "llvm/ADT/StringRef.h" #include <cstdlib> #include <memory> #include <string> namespace toy { /// Structure definition a location in a file. struct Location { … }; // List of Token returned by the lexer. enum Token : int { … }; /// The Lexer is an abstract base class providing all the facilities that the /// Parser expects. It goes through the stream one token at a time and keeps /// track of the location in the file for debugging purpose. /// It relies on a subclass to provide a `readNextLine()` method. The subclass /// can proceed by reading the next line from the standard input or from a /// memory mapped file. class Lexer { … }; /// A lexer implementation operating on a buffer in memory. class LexerBuffer final : public Lexer { … }; } // namespace toy #endif // TOY_LEXER_H