DYPGEN(1)
π DYPGEN(1) β like, the whole manual, but make it make sense
okay bestie, so this is a page from the General Commands Manual (yes, that one) and it's all about dypgen β say it with me, it's the Objective Caml parser generator. Buckle up, we're going in π
β¨ NAME β¨
dypgen β literally the Objective Caml parser generator. that's the whole name. iconic of it.
β¨ SYNOPSIS β¨
three flavors, pick your fighter:
dypgen [ options ] filename.dyp
dypgen.opt [ options ] filename.dyp
dyp2gram filename.dyp
πΈ DESCRIPTION πΈ
so the dypgen(1) command produces a parser from a context-free grammar spec that has semantic actions attached β very yacc(1) of it, ngl, it's "in the style of" yacc(1). π«Ά
say your input file is grammar.dyp (hypothetically, keep up). run dypgen and boom β you get Caml code for a parser in the file grammar.ml, plus its interface in the file grammar.mli. slay.
the generated module defines one parsing function per entry point in the grammar. these functions have the same names as the entry points. yes, matching names, that's the vibe. β¨
now, the lexer (aka the lexical analyzer, bestie, keep up) can be generated by dypgen itself, or by a third-party generator such as ocamllex(1). and this matters because:
- if an external lexer generator is used, then the parsing functions take as arguments a lexical analyzer (a function from lexer buffers to tokens) and a lexer buffer.
- if
dypgenis used to generate the lexer, then the parsing functions only take a lexer buffer as argument.
either way they return the semantic attribute of the corresponding entry point. π
lexer buffers are an abstract data type implemented in the library module Dyp. tokens are values from the concrete type token, which is defined in the interface file grammar.mli produced by dypgen(1). very "it's giving generated types", we love that for us.
dypgen.opt(1) is the same as dypgen(1) but compiled to native code instead of bytecode. same energy, faster shoes. π
dyp2gram(1) is is a pearl script that produces a readable text documentation of your grammar from a grammar.dyp file. (and yes, "is is" β that's how the original says it, I don't make the rules, I just vibe with them π)
π₯ OPTIONS π₯
the dypgen(1) command recognizes the following options, and there are a lot, so hydrate first:
--merge-warningprefix β activates merge warning: the generated parser will emit a warning on the standard output each time a merge happens. loud and proud about it.--pv-objβ the type constructorobjis made as a sum of polymorphic variants instead of a sum of constructors. useful when the maximum number of constructors allowed is reached. (we hit the ceiling, we renovate π )--pv-tokenβ the typetokenis made as a sum of polymorphic variants instead of a sum of constructors. also useful when the maximum number of constructors allowed is reached.--noemit-token-typeβ the typetokenis not emitted in themliormlfiles; it must be provided by the user instead. you're on your own, bestie, but like, in a cool way π¦--no-ppβ the valueppis not stated in themlifile.--no-obj-typeβ the typeobj_typeis not stated in themlifile.--no-undef-ntβ prevents the exceptionUndefined_ntfrom being raised. no drama, no raise π--ocamlcoptions βdypgenuses these options when callingocamlc -i.--commandcommand βdypgenuses this command instead of callingocamlc -i. your command, your rules.--no-mliβdypgendoes not generate the.mlifile. gone, reduced to atoms.--use-rule-orderβdypgenuses rule order to decide which rule to reduce in case of reduce/reduce conflict. it is overriden by the variabledypgen_use_rule_order. β οΈ yes, the variable wins, so don't come for me if your flag gets overruled.--use-all-actionsβ the parser will execute all the user actions bound to a rule instead of just the first that does not raiseGiveup. all of them. main character energy for every action. π--cppdypgen β calls the C preprocessorcppon the input file before processing it.--cpp-optionsoptions βdypgencalls the C preprocessorcppwith options"options"on the input file before processing it.--versionβ gives the version ofdypgenand exit.-helpβ Display this list of options.--helpβ Display this list of options.
lowkey note:-helpand--helpdo the exact same thing. two icons, one job. π«Ά
π SEE ALSO π
ocamllex(1).- dypgen User's Manual
okay that's the whole thing, bestie β go forth and generate parsers πβ¨
signed off from the General Commands Manual, DYPGEN(1), no date on the tin, unversioned and unbothered β catch you in the man pages ππ
π¦ where this page comes from
- nixos 26.05: ocaml5.4.1-dypgen 0.2
- nixpkgs unstable: ocaml5.5.1-dypgen 0.2
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms