# \#parsing

**URL:** https://discuss.ocaml.org/tag/parsing/303.md

[Latest](https://discuss.ocaml.org/latest.md) · [Categories](https://discuss.ocaml.org/categories.md) · [Tags](https://discuss.ocaml.org/tags.md)

---

## [Which data type to use as an input channel for a parser?](https://discuss.ocaml.org/t/which-data-type-to-use-as-an-input-channel-for-a-parser/17967)

<div class="topic-metadata">

**Author:** [@jbe](https://discuss.ocaml.org/u/jbe)\
**Replies:** 6\
**Last updated:** [April 11, 2026, 3:18pm UTC](https://discuss.ocaml.org/t/which-data-type-to-use-as-an-input-channel-for-a-parser/17967 "2026-04-11T15:18:48Z")

</div>

I have an API for which I would like to add a function that parses a specific data structure from its text representation. I currently want to process the input on a per-line basis, but this is just how I currently do i…

---

## [Parsing question - keywords](https://discuss.ocaml.org/t/parsing-question-keywords/15332)

<div class="topic-metadata">

**Author:** [@patrick-nicodemus](https://discuss.ocaml.org/u/patrick-nicodemus)\
**Replies:** 0\
**Last updated:** [September 25, 2024, 1:54pm UTC](https://discuss.ocaml.org/t/parsing-question-keywords/15332 "2024-09-25T13:54:34Z")

</div>

This is not an OCaml question, it is a design question about writing a parser grammar, but there are many people in the OCaml community who write parsers so I hope this is an appropriate question. I forked someone’s tre…

---

## [Solving shift/reduce conflicts for optional trailing comma in menhir](https://discuss.ocaml.org/t/solving-shift-reduce-conflicts-for-optional-trailing-comma-in-menhir/15042)

<div class="topic-metadata">

**Author:** [@ttzytt](https://discuss.ocaml.org/u/ttzytt)\
**Replies:** 4\
**Last updated:** [July 30, 2024, 7:34am UTC](https://discuss.ocaml.org/t/solving-shift-reduce-conflicts-for-optional-trailing-comma-in-menhir/15042 "2024-07-30T07:34:18Z")

</div>

Optional trailing commas (or other symbols) are quite a common feature in various programming languages. For example, Rust allows you to add a trailing comma at the end of an array like this ( Array and index expression…

---

## [Debugging Angstrom (or parser combinators in general)](https://discuss.ocaml.org/t/debugging-angstrom-or-parser-combinators-in-general/13741)

<div class="topic-metadata">

**Author:** [@m-spitfire](https://discuss.ocaml.org/u/m-spitfire)\
**Replies:** 5\
**Last updated:** [December 29, 2023, 9:45am UTC](https://discuss.ocaml.org/t/debugging-angstrom-or-parser-combinators-in-general/13741 "2023-12-29T09:45:18Z")

</div>

Hello. I’m trying to debug a parser that I wrote, but I have no idea how to do it. Is there any resource that I can read upon on about how to debug a parser written with combinators? My current issue is about (I think)…

---

## [Parsing simple recursive expressions with Angstrom](https://discuss.ocaml.org/t/parsing-simple-recursive-expressions-with-angstrom/13734)

<div class="topic-metadata">

**Author:** [@m-spitfire](https://discuss.ocaml.org/u/m-spitfire)\
**Replies:** 4\
**Last updated:** [December 29, 2023, 7:10am UTC](https://discuss.ocaml.org/t/parsing-simple-recursive-expressions-with-angstrom/13734 "2023-12-29T07:10:44Z")

</div>

Hello. I’m trying to write a parser for a simple language with AST definition as follows type term = | TmTrue | TmFalse | TmIf of term \* term \* term | TmZero I’m struggling to write the parser for if expression…

---

## [Lexer - How to handle conflicts? (Menhir)](https://discuss.ocaml.org/t/lexer-how-to-handle-conflicts-menhir/13717)

<div class="topic-metadata">

**Author:** [@MarcCoquand](https://discuss.ocaml.org/u/MarcCoquand)\
**Replies:** 2\
**Last updated:** [December 26, 2023, 6:14pm UTC](https://discuss.ocaml.org/t/lexer-how-to-handle-conflicts-menhir/13717 "2023-12-26T18:14:46Z")

</div>

Hey! I am setting up a tiny DSL, with the structure: user: id uuidv4, name name The idea is to generate CSV files based on this, and I am trying to figure out how to handle conflicting lexer rules. I have the following…

---

## [Why Do Simple Let Bindings Introduce Extra Type Assertions?](https://discuss.ocaml.org/t/why-do-simple-let-bindings-introduce-extra-type-assertions/13537)

<div class="topic-metadata">

**Author:** [@zepalmer](https://discuss.ocaml.org/u/zepalmer)\
**Replies:** 4\
**Last updated:** [December 1, 2023, 12:01pm UTC](https://discuss.ocaml.org/t/why-do-simple-let-bindings-introduce-extra-type-assertions/13537 "2023-12-01T12:01:59Z")

</div>

Brief I was just surprised to discover that let x : int = 4 in x actually produces the AST I would’ve expected from let x : int = (4 : int) in x This was a bit jarring, as the PPX code I’m writing attempts to move a …

---

## [Unicode-aware parser combinators](https://discuss.ocaml.org/t/unicode-aware-parser-combinators/13003)

<div class="topic-metadata">

**Author:** [@viritrilbia](https://discuss.ocaml.org/u/viritrilbia)\
**Replies:** 25\
**Last updated:** [September 13, 2023, 1:53am UTC](https://discuss.ocaml.org/t/unicode-aware-parser-combinators/13003 "2023-09-13T01:53:20Z")

</div>

For my application (a dependently typed proof assistant) I need a parser with (among other things) two properties: It is aware of UTF-8. Yes, any OCaml string can contain UTF-8 data, but it seems to me (correct me if …

---

## [Recursion in Menhir lexer for small DSL](https://discuss.ocaml.org/t/recursion-in-menhir-lexer-for-small-dsl/10566)

<div class="topic-metadata">

**Author:** [@olleharstedt](https://discuss.ocaml.org/u/olleharstedt)\
**Replies:** 31\
**Last updated:** [October 5, 2022, 4:08pm UTC](https://discuss.ocaml.org/t/recursion-in-menhir-lexer-for-small-dsl/10566 "2022-10-05T16:08:03Z")

</div>

I need to lex and parse a small DSL inside my language, related to the docblock: /\*\* \* @param array\<int\> $ints \*/ function foo(array &$ints): void { } The DSL is the @param part, and the main lang…

---

## [Good references on the theory of parsing](https://discuss.ocaml.org/t/good-references-on-the-theory-of-parsing/9625)

<div class="topic-metadata">

**Author:** [@Chet\_Murthy](https://discuss.ocaml.org/u/Chet_Murthy)\
**Replies:** 8\
**Last updated:** [April 7, 2022, 9:22pm UTC](https://discuss.ocaml.org/t/good-references-on-the-theory-of-parsing/9625 "2022-04-07T21:22:36Z")

</div>

This is a little off-topic, but I don’t really know where to ask this question: I’m looking for good (comprehensive) references on the theory of parsing. My current specific question is on the various reductions between…

---

## [Advice on how to componentize and later combine source code?](https://discuss.ocaml.org/t/advice-on-how-to-componentize-and-later-combine-source-code/9366)

<div class="topic-metadata">

**Author:** [@Chet\_Murthy](https://discuss.ocaml.org/u/Chet_Murthy)\
**Replies:** 10\
**Last updated:** [February 22, 2022, 6:55pm UTC](https://discuss.ocaml.org/t/advice-on-how-to-componentize-and-later-combine-source-code/9366 "2022-02-22T18:55:01Z")

</div>

I’m writing this note to ask for suggestions from readers. First, some setup: we all know that LR grammars are … famously fickle when it comes to adding rules post-hoc: you really do need to understand the entire gramma…

---

## [Generate a parser enabling incremental API and inspection API](https://discuss.ocaml.org/t/generate-a-parser-enabling-incremental-api-and-inspection-api/9380)

<div class="topic-metadata">

**Author:** [@SoftTimur](https://discuss.ocaml.org/u/SoftTimur)\
**Replies:** 1\
**Last updated:** [February 21, 2022, 7:35pm UTC](https://discuss.ocaml.org/t/generate-a-parser-enabling-incremental-api-and-inspection-api/9380 "2022-02-21T19:35:22Z")

</div>

I have a big project built by menhir and traditional makefile. First, I wanted to add a mechanism of error handling like this project to my project. By following the dune of the sample project, I managed to generate .ml…

---

## [\[ANN\] v3.0.0 release of reparse, reparse-lwt, reparse-lwt-unix](https://discuss.ocaml.org/t/ann-v3-0-0-release-of-reparse-reparse-lwt-reparse-lwt-unix/8058)

<div class="topic-metadata">

**Author:** [@BikalGurung](https://discuss.ocaml.org/u/BikalGurung)\
**Replies:** 0\
**Last updated:** [June 25, 2021, 8:40pm UTC](https://discuss.ocaml.org/t/ann-v3-0-0-release-of-reparse-reparse-lwt-reparse-lwt-unix/8058 "2021-06-25T20:40:48Z")

</div>

Dear OCamlers, I am happy to announce v3.0.0 of reparse - an OCaml library for constructing various types of parsers in OCaml. The release follows a complete overhaul of the internal working of the library to achieve t…

---

## [\[ANN\] Reparse v2.1.0 release](https://discuss.ocaml.org/t/ann-reparse-v2-1-0-release/7619)

<div class="topic-metadata">

**Author:** [@BikalGurung](https://discuss.ocaml.org/u/BikalGurung)\
**Replies:** 3\
**Last updated:** [April 8, 2021, 1:58pm UTC](https://discuss.ocaml.org/t/ann-reparse-v2-1-0-release/7619 "2021-04-08T13:58:35Z")

</div>

Hi All, I have just released v2.1.0 of reparse to opam. Below are the CHANGES for this release. CHANGES: This release has backwards incompatible changes. Infix functions are now available (opened by default) in Pars…

---

## [\[ANN\] reparse 2.0.0](https://discuss.ocaml.org/t/ann-reparse-2-0-0/6868)

<div class="topic-metadata">

**Author:** [@BikalGurung](https://discuss.ocaml.org/u/BikalGurung)\
**Replies:** 15\
**Last updated:** [December 29, 2020, 11:07am UTC](https://discuss.ocaml.org/t/ann-reparse-2-0-0/6868 "2020-12-29T11:07:48Z")

</div>

A new version of reparse 2.0.0 has been released to opam. Reparse is a monadic, recursive descent based, comprehensive, parser construction library for ocaml. CHANGES for version 2.0.0: Rewrite the whole package to us…

---

## [Mutually recursive parser in Angstrom](https://discuss.ocaml.org/t/mutually-recursive-parser-in-angstrom/6724)

<div class="topic-metadata">

**Author:** [@Kakadu](https://discuss.ocaml.org/u/Kakadu)\
**Replies:** 6\
**Last updated:** [November 8, 2020, 7:17pm UTC](https://discuss.ocaml.org/t/mutually-recursive-parser-in-angstrom/6724 "2020-11-08T19:17:28Z")

</div>

I want to defined mutually recursive parser functions using Angstrom and it seems that built-in fix doesn’t help me I can’t declare my own polyvariadic fix because parser type is abstract. I also checked other parser-…

---

## [Menhir + error recovery](https://discuss.ocaml.org/t/menhir-error-recovery/4378)

<div class="topic-metadata">

**Author:** [@lelf](https://discuss.ocaml.org/u/lelf)\
**Replies:** 0\
**Last updated:** [September 17, 2019, 4:48pm UTC](https://discuss.ocaml.org/t/menhir-error-recovery/4378 "2019-09-17T16:48:00Z")

</div>

Can someone point me to some examples of error recovery (code)? E. g. parse recover to foo=2+" → foo=2 by backing off to the nearest “parsable” state foo="2 → foo="2" at the point of parsing error you inser…

---

## [Parsing shell commands](https://discuss.ocaml.org/t/parsing-shell-commands/4274)

<div class="topic-metadata">

**Author:** [@AjayMT](https://discuss.ocaml.org/u/AjayMT)\
**Replies:** 9\
**Last updated:** [August 22, 2019, 12:42am UTC](https://discuss.ocaml.org/t/parsing-shell-commands/4274 "2019-08-22T00:42:23Z")

</div>

Hey everyone, As a first project, I’m trying to write a simple shell in OCaml. I want to be able to parse commands that look like this: ENV\_VAR=value ENV\_VAR=value command arg1 arg2 I’ve written a menhir/ocamlyacc gra…

---

## [Producing and using typed ASTs for all source files in a project](https://discuss.ocaml.org/t/producing-and-using-typed-asts-for-all-source-files-in-a-project/3713)

<div class="topic-metadata">

**Author:** [@bramford](https://discuss.ocaml.org/u/bramford)\
**Replies:** 5\
**Last updated:** [May 17, 2019, 3:25am UTC](https://discuss.ocaml.org/t/producing-and-using-typed-asts-for-all-source-files-in-a-project/3713 "2019-05-17T03:25:25Z")

</div>

I’m trying to produce typed ASTs for all source files in an OCaml project (e.g. a library or git repo). The goal is to inspect these typed ASTs to learn how OCaml modules/libraries are used throughout a project. What I’d…
