Structurize option parser (#2809)

Add V3OptionsParser that can suggest correct option.


Co-authored-by: Wilson Snyder <wsnyder@wsnyder.org>
Co-authored-by: github action <action@example.com>
This commit is contained in:
Yutetsu TAKATSUKASA 2021-03-26 22:48:24 +09:00 committed by GitHub
parent 7ea014dab5
commit 4e41c13501
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 851 additions and 664 deletions

File diff suppressed because it is too large Load Diff

View File

@ -371,8 +371,6 @@ private:
void optimize(int level);
void showVersion(bool verbose);
void coverage(bool flag) { m_coverageLine = m_coverageToggle = m_coverageUser = flag; }
static bool onoff(const char* sw, const char* arg, bool& flag);
static bool onoffb(const char* sw, const char* arg, VOptionBool& flagr);
static bool suffixed(const string& sw, const char* arg);
static string parseFileArg(const string& optdir, const string& relfilename);
bool parseLangExt(const char* swp, const char* langswp, const V3LangCode& lc);

View File

@ -0,0 +1,11 @@
%Error: Invalid option: -ccc... Suggested alternative: '-cc'
%Error: Invalid option: --ccc... Suggested alternative: '-cc'
%Error: Invalid option: -no-asserT... Suggested alternative: '-no-assert'
%Error: Invalid option: -noasserT... Suggested alternative: '-no-assert'
%Error: Invalid option: -asserT... Suggested alternative: '-assert'
%Error: Invalid option: +definE+A=B... Suggested alternative: '+define+'
%Error: Invalid option: -CFLAGs... Suggested alternative: '-CFLAGS'
%Error: Invalid option: -debug-aborT
%Error: Invalid option: -Won-SPLITVAR... Suggested alternative: '-Wno-SPLITVAR'
%Error: Unknown warning specified: -Wno-SPLITVER... Suggested alternative: '-Wno-SPLITVAR'
%Error: Unknown language specified: 1364-1997... Suggested alternative: '1364-1995'

View File

@ -0,0 +1,51 @@
#!/usr/bin/env perl
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
#
# Copyright 2008 by Wilson Snyder. This program is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
scenarios(vlt => 1);
my @opts;
# Typo
push @opts, "-ccc";
# Typo of an option that starts with "--"
push @opts, "--ccc";
# Typo of an option that starts with "-no-"
push @opts, "-no-asserT";
# Typo of an option that starts with "-no"
push @opts, "-noasserT";
# Typo of an option that allows "-no"
push @opts, "-asserT";
# Typo of an option that starts with '+'
push @opts, "+definE+A=B";
# Typo that takes arg
push @opts, "-CFLAGs -ggdb";
# Typo of an undocumented option
push @opts, "-debug-aborT";
# Typo of "-Wno" for partial match
push @opts, "-Won-SPLITVAR";
# Typo after -Wno- for partial match
push @opts, "-Wno-SPLITVER";
# Typo of -language
push @opts, "-language 1364-1997";
my $cmd = "";
foreach my $var (@opts) {
$cmd = $cmd . $ENV{VERILATOR_ROOT} . "/bin/verilator ${var}; ";
}
run(cmd => [$cmd],
verilator_run => 1,
logfile => "$Self->{obj_dir}/sim.log",
fails => 1,
expect_filename => $Self->{golden_filename},
);
ok(1);
1;