X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/7d424de14c0385012d328642bec6874c8e6cef17..2191bb749b8f63b6037ca7e590ae499d0bb26db9:/examples/extexi diff --git a/examples/extexi b/examples/extexi index 31083927..7ede7c4b 100644 --- a/examples/extexi +++ b/examples/extexi @@ -2,7 +2,7 @@ # This file is part of GNU Bison -# Copyright (C) 1992, 2000, 2001, 2005, 2006, 2009, 2010 Free Software +# Copyright (C) 1992, 2000-2001, 2005-2006, 2009-2012 Free Software # Foundation, Inc. # # This program is free software: you can redistribute it and/or modify @@ -29,7 +29,7 @@ BEGIN { if (ARGV[argc] == "--") break; for (i = argc + 1; i < ARGC; ++i) - file_wanted[ARGV[i]] = 1; + file_wanted[basename(ARGV[i])] = ARGV[i]; ARGC = argc; } @@ -43,20 +43,17 @@ BEGIN { } /^@comment file: / { - if (!file_wanted[$3]) - message("ignoring " $3); + if (file = file_wanted[$3]) + message(" GEN " file); else - { - message("extracting " $3); - file = $3; - } + message("SKIP " $3); } -/^@example$/, /^@end example$/ { +/^@(small)?example$/, /^@end (small)?example$/ { if (!file) next; - if ($0 ~ /^@example$/) + if ($0 ~ /^@(small)?example$/) { input = files_output[file] ? "\n" : ""; @@ -65,23 +62,23 @@ BEGIN { # => + 2. # Note that recent Bison support it, but not Flex. if (file ~ /\.[chy]*$/) - input = "#line " (FNR + 1) " \"" FILENAME "\"\n"; + input = "#line " (FNR + 1) " \"" FILENAME "\"\n"; next; } - if ($0 ~ /^@end example$/) + if ($0 ~ /^@end (small)?example$/) { if (input == "") - fatal("no contents: " file); + fatal("no contents: " file); input = normalize(input); # No spurious end of line: use printf. if (files_output[file]) - # The parens around the output file seem to be required + # The parens around the output file seem to be required # by awk on Mac OS X Tiger (darwin 8.4.6). printf ("%s", input) >> (output_dir "/" file); else - printf ("%s", input) > (output_dir "/" file); + printf ("%s", input) > (output_dir "/" file); close (output_dir "/" file); files_output[file] = 1; @@ -105,11 +102,11 @@ function normalize(contents, i, lines, n, line, res) { # Whole line commands. if (line ~ /^@(c |comment|dots|end (ignore|group)|ignore|group)/) - # Gperf accepts empty lines as valid input!!! - if (file ~ /\.gperf$/) - continue; - else - line = ""; + # Gperf accepts empty lines as valid input!!! + if (file ~ /\.gperf$/) + continue; + else + line = ""; gsub (/"@value\{VERSION\}"/, "\"" VERSION "\"", line) gsub (/^@result\{\}/, "", line); @@ -125,6 +122,11 @@ function normalize(contents, i, lines, n, line, res) { } +function basename(name, a, n) { + n = split (name, a, "/"); + return a[n]; +} + function message(msg) { if (! message_printed[msg]) {