Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
menhir
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
12
Issues
12
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
POTTIER Francois
menhir
Commits
981e2823
Commit
981e2823
authored
Aug 29, 2015
by
POTTIER Francois
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup.
parent
1d345d23
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
11 deletions
+15
-11
demos/calc-inspection/calc.ml
demos/calc-inspection/calc.ml
+15
-11
No files found.
demos/calc-inspection/calc.ml
View file @
981e2823
...
...
@@ -17,12 +17,23 @@ module E =
(
Parser
.
MenhirInterpreter
)
(
CalcErrorReporting
)
(* Define a printer for explanations. We treat an explanation as if it
were just an item: that is, we ignore the position information that
is provided in the explanation. Indeed, this information is hard to
show in text mode. *)
let
print_explanation
explanation
=
(* not printing positions in the past, as they are hard to show in a
meaningful way in text mode *)
P
.
print_item
(
E
.
item
explanation
)
(* Initialize the lexer, and catch any exception raised by the lexer. *)
let
print_explanations
startp
explanations
=
Printf
.
fprintf
stderr
"At line %d, column %d: syntax error.
\n
"
startp
.
Lexing
.
pos_lnum
startp
.
Lexing
.
pos_cnum
;
List
.
iter
print_explanation
explanations
;
flush
stderr
(* The rest of the code is as in the [calc] demo. *)
let
process
(
line
:
string
)
=
let
lexbuf
=
Lexing
.
from_string
line
in
...
...
@@ -33,14 +44,7 @@ let process (line : string) =
|
Lexer
.
Error
msg
->
Printf
.
fprintf
stderr
"%s%!"
msg
|
E
.
Error
((
startp
,
_
)
,
explanations
)
->
Printf
.
fprintf
stderr
"At line %d, column %d: syntax error.
\n
"
startp
.
Lexing
.
pos_lnum
startp
.
Lexing
.
pos_cnum
;
List
.
iter
print_explanation
explanations
;
flush
stderr
(* The rest of the code is as in the [calc] demo. *)
print_explanations
startp
explanations
let
process
(
optional_line
:
string
option
)
=
match
optional_line
with
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment