Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
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
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
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
697cf750
Commit
697cf750
authored
Jan 18, 2015
by
POTTIER Francois
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added [xfirst] in the inspection API.
parent
de9b6d8b
Changes
2
Hide whitespace changes
Inline
Sidebyside
Showing
2 changed files
with
39 additions
and
27 deletions
+39
27
src/IncrementalEngine.ml
src/IncrementalEngine.ml
+8
3
src/inspectionTableInterpreter.ml
src/inspectionTableInterpreter.ml
+31
24
No files found.
src/IncrementalEngine.ml
View file @
697cf750
...
...
@@ 181,19 +181,24 @@ module type INSPECTION = sig
state [s]. This set is not epsilonclosed. This set is presented as a
list, in an arbitrary order. *)
val
items
:
'
a
lr1state
>
item
list
val
items
:
_
lr1state
>
item
list
(* [nullable nt] tells whether the nonterminal symbol [nt] is nullable.
That is, it is true if and only if this symbol produces the empty
word [epsilon]. *)
val
nullable
:
'
a
nonterminal
>
bool
val
nullable
:
_
nonterminal
>
bool
(* [first nt t] tells whether the FIRST set of the nonterminal symbol [nt]
contains the terminal symbol [t]. That is, it is true if and only if
[nt] produces a word that begins with [t]. *)
val
first
:
'
a
nonterminal
>
'
b
terminal
>
bool
val
first
:
_
nonterminal
>
_
terminal
>
bool
(* [xfirst] is analogous to [first], but expects a first argument of type
[xsymbol] instead of [_ terminal]. *)
val
xfirst
:
xsymbol
>
_
terminal
>
bool
(* [foreach_terminal] enumerates the terminal symbols, including [error].
[foreach_terminal_but_error] enumerates the terminal symbols, excluding
...
...
src/inspectionTableInterpreter.ml
View file @
697cf750
...
...
@@ 80,6 +80,30 @@ module Make
assert
(
T
.
terminal
answer
=
X
(
T
t
));
(* TEMPORARY roundtrip *)
answer
(* Ordering functions. *)
let
compare_terminals
t1
t2
=
(* Subtraction is safe because overflow is impossible. *)
t2i
t1

t2i
t2
let
compare_nonterminals
nt1
nt2
=
(* Subtraction is safe because overflow is impossible. *)
n2i
nt1

n2i
nt2
let
compare_symbols
symbol1
symbol2
=
match
symbol1
,
symbol2
with

X
(
T
_
)
,
X
(
N
_
)
>

1

X
(
N
_
)
,
X
(
T
_
)
>
1

X
(
T
t1
)
,
X
(
T
t2
)
>
compare_terminals
t1
t2

X
(
N
nt1
)
,
X
(
N
nt2
)
>
compare_nonterminals
nt1
nt2
let
compare_words
w1
w2
=
General
.
compare
compare_symbols
w1
w2
(* The function [incoming_symbol] goes through the tables [T.lr0_core] and
[T.lr0_incoming]. This yields a representation of type [xsymbol], out of
which we strip the [X] quantifier, so as to get a naked symbol. This last
...
...
@@ 140,6 +164,13 @@ module Make
let
first
nt
t
=
decode_bool
(
PackedIntArray
.
unflatten1
T
.
first
(
n2i
nt
)
(
t2i
t
))
let
xfirst
symbol
t
=
match
symbol
with

X
(
T
t'
)
>
compare_terminals
t
t'
=
0

X
(
N
nt
)
>
first
nt
t
(* The function [foreach_terminal] exploits the fact that the
first component of [B.error] is [Terminal.n  1], i.e., the
number of terminal symbols, including [error] but not [#]. *)
...
...
@@ 165,28 +196,4 @@ module Make
f
(
T
.
terminal
i
)
accu
)
accu
(* Ordering functions. *)
let
compare_terminals
t1
t2
=
(* Subtraction is safe because overflow is impossible. *)
t2i
t1

t2i
t2
let
compare_nonterminals
nt1
nt2
=
(* Subtraction is safe because overflow is impossible. *)
n2i
nt1

n2i
nt2
let
compare_symbols
symbol1
symbol2
=
match
symbol1
,
symbol2
with

X
(
T
_
)
,
X
(
N
_
)
>

1

X
(
N
_
)
,
X
(
T
_
)
>
1

X
(
T
t1
)
,
X
(
T
t2
)
>
compare_terminals
t1
t2

X
(
N
nt1
)
,
X
(
N
nt2
)
>
compare_nonterminals
nt1
nt2
let
compare_words
w1
w2
=
General
.
compare
compare_symbols
w1
w2
end
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