Skip to content
0:00 / 0:00

#bison#re2c#lexer

Parser and Lexer — How to Create a Compiler part 1/5 — Converting text into an Abstract Syntax Tree

Bisqwit

147K subscribers • 9 videos on Hallway

YouTube
  • Recommended by 2 people: 1 on Lobsters and 1 in engineering communities.
  • Presented by Bisqwit
  • Linked in the descriptionbisqwit/compiler_series

Intermediate. Assumes working knowledge.

457K views8 years ago2 recommendations

Systems programmingCompilers and interpretersC++

Bisqwit demonstrates how to build a lexer and parser in C++ using re2c and GNU Bison to convert source code into an AST.

In this tool-assisted education video I create a parser in C++ for a B-like programming language using GNU Bison. For the lexicographical analysis, a lexer is generated using re2c. This is part of a multi-episode series. In the next video, we will focus on optimization. Become a member: youtube.com/Bisqwit/join Downloads: — github.com/bisqwit/compiler_series/tree/master/ep1 All the material associated with this episode can be downloaded here. Acknowledgements: — Picture: Processors :: Jason Rogers — Music¹: Aryol :: The Strategy Continues :: Kyohei Sada (converted into MIDI and played through OPL3 emulation through homebrew software) — Music²: Star Ocean :: Past Days :: Motoi Sakuraba (SPC-OPL3 conversion) — Music³: Rockman & Forte :: Museum :: Kirikiri-Chan and others (SPC-OPL3 conversion) — Music⁴: Famicom Tantei Club Part II: Ushiro ni Tatsu Shōjo :: Dean’s Room :: Kenji Yamamoto (SPC-OPL3 conversion), original composition: Bach's Invention № 15 — Music⁵: Aryol :: Arrest :: Kyohei Sada (SPC-OPL3 conversion) — Music⁶: Ren & Stimpy Show : Fire Dogs :: Main Theme :: Martin Gwynn Jones and others (SPC-OPL3 conversion) — Music⁷: Aryol :: Warmup :: Kyohei Sada (SPC-OPL3 conversion) — Music⁸: Energy Breaker :: Golden-Colored Wind :: Yukio Nakajima (SPC-OPL3 conversion) — Music⁹: Wonder Project J :: House :: Akihiko Mori (SPC-OPL3 conversion) — SFX: Mostly from YouTube Audio Library. Some are recorded from video games like The Guardian Legend, Lunar Ball, and Super Mario All-Stars. ¹ , ² & , ³ , ⁴ , ⁵ , ⁶ , ⁷ & , ⁸ , ⁹ My links: Twitter: twitter.com/RealBisqwit Liberapay: liberapay.com/Bisqwit Steady: steadyhq.com/en/bisqwit Patreon: patreon.com/Bisqwit (Other options at bisqwit.iki.fi/donate.html) Twitch: twitch.tv/RealBisqwit Homepage: iki.fi/bisqwit/ You can contribute subtitles: youtube.com/timedtext_video?ref=share&v=eF9qWbuQLuw or to any of my videos: youtube.com/timedtext_cs_panel?tab=2&c=UCKTehwyGCKF-b2wo0RKw… ---Rant--- [ PM] Bisqwit: Now uploading to YouTube. Within about 24 hours I will know if the rogue AI at YouTube slams the “limited or no advertising" stamp into it, or not. Actually, I only know if it does so *when* it does it. Then, I need to wait an additional 25 hours for YouTube staff to manually review it and clear the flag. If the flag does not appear, then it is possible that the bot just has not scanned it yet and I need to wait longer. Premature publication could mean that the bot will mark it after it has already been published, and then I will not receive any revenue for the first spike of views. It used to be 18 hours (since uploading that the bot does its evil deeds), but nowadays YT recommends waiting just 3 hours. We will see, we will see. #Bisqwit #Compiler #Tutorial

Why it's here

2 people recommend this

What people say. Recommended as a highly detailed, tool-assisted tutorial on building a compiler frontend.

u/rain5in r/Compilers • Recommends

BISQWIT Parser and Lexer — How to Create a Compiler part 1/5

j11gon Lobsters • Recommends

Parser and Lexer — How to Create a Compiler

u/btwiusearchin r/compsci • Mentions

On “A brand new programming language”

Bisqwit is currently making a series about how to make a compiler. The first video is about parsers/lexers. You should check it out.

u/Rockytritonin r/C_Programming • Mentions

On “Compiler Development using C.”

If you prefer learning from a video, this is a good set I've watched before: [video

u/belentepecemin r/ProgrammingLanguages • Mentions

On “Where do I start to create a compiler?”

The current stack-based output of the code is: GET_LOCAL 1 // b GET_LOCAL 2 // c ADD SET_LOCAL 0 // a (Since all of the alignment is 8 bytes right now). Also, I have created an emulator for the instruction set I want to emit. But I have no idea how to turn my stack-based implementation to a register-based one and then make it to assembly code. I have watched the video series by Bisqwit. But still, I don't know how to code something like that.