Title: Theory / Unimportant / CS / Programming / oCaml / Menhir
Tags: récupéré seen_description declaration FromInstruction computer_to_instruction hasNotNewEffectReturnsMeaning todo_declaration

Instruction: menhir foo_1 ... foo_n
Page: 4
Effect: Call menhir with input files foo1 ... foon
Language: Menhir
Chapter: 2

Fla: --base bar
Effect: The output files are called bar.ml and bar.mli
Page: 4
Prefix: menhir
Chapter: 2

Fla: --cmly bar
Effect: menhir produce also a cmly file containing a binary-form representation of the grammar and automaton
Page: 4
Prefix: menhir
Chapter: 2

Fla: --comment
Effect: Add few comment to generated caml code
Page: 4
Prefix: menhir
Chapter: 2

Fla: --compare-errors filename1 --compare-errors filename2
Effect: Two such switches must always be used in conjunction so as to specify the names of two .messages files, filename1 and filename2. Each file is read and internally translated to a mapping of states to messages. Menhir then checks that the left-hand mapping is a subset of the right-hand mapping. This feature is typically used in conjunction with --list-errors to check that filename2 is complete (that is, covers all states where an error can occur).
Page: 4
Prefix: menhir
Chapter: 2

Fla: --compile-errors foo
Effect: This switch causes Menhir to read the file filename, which must obey the .messages file format, and to compile it to an OCaml function that maps a state number to a message. The OCaml code is sent to the standard output channel. At the same time, Menhir checks that the collection of input sentences in the file filename is correct and irredundant.
Page: 4
Prefix: menhir
Chapter: 2

Fla: --coq
Effect: This switch causes Menhir to produce Coq code
Page: 4
Prefix: menhir
Chapter: 2

Instruction: ;
Page: 8
Effect: insignifiant caracter
Language: menhir
Chapter: 2

Question: How to comment
Answer: //, /* */ or (* *). Don't mix
Page: 8
Chapter: 2
Context: menhir

Instruction: <foo>
Page: 8
Effect: The type foo
Language: menhir
Chapter: 2
Assuming: foo is fully qualified

Name: Specification
Definition: declaration . . . declaration
Page: 8
Chapter: 4
Context: menhir
Definition2: %% rule . . . rule
Definition3: [ %% OCaml code ]

Name: Header
Definition: A piece of OCaml code, surrounded with %{ and %} copied verbatim at the beginning of the .ml file.
Page: 8
Chapter: 4
Context: menhir

Instruction: %parameter <foo:bar>
Page: 10
Effect: This parser is a functor with paramater foo of module type bar
Language: menhir
Context: header
Chapter: 4
Section: 1.2

Question: In which order headers are applied
Answer: parameters first
Page: 10
Chapter: 4
Section: 1.2
Context: menhir header

Instruction: %token foo_1 ... foo_n
Page: 10
Meaning: Introduce foo_1 ... foo_n as token, in grammar specifiaction, and data constructors in the token type.
Language: menhir
Chapter: 4
Section: 1.2
Context: header

Instruction: %token <bar> foo_1 ... foo_n
Page: 10
Meaning: Introduce foo_1 ... foo_n as token, in grammar specifiaction, and data constructors in the token type. They carry a semantic value of type bar
Language: menhir
Chapter: 4
Section: 1.2
Context: header

Instruction: %start <bar> foo_1 ... foo_n
Page: 10
Effect: Each foo_i are start symbol with type bar. It become the name of a function whose signature is published in the .mli, which can be used to invoke the parser
Language: menhir
Context: header
Chapter: 4
Section: 1.6

Instruction: %on_error_reduce foo_1 ... foo_n
Page: 10
Effect: marks the nonterminal symbols  foo_1 ... foo_n as potentially eligible for reduction when an invalid token is found.
Language: menhir
Context: header
Chapter: 4
Section: 1.7

Name: A production reducible on error
Definition: A reduction of the form foo -> ...,  such that there is a %on_error_reduce foo declaration
Page: 10
Chapter: 4
Section: 1.7
Context: menhir header

Question: What appen in state s if there is an error
Answer: the production reducible on error, with highest on-error-reduce-priority at this state is taken.
Page: 10
Chapter: 4
Section: 1.7
Context: menhir header

Question: What is the interest of reduce error
Answer: They allow to obtain state with error easier to report.
Page: 10
Chapter: 4
Section: 1.7
Context: menhir

Instruction: foo:
|bar_1
...
|bar_n
Page: 11
Meaning: Introduce a non terminal symbol foo corresponding to n productions group bar_i
Language: menhir
Chapter: 4
Section: 2
Context: rule
Identifier: foo

Instruction: foo_1 ... foo_n {bar}
Page: 11
Effect: A rule stating that, when a sequence satisfying each foo_i is found, the ocaml code bar is executed and returned.
Its precedence level is the one of its right most terminal symbol
Language: menhir
Context: rule
Chapter: 4
Section: 2.1
Intuition: A production group

Instruction: foo_1 ... %prec foo_i ..._ foo_n {bar}
Page: 11
Effect: Similar to foo_1 ... foo_n {bar}. Stating furthermore that the precedence level is foo_i
Language: menhir
Context: rule
Chapter: 4
Section: 2.1

Name: A production
Definition: A sequence of producer, optionnaly followed by a %prec annotation
Page: 11
Chapter: 4
Section: 2.2
Context: menhir rule

Name: A producer
Definition: an actual, optionally preceded with a binding of a semantic value identifier, of the form lid =
Page: 11
Chapter: 4
Section: 2.2
Context: menhir rule

Name: An actual
Definition: a terminal or nonterminal symbol
Page: 11
Chapter: 4
Section: 2.2
Context: menhir rule
Definition2: A parametrized non-terminal symbol, applied to some arguments.
Definition3: Potentially followed by some modifier
Definition4: An anonymous rule (only in argument)

Name: Anonymous rule
Definition: A disjunction of actual
Page: 11
Chapter: 4
Section: 2.2
Context: menhir rule
Typ: An actual