Writing a Custom Language Parser in Golang: Tokenization

Added:

Series Intro
Project Setup
Token Kinds
Token Helpers
Lexer Struct
Core Methods
Number Parsing
Whitespace Fix

Series Intro

0:00
Playing Section
  • 1

    Starts a new series on writing a Pratt parser using Go language for a modern syntax with OOP and static types.

  • 2

    The focus of the first two episodes is building a tokenizer to split source code into tokens.

  • 3

    The series aims to teach building an AST, a key step for interpretation and compilation.

Proficiency in Go (Golang) programming, including familiarity with structs, slices, and control flow.
Basic understanding of compiler theory, specifically the distinction between lexical analysis (lexing) and syntax analysis (parsing).
Familiarity with string manipulation and character encoding (runes) in Go for processing input streams.
An understanding of Finite State Machines (FSMs) and how they model state transitions during tokenization.
Designing and constructing an Abstract Syntax Tree (AST) representation in Go from the generated tokens.
Implementing a parser (such as a Recursive Descent or Pratt parser) to analyze token sequences according to a formal grammar.
Developing an evaluator or tree-walk interpreter to execute the parsed AST.
Creating robust error-handling mechanisms for lexical and syntax analysis to provide clear feedback to users.
32.5K views1.1Klikes45:06@tylerlacebyOriginal Release: 2024-04-02

Tokenization is the process of converting raw source code into meaningful tokens using regular expressions and pattern matching, where each token contains a kind (category) and value (content), enabling the construction of an Abstract Syntax Tree (AST) for further parsing and language processing.