]> hydra-www.ietfng.org Git - grade/commitdiff
Add !... section types to omit from skeleton
authorNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Mon, 16 Feb 2015 06:00:21 +0000 (01:00 -0500)
committerNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Wed, 18 Feb 2015 00:53:42 +0000 (19:53 -0500)
README.rst
grade.pl [changed mode: 0644->0755]
make-skeleton.pl

index 5c1f34608f1cef3a3a921eefe602571b9c02cd21..9f875355cfceefabe4787753c989e74817af2a83 100644 (file)
@@ -143,7 +143,9 @@ where
   not contain whitespace.
 
 * ``type`` indicates to the ``grade.pl`` script how to interpret this
-  section.
+  section.  If ``type`` begins with ``!``, the section will be omitted
+  from the generated skeleton and this initial ``!`` will be stripped
+  from the type before consulting the following choices.
 
   * Type ``0`` defines a section of define flags whose invoked scores are
     simply summed.  ``extra`` is ignored for this type.  This is the only
old mode 100644 (file)
new mode 100755 (executable)
index c5c92d1..45551ec
--- a/grade.pl
+++ b/grade.pl
@@ -67,6 +67,7 @@ sub findDefinesSection($) { # {{{
       my $secargs = $1;
       if ($secargs =~ /^(\S+)\s+(\S+)\s+(\S+)\s+(.*)$/) {
         ($secty, $secmax, $secextra, $secname) = ($1,$2,$3,$4);
+        $secty =~ s/^!//;      # strip no-skeleton directive
       } else { die "Malformed section line"; }
       return;
     }
index 9226b8b1cdce29c036fe1df645f6dd098bb9b531..ecacca35b133c3ba2ae75ac9d69da6cb4bdc3689 100755 (executable)
@@ -8,6 +8,7 @@ use strict;
 use warnings;
 
 my $section = undef;
+my $skipsec = 0;
 
 sub comments() {
   print "\n\$BEGIN_COMMENTS\n\n\$END_COMMENTS\n\n";
@@ -17,23 +18,25 @@ while(my $line = <STDIN>) {
   chomp $line;
 
   # @section directive?
-  if ($line =~ /^@(\S+)\s/) {
-    comments() if defined $section;
+  if ($line =~ /^@(\S+)\s+(\S+)\s+/) {
+    comments() if defined $section and not $skipsec;
     $section = $1;
+    $skipsec = 0;
+    if ($2 =~ /^!/) { $skipsec = 1; next; }
     print "\@$section\n";
   }
 
   # :define directive?
   elsif ($line =~ /^(:\S+)\s+/) {
     die "Directive not within section" if not defined $section;
-    print "#$1\n";
+    print "#$1\n" if not $skipsec;
     while (my $cline = <STDIN>) { chomp $cline; last if $cline eq "."; }
   }
 
   # "#..." and not "#!..." get passed to template
   elsif ($line =~ /^\s*#/) {
     if ($line !~ /^\s*#!/) {
-      print "$line\n";
+      print "$line\n" if not $skipsec;
     }
   }
 
@@ -43,4 +46,4 @@ while(my $line = <STDIN>) {
 }
 
 die "No sections encountered" if not defined $section;
-comments();
+comments() if not $skipsec;