flâneur — a map of the web's best reading

2. Kaleidoscope: Implementing a Parser and AST — LLVM 20.0.0git documentation

llvm.org · 6,570 words · saved by 1 readers

Welcome to Chapter 2 of the “Implementing a language with LLVM” tutorial. This chapter shows you how to use the lexer, built in Chapter 1, to build a full parser for our Kaleidoscope language. Once we have a parser, we’ll define and build an Abstract Syntax Tree (AST). The parser we will build uses a combination of Recursive Descent Parsing and Operator-Precedence Parsing to parse the Kaleidoscope language (the latter for binary expressions and the former for everything else). Before we get to parsing though, let’s talk about the output of the parser: the Abstract Syntax Tree. The AST for a program captures its behavior in such a way that it is easy for later stages of the compiler (e.g. code generation) to interpret. We basically want one object for each construct in the language, and the AST should closely model the language. In Kaleidoscope, we have expressions, a prototype, and a function object. We’ll start with expressions first: The code above shows the definition of the base Ex

2. Kaleidoscope: Implementing a Parser and AST — LLVM 23.0.0git documentation Navigation index next | previous | LLVM Home | Documentation >> Getting Started/Tutorials » LLVM Tutorial: Table of Contents » My First Language Frontend with LLVM Tutorial » 2. Kaleidoscope: Implementing a Parser and AST Documentation Getting Started/Tutorials User Guides Reference Getting Involved Contributing to LLVM Submitting Bug Reports Mailing Lists Discord Meetups and Social Events Additional Links FAQ Glossary Publications Github Repository This Page Show Source Quick search 2. Kaleidosc

Explore this link on the map →

saved by

related reading