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
ac83731e
Commit
ac83731e
authored
Jul 20, 2015
by
POTTIER Francois
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added the options --unused-token <token> and --unused-tokens.
parent
c3c60224
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
50 additions
and
14 deletions
+50
-14
CHANGES
CHANGES
+3
-0
TODO
TODO
+0
-4
doc/macros.tex
doc/macros.tex
+2
-0
doc/main.tex
doc/main.tex
+7
-0
src/partialGrammar.ml
src/partialGrammar.ml
+12
-10
src/settings.ml
src/settings.ml
+16
-0
src/settings.mli
src/settings.mli
+10
-0
No files found.
CHANGES
View file @
ac83731e
2015/07/20:
Added the command line options --unused-token <symbol> and --unused-tokens.
2015/06/29:
2015/06/29:
Changed the treatment of the positional keywords $i. They are now
Changed the treatment of the positional keywords $i. They are now
rewritten into variables of the form '_i' where 'i' is an integer.
rewritten into variables of the form '_i' where 'i' is an integer.
...
...
TODO
View file @
ac83731e
...
@@ -104,10 +104,6 @@
...
@@ -104,10 +104,6 @@
le cours de compilation où on démarre avec une grammaire à trous),
le cours de compilation où on démarre avec une grammaire à trous),
par exemple les non-terminaux inaccessibles
par exemple les non-terminaux inaccessibles
* add a way of turning off the "unused token" warning for a specific token
(or for all of them) This is legitimate because the lexer might be designed
to produce certain tokens that the parser does not use at all.
* move to a new license (GPL V2?), as per Hongbo Zhang's request.
* move to a new license (GPL V2?), as per Hongbo Zhang's request.
* Les fichiers dans demos/ ne devraient pas être sous QPL mais libres...
* Les fichiers dans demos/ ne devraient pas être sous QPL mais libres...
...
...
doc/macros.tex
View file @
ac83731e
...
@@ -109,6 +109,8 @@
...
@@ -109,6 +109,8 @@
\newcommand
{
\oexternaltokens
}{
\texttt
{
-
{}
-external-tokens
}
\xspace
}
\newcommand
{
\oexternaltokens
}{
\texttt
{
-
{}
-external-tokens
}
\xspace
}
\newcommand
{
\ofixedexc
}{
\texttt
{
-
{}
-fixed-exception
}
\xspace
}
\newcommand
{
\ofixedexc
}{
\texttt
{
-
{}
-fixed-exception
}
\xspace
}
\newcommand
{
\ograph
}{
\texttt
{
-
{}
-graph
}
\xspace
}
\newcommand
{
\ograph
}{
\texttt
{
-
{}
-graph
}
\xspace
}
\newcommand
{
\oignoreone
}{
\texttt
{
-
{}
-unused-token
}
\xspace
}
\newcommand
{
\oignoreall
}{
\texttt
{
-
{}
-unused-tokens
}
\xspace
}
\newcommand
{
\oinfer
}{
\texttt
{
-
{}
-infer
}
\xspace
}
\newcommand
{
\oinfer
}{
\texttt
{
-
{}
-infer
}
\xspace
}
\newcommand
{
\ointerpret
}{
\texttt
{
-
{}
-interpret
}
\xspace
}
\newcommand
{
\ointerpret
}{
\texttt
{
-
{}
-interpret
}
\xspace
}
\newcommand
{
\ointerpretshowcst
}{
\texttt
{
-
{}
-interpret-show-cst
}
\xspace
}
\newcommand
{
\ointerpretshowcst
}{
\texttt
{
-
{}
-interpret-show-cst
}
\xspace
}
...
...
doc/main.tex
View file @
ac83731e
...
@@ -156,6 +156,13 @@ vertices are the grammar's nonterminal symbols. There is a directed edge from
...
@@ -156,6 +156,13 @@ vertices are the grammar's nonterminal symbols. There is a directed edge from
vertex
$
A
$
to vertex
$
B
$
if the definition of
$
A
$
refers to
$
B
$
. The file is
vertex
$
A
$
to vertex
$
B
$
if the definition of
$
A
$
refers to
$
B
$
. The file is
in a format that is suitable for processing by the
\emph
{
graphviz
}
toolkit.
in a format that is suitable for processing by the
\emph
{
graphviz
}
toolkit.
\docswitch
{
\oignoreone
\nt
{
symbol
}}
This switch suppresses the warning that
is normally emitted when
\menhir
finds that the terminal symbol
\nt
{
symbol
}
is
unused.
\docswitch
{
\oignoreall
}
This switch suppresses all of the warnings that are
normally emitted when
\menhir
finds that some terminal symbols are unused.
\docswitch
{
\oinfer
}
This switch causes the semantic actions to be checked for
\docswitch
{
\oinfer
}
This switch causes the semantic actions to be checked for
type consistency
\emph
{
before
}
the parser is generated. This is done by
type consistency
\emph
{
before
}
the parser is generated. This is done by
invoking the
\ocaml
compiler. Use of
\oinfer
is
\textbf
{
strongly recommended
}
,
invoking the
\ocaml
compiler. Use of
\oinfer
is
\textbf
{
strongly recommended
}
,
...
...
src/partialGrammar.ml
View file @
ac83731e
...
@@ -717,13 +717,15 @@ let check_parameterized_grammar_is_well_defined grammar =
...
@@ -717,13 +717,15 @@ let check_parameterized_grammar_is_well_defined grammar =
)
grammar
.
p_rules
;
)
grammar
.
p_rules
;
(* Check that every token is used. *)
(* Check that every token is used. *)
begin
match
Settings
.
token_type_mode
with
if
not
Settings
.
ignore_all_unused_tokens
then
begin
match
Settings
.
token_type_mode
with
|
Settings
.
TokenTypeOnly
->
|
Settings
.
TokenTypeOnly
->
()
()
|
Settings
.
TokenTypeAndCode
|
Settings
.
TokenTypeAndCode
|
Settings
.
CodeOnly
_
->
|
Settings
.
CodeOnly
_
->
StringMap
.
iter
(
fun
token
{
tk_position
=
p
}
->
StringMap
.
iter
(
fun
token
{
tk_position
=
p
}
->
if
not
(
StringSet
.
mem
token
!
used_tokens
)
then
if
not
(
StringSet
.
mem
token
!
used_tokens
||
StringSet
.
mem
token
Settings
.
ignored_unused_tokens
)
then
Error
.
warning
[
p
]
Error
.
warning
[
p
]
(
Printf
.
sprintf
"the token %s is unused."
token
)
(
Printf
.
sprintf
"the token %s is unused."
token
)
)
grammar
.
p_tokens
)
grammar
.
p_tokens
...
...
src/settings.ml
View file @
ac83731e
...
@@ -159,6 +159,15 @@ type suggestion =
...
@@ -159,6 +159,15 @@ type suggestion =
let
suggestion
=
let
suggestion
=
ref
SuggestNothing
ref
SuggestNothing
let
ignored_unused_tokens
=
ref
StringSet
.
empty
let
ignore_unused_token
t
=
ignored_unused_tokens
:=
StringSet
.
add
t
!
ignored_unused_tokens
let
ignore_all_unused_tokens
=
ref
false
let
options
=
Arg
.
align
[
let
options
=
Arg
.
align
[
"--base"
,
Arg
.
Set_string
base
,
"<basename> Specifies a base name for the output file(s)"
;
"--base"
,
Arg
.
Set_string
base
,
"<basename> Specifies a base name for the output file(s)"
;
"--canonical"
,
Arg
.
Unit
(
fun
()
->
construction_mode
:=
ModeCanonical
)
,
" Construct a canonical Knuth LR(1) automaton"
;
"--canonical"
,
Arg
.
Unit
(
fun
()
->
construction_mode
:=
ModeCanonical
)
,
" Construct a canonical Knuth LR(1) automaton"
;
...
@@ -208,6 +217,8 @@ let options = Arg.align [
...
@@ -208,6 +217,8 @@ let options = Arg.align [
"--table"
,
Arg
.
Set
table
,
" Use the table-based back-end"
;
"--table"
,
Arg
.
Set
table
,
" Use the table-based back-end"
;
"--timings"
,
Arg
.
Set
timings
,
" Display internal timings"
;
"--timings"
,
Arg
.
Set
timings
,
" Display internal timings"
;
"--trace"
,
Arg
.
Set
trace
,
" Include tracing instructions in the generated code"
;
"--trace"
,
Arg
.
Set
trace
,
" Include tracing instructions in the generated code"
;
"--unused-token"
,
Arg
.
String
ignore_unused_token
,
"<token> Do not warn that <token> is unused"
;
"--unused-tokens"
,
Arg
.
Set
ignore_all_unused_tokens
,
" Do not warn about any unused token"
;
"--version"
,
Arg
.
Set
version
,
" Show version number and exit"
;
"--version"
,
Arg
.
Set
version
,
" Show version number and exit"
;
"-b"
,
Arg
.
Set_string
base
,
"<basename> Synonymous with --base <basename>"
;
"-b"
,
Arg
.
Set_string
base
,
"<basename> Synonymous with --base <basename>"
;
"-lg"
,
Arg
.
Set_int
logG
,
" Synonymous with --log-grammar"
;
"-lg"
,
Arg
.
Set_int
logG
,
" Synonymous with --log-grammar"
;
...
@@ -389,3 +400,8 @@ let strict =
...
@@ -389,3 +400,8 @@ let strict =
let
fixedexc
=
let
fixedexc
=
!
fixedexc
!
fixedexc
let
ignored_unused_tokens
=
!
ignored_unused_tokens
let
ignore_all_unused_tokens
=
!
ignore_all_unused_tokens
src/settings.mli
View file @
ac83731e
...
@@ -163,3 +163,13 @@ val strict: bool
...
@@ -163,3 +163,13 @@ val strict: bool
val
fixedexc
:
bool
val
fixedexc
:
bool
(* This is a set of tokens which may be unused and about which we should not
emit a warning. *)
val
ignored_unused_tokens
:
StringSet
.
t
(* This flag supersedes the set [ignored_unused_tokens]. If it is set, then
we should not emit a warning about any unused tokens. *)
val
ignore_all_unused_tokens
:
bool
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