Skip to content

Commit 74e1ccc

Browse files
committed
Rewording
1 parent 1321d52 commit 74e1ccc

5 files changed

Lines changed: 28 additions & 33 deletions

File tree

src/mlang/index.mld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ intermediate representations going from the source code to the target backend.
66
{1 Frontend}
77

88
First, the source code is parsed according to the Menhir grammar specified in {!module: Mlang.M_frontend.Mparser}.
9-
The grammar is not exactly LR(1) so we rely on {!module: Mlang.M_frontend.Parse_utils} to backtrack, especially on symbol parsing. The target intermediate representation is {!module: Mlang.M_frontend.Mast}, which is very close to the concrete syntax and can be printed using {!module: Mlang.M_frontend.Format_mast}.
9+
The grammar is not exactly LR(1) so we rely on {!module: Mlang.M_frontend.Parse_utils} to backtrack, especially on symbol parsing. {!module: Mlang.M_frontend.Syntax_messages} treats the error messages in the different failing cases. The target intermediate representation is {!module: Mlang.M_frontend.Mast}, which is very close to the concrete syntax and can be printed using {!module: Mlang.M_frontend.Format_mast}.
1010
The frontend also handles ast expansion with {!module: Mlang.M_frontend.Expander} and validation with {!module: Mlang.M_frontend.Validator}.
1111

1212
{!modules:

src/mlang/m_frontend/dune

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
(target syntax_messages.ml)
1818
(deps
1919
(:parser mparser.mly)
20-
(:msg mparser.messages))
20+
(:msg syntax.messages))
2121
(action
2222
(with-stdout-to
2323
%{target}
@@ -38,14 +38,14 @@
3838
(target updated.messages)
3939
(deps
4040
(:parser mparser.mly)
41-
(:msg mparser.messages))
41+
(:msg syntax.messages))
4242
(action
4343
(with-stdout-to
4444
%{target}
4545
(run menhir %{parser} --base %{parser} --update-errors %{msg}))))
4646

4747
(rule
48-
(target mparser.messages.updated)
48+
(target syntax.messages.updated)
4949
(deps
5050
(:parser mparser.mly)
5151
(:new new.messages)
@@ -56,12 +56,12 @@
5656
(run menhir %{parser} --base %{parser} --merge-errors %{new}
5757
--merge-errors %{updated}))))
5858

59-
; Tests the mparser.messages file when the parser changes.
59+
; Tests the syntax.messages file when the parser changes.
6060
; To update the file, use dune runtest --auto-update
6161

6262
(rule
6363
(alias runtest)
6464
(package mlang)
65-
(deps mparser.messages mparser.messages.updated)
65+
(deps syntax.messages syntax.messages.updated)
6666
(action
67-
(diff mparser.messages mparser.messages.updated)))
67+
(diff syntax.messages syntax.messages.updated)))
Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,26 @@
1-
(** Parsing error messages handler.
2-
The .ml file corresponding to this mli is generated automatically generated
3-
by menhir (check the dune file) from the [mparser.messages] file. This file
4-
is the core of parsing message handling: this is where all error messages
5-
must be added.
1+
(** Parsing error messages handler. The .ml file corresponding to this mli is
2+
generated automatically generated by menhir from the [syntax.messages] file.
3+
This file is the core of parsing message handling: this is where all error
4+
messages must be added.
65
7-
The structure of the [mparser.messages] strongly depends on the parser's. If
6+
The structure of the [syntax.messages] strongly depends on the parser's. If
87
the parser changes, it may be necessary to rework on it to update the error
98
messages. Hopefully, [menhir] comes with a way to automatically update
109
messages when the parser changes. This can be automatically done by running
1110
[dune runtest --auto-promote]. Check the [src/mlang/m_frontend/dune] file
1211
for more information.
1312
1413
Each possible error is mapped to a state (an integer) and a custom message
15-
in the [mparser.messages] file. When the parser raises an exception, it also
16-
raises the state where it failed. This module allows to get the
14+
in the [syntax.messages] file. When the parser raises an exception, it also
15+
raises the state in which it failed. This module allows to get the
1716
corresponding error message.
1817
19-
There is then three possibilities:
20-
* the state has a custom error message, which can be printed;
21-
* the state has the default error message (<"YOUR SYNTAX ERROR MESSAGE HERE>"),
22-
which has not been written yet;
23-
* the state has no error message, which should not happen unless the
24-
[mparser.messages] is not sync with [mparser.mly].
25-
*)
18+
There is then three possibilities: * the state has a custom error message,
19+
which can be printed; * the state has the default error message (<"YOUR
20+
SYNTAX ERROR MESSAGE HERE>"), which has not been customized yet; * the state
21+
has no error message, which should happen only if the [syntax.messages] is
22+
not sync with [mparser.mly]. *)
2623

2724
val message : int -> string
28-
(** Returns the error message corresponding to a parser error state.
29-
Raises [Not_found] if the state has no error message. *)
25+
(** Returns the error message corresponding to a parser error state. Raises
26+
[Not_found] if the state has no error message. *)

src/mlang/m_ir/mir.mli

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,13 @@
2222
- Constants have been inlined.
2323
- Loops (FunCallLoop, Loop) have been unrolled.
2424
- Chaining, domain and verification calculations have been unified into
25-
Target calculations.
26-
This filtering is performed by {!M_frontend.Expander}, {!M_frontend.Validator} and
27-
{!M_frontend.Mast_to_mir}.
25+
Target calculations. This filtering is performed by
26+
{!M_frontend.Expander}, {!M_frontend.Validator} and
27+
{!M_frontend.Mast_to_mir}.
2828
29-
The structural difference between {!M_frontend.Mast} and Mir common types are
30-
the replacement of {!Mir.Com.m_var_name} by {!M_ir.Com.Var.t} and
31-
{!M_frontend.Mast.error_name} by {!M_ir.Com.Error.t}.
32-
*)
29+
The structural difference between {!M_frontend.Mast} and Mir common types
30+
are the replacement of {!Mir.Com.m_var_name} by {!M_ir.Com.Var.t} and
31+
{!M_frontend.Mast.error_name} by {!M_ir.Com.Error.t}. *)
3332

3433
type set_value = Com.Var.t Com.set_value
3534

@@ -64,8 +63,7 @@ type stats = {
6463
max_nb_args : int;
6564
table_map : Com.Var.t IntMap.t;
6665
}
67-
(** A set of constants relative to the program and its selected
68-
applications. *)
66+
(** A set of constants relative to the program and its selected applications. *)
6967

7068
type program = {
7169
program_safe_prefix : string;

0 commit comments

Comments
 (0)