Previously. Besides modal editing and customizability, another core aspect of Vim’s power comes from composability. For example:

  • dt: deletes until the next : character
  • 2dw or d2w deletes two words
  • cib deletes inside the current bracket and insert insert mode from there
  • >10j indents the current line and the next 10 lines

This mechanism offers significant flexibility while minimizing the amount of key presses.

Table of Contents

  1. Switch Cases
  2. Enter Bison
  3. Exit Bison, and Enter My Own LR(0) Parser Generator

Switch Cases

With most of the infrastructure work finished in the previous two episodes, I thought implementing these actual features would just be a tedious part that I have to go through. However, when I was thinking about boolean flags like expect_movement and trying to nest yet another level of switch-case, I had a feeling of déjà vu.

Am I just building a parser? By hand? With switch-cases and boolean flags?

That’s correct, I was trying to build something that can construct a tree structure from a linear input (keystrokes) so I can write cleaner execution logic. In other words, a parser.

Work in progress.

Enter Bison

Exit Bison, and Enter My Own LR(0) Parser Generator