Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
POTTIER Francois
menhir
Commits
894ed838
Commit
894ed838
authored
Jan 18, 2015
by
POTTIER Francois
Browse files
Moved the list and stream functions to a new module [MenhirLib.General].
parent
1fec3725
Changes
6
Hide whitespace changes
Inline
Side-by-side
GNUmakefile
View file @
894ed838
...
...
@@ -85,6 +85,7 @@ LIBFILES := \
src/IncrementalEngine.ml
\
src/engineTypes.ml
\
src/engine.
{
ml,mli
}
\
src/general.
{
ml,mli
}
\
src/inspectionTableFormat.ml
\
src/inspectionTableInterpreter.
{
ml,mli
}
\
src/tableFormat.ml
\
...
...
LICENSE
View file @
894ed838
...
...
@@ -13,6 +13,7 @@ In the following, "the Library" refers to the following files:
src/tableFormat.ml
src/tableInterpreter.{ml,mli}
src/convert.{ml,mli}
src/general.{ml,mli}
while "the Generator" refers to all other files in this archive.
...
...
src/IncrementalEngine.ml
View file @
894ed838
open
General
(* This signature describes the incremental LR engine. *)
(* In this mode, the user controls the lexer, and the parser suspends
...
...
@@ -69,23 +71,6 @@ module type INCREMENTAL_ENGINE = sig
type
'
a
lr1state
(* A stream is a list whose elements are produced on demand. *)
type
'
a
stream
=
'
a
head
Lazy
.
t
and
'
a
head
=
|
Nil
|
Cons
of
'
a
*
'
a
stream
(* The length of a stream. *)
val
length
:
'
a
stream
->
int
(* Folding over a stream. *)
val
foldr
:
(
'
a
->
'
b
->
'
b
)
->
'
a
stream
->
'
b
->
'
b
(* An element is a pair of a non-initial state [s] and a semantic value [v]
associated with the incoming symbol of this state. The idea is, the value
[v] was pushed onto the stack just before the state [s] was entered. Thus,
...
...
src/_tags
View file @
894ed838
...
...
@@ -31,3 +31,4 @@
<tableFormat.cmx>: for-pack(MenhirLib)
<tableInterpreter.cmx>: for-pack(MenhirLib)
<convert.cmx>: for-pack(MenhirLib)
<general.cmx>: for-pack(MenhirLib)
src/engine.ml
View file @
894ed838
...
...
@@ -503,35 +503,6 @@ module Make (T : TABLE) = struct
(* --------------------------------------------------------------------------- *)
(* Streams. *)
type
'
a
stream
=
'
a
head
Lazy
.
t
and
'
a
head
=
|
Nil
|
Cons
of
'
a
*
'
a
stream
(* The length of a stream. *)
let
rec
length
xs
=
match
Lazy
.
force
xs
with
|
Nil
->
0
|
Cons
(
_
,
xs
)
->
1
+
length
xs
(* Folding over a stream. *)
let
rec
foldr
f
xs
accu
=
match
Lazy
.
force
xs
with
|
Nil
->
accu
|
Cons
(
x
,
xs
)
->
f
x
(
foldr
f
xs
accu
)
(* --------------------------------------------------------------------------- *)
(* Stack inspection. *)
(* We offer a read-only view of the parser's state as a stream of elements.
...
...
@@ -542,6 +513,8 @@ module Make (T : TABLE) = struct
type
element
=
|
Element
:
'
a
lr1state
*
'
a
*
Lexing
.
position
*
Lexing
.
position
->
element
open
General
type
stack
=
element
stream
...
...
src/menhirLib.mlpack
View file @
894ed838
...
...
@@ -5,6 +5,7 @@ InfiniteArray
LinearizedArray
PackedIntArray
RowDisplacement
General
IncrementalEngine
EngineTypes
Engine
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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