Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
POTTIER Francois
menhir
Commits
1a570d12
Commit
1a570d12
authored
Oct 26, 2015
by
POTTIER Francois
Browse files
Cleanup: modified [Error.errorp] to take a format.
parent
abb1f3ad
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/error.ml
View file @
1a570d12
...
...
@@ -84,10 +84,6 @@ let printN positions message = (* TEMPORARY *)
let
error_message
message
=
"Error: "
^
message
let
old_error
positions
message
=
(* TEMPORARY *)
printN
positions
(
error_message
message
);
exit
1
let
error
positions
format
=
print_positions
positions
;
Printf
.
kfprintf
...
...
@@ -95,8 +91,8 @@ let error positions format =
stderr
(
"Error: "
^^
format
^^
"
\n
%!"
)
let
errorp
v
message
=
old_
error
[
Positions
.
position
v
]
message
let
errorp
v
=
error
[
Positions
.
position
v
]
let
signal
positions
message
=
printN
positions
message
;
...
...
src/error.mli
View file @
1a570d12
...
...
@@ -41,7 +41,7 @@ val error: Positions.positions -> ('a, out_channel, unit, 'b) format4 -> 'a
(* [errorp v msg] displays the error message [msg], referring to the
position range carried by [v], and exits. *)
val
errorp
:
'
a
Positions
.
located
->
string
->
'
b
val
errorp
:
_
Positions
.
located
->
(
'
a
,
out_channel
,
unit
,
'
b
)
format4
->
'
a
(* [warning ps msg] displays the warning message [msg], referring to
the positions [ps]. *)
...
...
src/lexer.mll
View file @
1a570d12
...
...
@@ -337,9 +337,7 @@ rule main = parse
{
PLUS
}
|
(
lowercase
identchar
*
)
as
id
{
if
Hashtbl
.
mem
reserved
id
then
Error
.
errorp
(
Positions
.
with_poss
(
lexeme_start_p
lexbuf
)
(
lexeme_end_p
lexbuf
)
()
)
"this is an Objective Caml reserved word."
error2
lexbuf
"this is an Objective Caml reserved word."
else
LID
(
with_pos
(
cpos
lexbuf
)
id
)
}
...
...
src/parameterizedGrammar.ml
View file @
1a570d12
...
...
@@ -595,7 +595,7 @@ let expand p_grammar =
let
accu
=
types_from_list
q
in
let
mangled
=
mangle
nt
in
if
StringMap
.
mem
mangled
accu
then
Error
.
error
[
Positions
.
position
(
Parameters
.
with_pos
nt
)
]
Error
.
error
[
Parameters
.
position
nt
]
"there are multiple %%type declarations for nonterminal %s."
mangled
;
StringMap
.
add
mangled
(
Positions
.
value
ty
)
accu
...
...
@@ -610,7 +610,7 @@ let expand p_grammar =
let
accu
=
on_error_reduce_from_list
ps
in
let
mangled
=
mangle
nt
in
if
StringSet
.
mem
mangled
accu
then
Error
.
error
[
Positions
.
position
(
Parameters
.
with_pos
nt
)
]
Error
.
error
[
Parameters
.
position
nt
]
"there are multiple %%on_error_reduce declarations for nonterminal %s."
mangled
;
StringSet
.
add
mangled
accu
...
...
src/partialGrammar.ml
View file @
1a570d12
...
...
@@ -43,7 +43,7 @@ let join_declaration filename (grammar : grammar) decl =
if
token_property
.
tk_is_declared
then
Error
.
errorp
decl
(
Printf
.
sprintf
"the token %s has multiple definitions."
terminal
)
"the token %s has multiple definitions."
terminal
(* Otherwise, update the previous definition. *)
...
...
@@ -594,7 +594,7 @@ let check_keywords producers action =
)
producers
;
if
not
!
found
then
Error
.
errorp
keyword
(
Printf
.
sprintf
"%s refers to a nonexistent symbol."
id
)
"%s refers to a nonexistent symbol."
id
|
Position
(
Left
,
_
,
_
)
|
SyntaxError
->
()
...
...
@@ -627,10 +627,9 @@ let check_parameterized_grammar_is_well_defined grammar =
List
.
iter
(
fun
p
->
let
head_symb
=
parameter_head_symb
p
in
if
not
(
StringMap
.
mem
(
value
head_symb
)
grammar
.
p_rules
)
then
Error
.
errorp
(
Parameters
.
with_pos
p
)
(
Printf
.
sprintf
Error
.
error
[
Parameters
.
position
p
]
"this should be a nonterminal symbol.
\n
\
%s declarations are applicable only to nonterminal symbols."
kind
)
%s declarations are applicable only to nonterminal symbols."
kind
)
ps
in
check
"%type"
(
List
.
map
fst
grammar
.
p_types
);
...
...
@@ -687,7 +686,7 @@ let check_parameterized_grammar_is_well_defined grammar =
if
not
((
StringMap
.
find
s
grammar
.
p_tokens
)
.
tk_is_declared
||
List
.
mem
s
reserved
)
then
Error
.
errorp
symbol
(
Printf
.
sprintf
"%s has not been declared as a token."
s
)
"%s has not been declared as a token."
s
with
Not_found
->
()
);
already_seen
...
...
@@ -706,13 +705,13 @@ let check_parameterized_grammar_is_well_defined grammar =
(* It is forbidden to use the %prec directive with %inline. *)
if
prule
.
pr_inline_flag
then
Error
.
errorp
terminal
"use of %prec is forbidden in an %inlined nonterminal definition."
;
"use of
%
%prec is forbidden in an
%
%inlined nonterminal definition."
;
(* Furthermore, the symbol following %prec must be a valid
token identifier. *)
if
not
(
StringMap
.
mem
terminal
.
value
grammar
.
p_tokens
)
then
Error
.
errorp
terminal
(
Printf
.
sprintf
"%s is undefined."
terminal
.
value
)
)
"%s is undefined."
terminal
.
value
)
prule
.
pr_branches
;
...
...
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