Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
POTTIER Francois
menhir
Commits
53982660
Commit
53982660
authored
Sep 25, 2015
by
POTTIER Francois
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed --canonical to allow default reductions.
parent
53e2c164
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
28 deletions
+23
-28
CHANGES
CHANGES
+6
-0
src/invariant.ml
src/invariant.ml
+15
-25
src/settings.ml
src/settings.ml
+2
-3
No files found.
CHANGES
View file @
53982660
2015/09/25:
Modified the meaning of --canonical to allow default reductions to take
place. There implies no loss of precision in terms of lookahead sets,
and should allow gaining more contextual information when a syntax
error is encountered. (It should also lead to a smaller automaton.)
2015/09/23:
New option --list-errors, which produces a list of input sentences which
are representative of all possible syntax errors. (Costly.)
...
...
src/invariant.ml
View file @
53982660
...
...
@@ -765,11 +765,14 @@ let errorpeeker node =
not do anything about it for the moment. (Furthermore, someone who
uses precedence declarations is looking for trouble anyway.)
20120525: if [--canonical] has been specified, then we disallow
default reductions on a normal token, because we do not want to
introduce any spurious actions into the automaton. We do still
allow default reductions on "#", since they are needed for the
automaton to terminate properly. *)
Between 2012/05/25 and 2015/09/25, if [--canonical] has been specified,
then we disallow default reductions on a normal token, because we do not
want to introduce any spurious actions into the automaton. We do still
allow default reductions on "#", since they are needed for the automaton to
terminate properly. From 2015/09/25 on, we again always allow default
reductions, as they seem to be beneficial when explaining syntax errors. *)
(**)
let
(
has_default_reduction
:
Lr1
.
node
->
(
Production
.
index
*
TerminalSet
.
t
)
option
)
,
hdrcount
=
Misc
.
tabulateo
Lr1
.
number
Lr1
.
fold
Lr1
.
n
(
fun
s
->
...
...
@@ -778,27 +781,14 @@ let (has_default_reduction : Lr1.node -> (Production.index * TerminalSet.t) opti
None
else
match
ProductionMap
.
is_singleton
(
Lr1
.
invert
(
Lr1
.
reductions
s
))
with
|
Some
(
_
,
toks
)
as
reduction
when
SymbolMap
.
purelynonterminal
(
Lr1
.
transitions
s
)
->
if
TerminalSet
.
mem
Terminal
.
sharp
toks
then
(* Perform default reduction on "#". *)
reduction
else
begin
(* Perform default reduction, unless [--canonical] has been specified. *)
match
Settings
.
construction_mode
with
|
Settings
.
ModeCanonical
->
None
|
Settings
.
ModeInclusionOnly
|
Settings
.
ModePager
|
Settings
.
ModeLALR
->
reduction
end
|
Some
_
let
reduction
=
ProductionMap
.
is_singleton
(
Lr1
.
invert
(
Lr1
.
reductions
s
))
in
match
reduction
with
|
Some
_
->
if
SymbolMap
.
purelynonterminal
(
Lr1
.
transitions
s
)
then
reduction
else
None
|
None
->
N
on
e
reducti
on
)
...
...
src/settings.ml
View file @
53982660
...
...
@@ -28,9 +28,8 @@ let version =
type
construction_mode
=
|
ModeCanonical
(* --canonical: canonical Knuth LR(1) automaton *)
|
ModeInclusionOnly
(* --no-pager : states are merged when there is an inclusion
relationship, default reductions are used *)
|
ModePager
(* normal mode: states are merged as per Pager's criterion,
default reductions are used *)
relationship *)
|
ModePager
(* normal mode: states are merged as per Pager's criterion *)
|
ModeLALR
(* --lalr : states are merged as in an LALR generator,
i.e. as soon as they have the same LR(0) core *)
...
...
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