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
7635e62c
Commit
7635e62c
authored
Aug 25, 2016
by
POTTIER Francois
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Terminology: a trailer is now called a postlude everywhere.
parent
db3883c7
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
27 additions
and
28 deletions
+27
-28
src/fancy-parser.mly
src/fancy-parser.mly
+6
-6
src/lexer.mll
src/lexer.mll
+1
-2
src/partialGrammar.ml
src/partialGrammar.ml
+7
-7
src/syntax.mli
src/syntax.mli
+5
-5
src/unparameterizedPrinter.ml
src/unparameterizedPrinter.ml
+2
-2
src/unparameterizedSyntax.ml
src/unparameterizedSyntax.ml
+1
-1
src/yacc-parser.mly
src/yacc-parser.mly
+5
-5
No files found.
src/fancy-parser.mly
View file @
7635e62c
...
...
@@ -48,16 +48,16 @@ open Positions
/*
-------------------------------------------------------------------------
*/
/*
A
grammar
consists
of
declarations
and
rules
,
followed
by
an
optional
trailer
,
which
we
do
not
parse
.
*/
postlude
,
which
we
do
not
parse
.
*/
grammar
:
ds
=
declaration
*
PERCENTPERCENT
rs
=
rule
*
t
=
trailer
ds
=
declaration
*
PERCENTPERCENT
rs
=
rule
*
t
=
postlude
{
{
pg_filename
=
""
;
(* filled in by the caller *)
pg_declarations
=
List
.
flatten
ds
;
pg_rules
=
rs
;
pg_
trailer
=
t
pg_
postlude
=
t
}
}
...
...
@@ -339,12 +339,12 @@ modifier:
{
with_poss
$
startpos
$
endpos
"list"
}
/*
-------------------------------------------------------------------------
*/
/*
A
trailer
is
announced
by
%%,
but
is
optional
.
*/
/*
A
postlude
is
announced
by
%%,
but
is
optional
.
*/
trailer
:
postlude
:
EOF
{
None
}
|
p
=
PERCENTPERCENT
/*
followed
by
actual
trailer
*/
|
p
=
PERCENTPERCENT
/*
followed
by
actual
postlude
*/
{
Some
(
Lazy
.
force
p
)
}
%%
src/lexer.mll
View file @
7635e62c
...
...
@@ -632,7 +632,7 @@ and char = parse
(* Read until the end of the file. This is used after finding a %%
that marks the end of the grammar specification. We update the
current position as we go. This allows us to build a stretch
for the
trailer
. *)
for the
postlude
. *)
and finish = parse
| newline
...
...
@@ -641,4 +641,3 @@ and finish = parse
{ lexeme_start_p lexbuf }
| _
{ finish lexbuf }
src/partialGrammar.ml
View file @
7635e62c
...
...
@@ -126,15 +126,15 @@ let join_declaration filename (grammar : grammar) decl =
grammar
(* ------------------------------------------------------------------------- *)
(* This stores an optional
trailer
into a grammar.
Trailer
s are stored in an arbitrary order. *)
(* This stores an optional
postlude
into a grammar.
Postlude
s are stored in an arbitrary order. *)
let
join_
trailer
trailer
grammar
=
match
trailer
with
let
join_
postlude
postlude
grammar
=
match
postlude
with
|
None
->
grammar
|
Some
trailer
->
{
grammar
with
p_postludes
=
trailer
::
grammar
.
p_postludes
}
|
Some
postlude
->
{
grammar
with
p_postludes
=
postlude
::
grammar
.
p_postludes
}
(* ------------------------------------------------------------------------- *)
(* We rewrite definitions when nonterminals are renamed. The
...
...
@@ -573,7 +573,7 @@ let empty_grammar =
let
join
grammar
pgrammar
=
let
filename
=
pgrammar
.
pg_filename
in
List
.
fold_left
(
join_declaration
filename
)
grammar
pgrammar
.
pg_declarations
$$
join_
trailer
pgrammar
.
pg_trailer
$$
join_
postlude
pgrammar
.
pg_postlude
let
check_parameterized_grammar_is_well_defined
grammar
=
...
...
src/syntax.mli
View file @
7635e62c
...
...
@@ -29,9 +29,9 @@ type filename =
(* ------------------------------------------------------------------------ *)
(* A
trailer
is a source file fragment. *)
(* A
postlude
is a source file fragment. *)
type
trailer
=
type
postlude
=
Stretch
.
t
(* ------------------------------------------------------------------------ *)
...
...
@@ -185,7 +185,7 @@ type declaration =
type
partial_grammar
=
{
pg_filename
:
filename
;
pg_
trailer
:
trailer
option
;
pg_
postlude
:
postlude
option
;
pg_declarations
:
declaration
Positions
.
located
list
;
pg_rules
:
parameterized_rule
list
;
}
...
...
@@ -196,7 +196,7 @@ type partial_grammar =
(* The differences with partial grammars (above) are as follows:
1. the file name is gone (there could be several file names, anyway).
2. there can be several
trailers, now known as
postludes.
2. there can be several postludes.
3. declarations are organized by kind: preludes, functor %parameters,
%start symbols, %types, %tokens, %on_error_reduce.
4. rules are stored in a map, indexed by symbol names, instead of a list.
...
...
@@ -205,7 +205,7 @@ type partial_grammar =
type
grammar
=
{
p_preludes
:
Stretch
.
t
list
;
p_postludes
:
trailer
list
;
p_postludes
:
postlude
list
;
p_parameters
:
Stretch
.
t
list
;
p_start_symbols
:
Positions
.
t
StringMap
.
t
;
p_types
:
(
parameter
*
Stretch
.
ocamltype
Positions
.
located
)
list
;
...
...
src/unparameterizedPrinter.ml
View file @
7635e62c
...
...
@@ -141,7 +141,7 @@ let print_branch mode f branch =
end
;
Printf
.
fprintf
f
"}
\n
"
let
print_
trailer
s
b
g
=
let
print_
postlude
s
b
g
=
List
.
iter
(
fun
stretch
->
Printf
.
fprintf
b
"%s
\n
"
stretch
.
stretch_raw_content
)
g
.
postludes
(* Because the resolution of reduce/reduce conflicts is implicitly dictated by
...
...
@@ -212,7 +212,7 @@ let print mode f g =
Printf
.
fprintf
f
"
\n
%%%%
\n
"
;
begin
match
mode
with
|
PrintNormal
->
print_
trailer
s
f
g
print_
postlude
s
f
g
|
PrintUnitActions
|
PrintUnitActionsUnitTokens
->
()
...
...
src/unparameterizedSyntax.ml
View file @
7635e62c
...
...
@@ -36,7 +36,7 @@ type rule =
type
grammar
=
{
preludes
:
Stretch
.
t
list
;
postludes
:
Syntax
.
trailer
list
;
postludes
:
Syntax
.
postlude
list
;
parameters
:
Stretch
.
t
list
;
start_symbols
:
StringSet
.
t
;
types
:
Stretch
.
ocamltype
StringMap
.
t
;
...
...
src/yacc-parser.mly
View file @
7635e62c
...
...
@@ -36,23 +36,23 @@ open Positions
/*
-------------------------------------------------------------------------
*/
/*
A
grammar
consists
of
declarations
and
rules
,
followed
by
an
optional
trailer
,
which
we
do
not
parse
.
*/
postlude
,
which
we
do
not
parse
.
*/
grammar
:
declarations
PERCENTPERCENT
rules
trailer
declarations
PERCENTPERCENT
rules
postlude
{
{
pg_filename
=
""
;
(* filled in by the caller *)
pg_declarations
=
List
.
rev
$
1
;
pg_rules
=
$
3
;
pg_
trailer
=
$
4
pg_
postlude
=
$
4
}
}
trailer
:
postlude
:
EOF
{
None
}
|
PERCENTPERCENT
/*
followed
by
actual
trailer
*/
|
PERCENTPERCENT
/*
followed
by
actual
postlude
*/
{
Some
(
Lazy
.
force
$
1
)
}
/*
-------------------------------------------------------------------------
*/
...
...
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