Skip to content

Commit

Permalink
- Added the -C command-line switch, which checks the syntax of a pr…
Browse files Browse the repository at this point in the history
…ogram only.
  • Loading branch information
trizen committed Jul 15, 2015
1 parent f902781 commit a5332b0
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions bin/sidef
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ sub NATIVE () { 2 }
my %args;
if ($#ARGV != -1 and chr ord $ARGV[0] eq '-') {
require Getopt::Std;
Getopt::Std::getopts('e:E:d:Dho:ivHN:n:WwbcM:rR:tO:s:', \%args);
Getopt::Std::getopts('e:E:d:Dho:ivHN:n:WwbcM:rR:tO:s:C', \%args);
}

# Help
Expand Down Expand Up @@ -208,6 +208,11 @@ else {
}
}

# Check the syntax
elsif (defined $args{C}) {
say "$script_name syntax OK";
}

# Execute the struct
else {
if ($is_perl_code) {
Expand Down Expand Up @@ -340,7 +345,8 @@ sub output_usage {
'-i' => 'interactive mode',
'-b' => 'bundle the code as a stand-alone perl program',
'-c' => 'compile the code as a stand-alone perl program',
'-d dumped_file' => 'execute a syntax tree dumped file',
'-C' => 'check syntax only',
'-d ast_file' => 'load a dumped syntax tree',
'-D' => 'dump the syntax tree of a program',
'-o output_file' => 'file where to dump the output',
'-E program' => 'one line of program',
Expand All @@ -352,8 +358,8 @@ sub output_usage {
'-s int' => 'the number of spaces used in code indentation',
'-v' => 'print version number and exit',
'-t' => 'treat all command-line arguments as scripts',
'-r' => 'deparse a Sidef program',
'-R lang' => ['deparse a Sidef program to a given language', 'valid values: sidef, perl'],
'-r' => 'parse and deparse a Sidef program',
'-R lang' => ['parse and deparse a Sidef program to a given language', 'valid values: sidef, perl'],
'-w' => 'enable warnings with stack backtrace',
'-W' => 'make warnings fatal (with stack backtrace)',
);
Expand Down Expand Up @@ -773,7 +779,7 @@ HEAD

close $fh;
}
}
}
} => $path
);

Expand Down

0 comments on commit a5332b0

Please sign in to comment.