Skip to main navigation Skip to search Skip to main content

A new Approach to Parser Generators using Parser Combinators in C#

  • Lukas Christian Hofwimmer

    Student thesis: Master's Thesis

    Abstract

    This theses introduces a novel approach to parser generation that unifies three traditionally separate concepts in language processing: syntax specification, parser construction,
    and syntax tree representation. Instead of relying on external syntax description languages and generator pipelines, the proposed method embeds syntax definitions directly
    into a host language. In this case C# is used as a domain syntax model that simultaneously functions as both the input specification for parser generation and the structural
    output of the parsing process. To enable this integration, the thesis develops a domain
    model capable of expressing essential grammar constructs such as sequences, alternatives, repetitions, optionals, literals, and terminal classes, all inferred via C#’s type
    system and reflection capabilities.
    A core contribution of this work is the implementation of a parser combinator library
    for C# based on Haskell’s Parsec, adapted to an imperative, object-oriented language
    while preserving the functional semantics required for compositional parsing. This includes monadic parser construction and controlled backtracking. Building upon this
    foundation, a parser generator is implemented that transforms domain syntax models
    into fully functional parser combinators, yielding type-safe, LINQ query-composable
    parsers expressed entirely in C#.
    The evaluation compares the generated parsers with ANTLR using JSON and Wikitext grammars. Results indicate that while the approach is not optimized for performance, it demonstrates practical feasibility, expressive power, and advantages in maintainability and tooling integration. The thesis concludes by outlining limitations particularly regarding performance and discusses potential future improvement, including
    optimizations and more advanced tooling.
    Date of Award2025
    Original languageEnglish (American)
    Awarding Institution
    • FH OÖ
    SupervisorJosef Pichler (Supervisor)

    Studyprogram

    • Software Engineering

    Cite this

    '