How To Install kelbt on Ubuntu 22.04

In this tutorial we learn how to install kelbt on Ubuntu 22.04. kelbt is backtracking LR parser generator

Introduction

In this tutorial we learn how to install kelbt on Ubuntu 22.04.

What is kelbt

kelbt is:

Kelbt generates backtracking LALR(1) parsers. Standard LALR(1) parser generators emit an error upon encountering a conflict in the parse tables. Kelbt forges onward, generating parsers which handle conflicts by backtracking at runtime. Kelbt is able to generate a parser for any context-free grammar and therefore implements a generalized parsing method.

Kelbt is different from other backtracking LR systems in two ways. First, it elevates backtracking to the level of semantic actions by introducing a class of actions called undo actions. Undo actions are invoked as the backtracker undoes parsing and allow the user to revert any side effects of forward semantic actions. This makes it possible to backtrack over language constructs which must modify global state in preparation for handling context dependencies.

Second, Kelbt enables a user-controlled parsing strategy which approximates that of generalized recursive-descent parsing with ordered choice. This makes it easy for the user to resolve language ambiguities by ordering the grammar productions of a non-terminal according to precedence. It is approximate in the sense that for most grammars the equivalent of an ordered choice parsing strategy is achieved. In cases where productions are parsed out of the order given, there is a simple grammar transformation which remedies the problem.

As a proof of concept, Kelbt has been used to write a partial C++ parser (included) which is composed of strictly a scanner, a name lookup stage and a grammar with standard semantic actions and semantic undo actions.

There are three methods to install kelbt on Ubuntu 22.04. We can use apt-get, apt and aptitude. In the following sections we will describe each method. You can choose one of them.

Install kelbt Using apt-get

Update apt database with apt-get using the following command.

sudo apt-get update

After updating apt database, We can install kelbt using apt-get by running the following command:

sudo apt-get -y install kelbt

Install kelbt Using apt

Update apt database with apt using the following command.

sudo apt update

After updating apt database, We can install kelbt using apt by running the following command:

sudo apt -y install kelbt

Install kelbt Using aptitude

If you want to follow this method, you might need to install aptitude first since aptitude is usually not installed by default on Ubuntu. Update apt database with aptitude using the following command.

sudo aptitude update

After updating apt database, We can install kelbt using aptitude by running the following command:

sudo aptitude -y install kelbt

How To Uninstall kelbt on Ubuntu 22.04

To uninstall only the kelbt package we can use the following command:

sudo apt-get remove kelbt

Uninstall kelbt And Its Dependencies

To uninstall kelbt and its dependencies that are no longer needed by Ubuntu 22.04, we can use the command below:

sudo apt-get -y autoremove kelbt

Remove kelbt Configurations and Data

To remove kelbt configuration and data from Ubuntu 22.04 we can use the following command:

sudo apt-get -y purge kelbt

Remove kelbt configuration, data, and all of its dependencies

We can use the following command to remove kelbt configurations, data and all of its dependencies, we can use the following command:

sudo apt-get -y autoremove --purge kelbt

References

Summary

In this tutorial we learn how to install kelbt package on Ubuntu 22.04 using different package management tools: apt, apt-get and aptitude.