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
e2db096b
Commit
e2db096b
authored
Nov 23, 2018
by
POTTIER Francois
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow an empty point-free semantic action to contain whitespace.
parent
904c82cc
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
42 additions
and
25 deletions
+42
-25
CHANGES.md
CHANGES.md
+4
-0
src/fancy-parser.mly
src/fancy-parser.mly
+7
-4
src/lexpointfree.mll
src/lexpointfree.mll
+13
-3
src/newRuleSyntax.ml
src/newRuleSyntax.ml
+10
-11
src/parserAux.ml
src/parserAux.ml
+1
-1
src/parserAux.mli
src/parserAux.mli
+3
-2
src/syntax.ml
src/syntax.ml
+4
-4
No files found.
CHANGES.md
View file @
e2db096b
...
@@ -2,6 +2,10 @@
...
@@ -2,6 +2,10 @@
## 2018/11/XX
## 2018/11/XX
*
Relax the syntax of point-free actions to allow
`< >`
(with arbitrary
whitespace inside the angle brackets) instead of just
`<>`
.
(Suggested by Lélio Brun.)
*
When a cycle of
`%inline`
nonterminal symbols is encountered,
*
When a cycle of
`%inline`
nonterminal symbols is encountered,
the error message now shows the entire cycle,
the error message now shows the entire cycle,
as opposed to just one symbol that participates in the cycle.
as opposed to just one symbol that participates in the cycle.
...
...
src/fancy-parser.mly
View file @
e2db096b
...
@@ -69,6 +69,9 @@ let unparenthesize (s : string) : string =
...
@@ -69,6 +69,9 @@ let unparenthesize (s : string) : string =
let
unparenthesize
(
s
:
Stretch
.
t
)
:
Stretch
.
t
=
let
unparenthesize
(
s
:
Stretch
.
t
)
:
Stretch
.
t
=
{
s
with
stretch_content
=
unparenthesize
s
.
stretch_content
}
{
s
with
stretch_content
=
unparenthesize
s
.
stretch_content
}
let
unparenthesize
(
o
:
Stretch
.
t
option
)
:
Stretch
.
t
option
=
Option
.
map
unparenthesize
o
%
}
%
}
/*
-------------------------------------------------------------------------
*/
/*
-------------------------------------------------------------------------
*/
...
@@ -623,12 +626,12 @@ action:
...
@@ -623,12 +626,12 @@ action:
{
XATraditional
action
}
{
XATraditional
action
}
|
action
=
OCAMLTYPE
|
action
=
OCAMLTYPE
{
match
ParserAux
.
validate_pointfree_action
action
with
{
match
ParserAux
.
validate_pointfree_action
action
with
|
Some
s
->
|
o
s
->
XAPointFree
(
unparenthesize
s
)
XAPointFree
(
unparenthesize
o
s
)
|
None
->
|
exception
Lexpointfree
.
InvalidPointFreeAction
->
Error
.
error
[
Positions
.
import
$
loc
]
Error
.
error
[
Positions
.
import
$
loc
]
"A point-free semantic action must consist \
"A point-free semantic action must consist \
of a single OCaml identifier."
of a single OCaml identifier."
(* or whitespace *)
}
}
/*
Patterns
.
*/
/*
Patterns
.
*/
...
...
src/lexpointfree.mll
View file @
e2db096b
...
@@ -11,6 +11,12 @@
...
@@ -11,6 +11,12 @@
(* *)
(* *)
(******************************************************************************)
(******************************************************************************)
{
exception
InvalidPointFreeAction
}
(* See [ParserAux.validate_pointfree_action]. *)
(* See [ParserAux.validate_pointfree_action]. *)
let
lowercase
=
[
'
a'
-
'
z'
'\223'
-
'\246'
'\248'
-
'\255'
'
_'
]
let
lowercase
=
[
'
a'
-
'
z'
'\223'
-
'\246'
'\248'
-
'\255'
'
_'
]
...
@@ -28,13 +34,16 @@ let op =
...
@@ -28,13 +34,16 @@ let op =
let
whitespace
=
[
'
'
'\t'
'\n'
]
let
whitespace
=
[
'
'
'\t'
'\n'
]
rule
valid_pointfree_action
=
parse
rule
valid
ate
_pointfree_action
=
parse
|
whitespace
*
(
lowercase
|
uppercase
|
'
`
'
)
(
identchar
|
'.'
)
*
whitespace
*
eof
|
whitespace
*
(
lowercase
|
uppercase
|
'
`
'
)
(
identchar
|
'.'
)
*
whitespace
*
eof
|
whitespace
*
'
(
'
op
'
)
'
whitespace
*
eof
|
whitespace
*
'
(
'
op
'
)
'
whitespace
*
eof
|
eof
(* We have got a nonempty point-free action: <id>. *)
{
true
}
{
true
}
|
_
|
whitespace
*
eof
(* We have got an empty point-free action: <>. *)
{
false
}
{
false
}
|
_
{
raise
InvalidPointFreeAction
}
(* See [ParserAux.valid_ocaml_identifier]. *)
(* See [ParserAux.valid_ocaml_identifier]. *)
...
@@ -42,4 +51,5 @@ and valid_ocaml_identifier = parse
...
@@ -42,4 +51,5 @@ and valid_ocaml_identifier = parse
|
lowercase
identchar
*
eof
|
lowercase
identchar
*
eof
{
true
}
{
true
}
|
_
|
_
|
eof
{
false
}
{
false
}
src/newRuleSyntax.ml
View file @
e2db096b
...
@@ -11,7 +11,6 @@
...
@@ -11,7 +11,6 @@
(* *)
(* *)
(******************************************************************************)
(******************************************************************************)
open
Stretch
open
Syntax
open
Syntax
(* Because the main function, [NewRuleSyntax.rule], is called by the stage 2
(* Because the main function, [NewRuleSyntax.rule], is called by the stage 2
...
@@ -388,12 +387,15 @@ and production_aux
...
@@ -388,12 +387,15 @@ and production_aux
pr_branch_production_level
=
level
;
pr_branch_production_level
=
level
;
}
}
|
EAction
(
XAPointFree
id
,
prec
)
->
|
EAction
(
XAPointFree
o
id
,
prec
)
->
(* A point-free semantic action, containing
the
OCaml identifier [id]
(* A point-free semantic action, containing
an
OCaml identifier [id]
between angle brackets. This is syntactic sugar for a traditional
between angle brackets. This is syntactic sugar for a traditional
semantic action containing an application of [id] to a tuple of the
semantic action containing an application of [id] to a tuple of the
semantic values that have been assigned a name by the user. *)
semantic values that have been assigned a name by the user. *)
(* As a special case, if [oid] is [None], then we must not build
an application node -- we simply build a tuple. *)
(* [id] is actually a stretch, not just a string, and this matters when
(* [id] is actually a stretch, not just a string, and this matters when
there is an OCaml error (e.g., [id] is undeclared, or ill-typed).
there is an OCaml error (e.g., [id] is undeclared, or ill-typed).
The stretch contains source code location information which allows
The stretch contains source code location information which allows
...
@@ -407,15 +409,12 @@ and production_aux
...
@@ -407,15 +409,12 @@ and production_aux
(* We abuse the abstract syntax of IL and build an application node,
(* We abuse the abstract syntax of IL and build an application node,
regardless of whether [id] a (possibly qualified) value, a (possibly
regardless of whether [id] a (possibly qualified) value, a (possibly
qualified) data constructor, a polymorphic variant constructor, etc. *)
qualified) data constructor, a polymorphic variant constructor, etc. *)
(* As a special case, if [id] is the empty string, then we do not build
an application node. Although it would be correctly printed, doing
this would defeat some IL optimizations and produce redundant [let]
constructs. *)
let
e
=
let
e
=
if
String
.
length
id
.
stretch_raw_content
=
0
then
match
oid
with
tuple
|
Some
id
->
else
IL
.
EApp
(
IL
.
ETextual
id
,
[
tuple
])
IL
.
EApp
(
IL
.
ETextual
id
,
[
tuple
])
|
None
->
tuple
in
in
(* Build a traditional semantic action. *)
(* Build a traditional semantic action. *)
let
action
=
Action
.
from_il_expr
e
in
let
action
=
Action
.
from_il_expr
e
in
...
...
src/parserAux.ml
View file @
e2db096b
...
@@ -127,7 +127,7 @@ let validate_pointfree_action (ty : ocamltype) : Stretch.t option =
...
@@ -127,7 +127,7 @@ let validate_pointfree_action (ty : ocamltype) : Stretch.t option =
assert
false
assert
false
|
Declared
stretch
->
|
Declared
stretch
->
let
s
=
stretch
.
stretch_raw_content
in
let
s
=
stretch
.
stretch_raw_content
in
if
Lexpointfree
.
valid_pointfree_action
(
Lexing
.
from_string
s
)
then
if
Lexpointfree
.
valid
ate
_pointfree_action
(
Lexing
.
from_string
s
)
then
Some
stretch
Some
stretch
else
else
None
None
...
...
src/parserAux.mli
View file @
e2db096b
...
@@ -87,8 +87,9 @@ val override: Positions.t -> 'a option -> 'a option -> 'a option
...
@@ -87,8 +87,9 @@ val override: Positions.t -> 'a option -> 'a option -> 'a option
val
producer_names
:
early_producers
->
identifier
option
array
val
producer_names
:
early_producers
->
identifier
option
array
(* Check that a stretch contains an OCaml lowercase or uppercase identifier,
(* Check that a stretch represents valid content for a point-free semantic
and convert this stretch to a string. The stretch may be empty, too. *)
action, i.e., either just whitespace, or an OCaml lowercase or uppercase
identifier. May raise [Lexpointfree.InvalidPointFreeAction]. *)
val
validate_pointfree_action
:
ocamltype
->
Stretch
.
t
option
val
validate_pointfree_action
:
ocamltype
->
Stretch
.
t
option
...
...
src/syntax.ml
View file @
e2db096b
...
@@ -262,10 +262,10 @@ and symbol_expression =
...
@@ -262,10 +262,10 @@ and symbol_expression =
and
extended_action
=
and
extended_action
=
|
XATraditional
of
raw_action
|
XATraditional
of
raw_action
|
XAPointFree
of
Stretch
.
t
|
XAPointFree
of
Stretch
.
t
option
(* A semantic action is either traditional { ... } or point-free
<id>
.
(* A semantic action is either traditional { ... } or point-free.
In the latter case, [id] is either the empty string or an OCaml
There are two forms of point-free actions, <> and <id>.
identifier. *)
In the latter case, [id] is an OCaml
identifier. *)
type
rule
=
type
rule
=
{
{
...
...
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