2023
October
9

9th October

Implementing the Pratt parser: Identifiers

The main idea behind the pratt parser is the association of token types with parsing functions. In the last session, the types for such functions were added. Today, the parser was extended to include prefix & infix function maps.

Identifiers

The simplest identifier in the monkey programming language is:

foobar;

So this was the starting point, and extended the parser to be able to parse this expression. This required adding a parseExpressionStatement & parseExpression methods to the parser.

The parseExpression method took a priority, which is a enum of precedences amongst the operators in the language. Although the precedence is not completely implemented, it is a good start to have it in place.

Commit:4a81b1c (opens in a new tab)

Subscribe to my newsletter

The latest news, articles, and resources, sent to your inbox weekly.

© 2024 Seagin, Inc. All rights reserved.