diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2008-10-21 07:00:00 -0700 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2008-10-21 07:00:00 -0700 |
commit | 9364f22aed35e1a1e9d07c121510f80be3ab0502 (patch) | |
tree | d49911209b132da58d838efa852daf28d516df21 /WebKitTools/android/flex-2.5.4a/MISC/debflex.awk | |
parent | 87eb0cb35bad8784770ebc807e6c982432e47107 (diff) | |
download | external_webkit-9364f22aed35e1a1e9d07c121510f80be3ab0502.zip external_webkit-9364f22aed35e1a1e9d07c121510f80be3ab0502.tar.gz external_webkit-9364f22aed35e1a1e9d07c121510f80be3ab0502.tar.bz2 |
Initial Contribution
Diffstat (limited to 'WebKitTools/android/flex-2.5.4a/MISC/debflex.awk')
-rw-r--r-- | WebKitTools/android/flex-2.5.4a/MISC/debflex.awk | 119 |
1 files changed, 119 insertions, 0 deletions
diff --git a/WebKitTools/android/flex-2.5.4a/MISC/debflex.awk b/WebKitTools/android/flex-2.5.4a/MISC/debflex.awk new file mode 100644 index 0000000..b1eda49 --- /dev/null +++ b/WebKitTools/android/flex-2.5.4a/MISC/debflex.awk @@ -0,0 +1,119 @@ +# Clarify the flex debug trace by substituting first line of each rule. +# Francois Pinard <pinard@iro.umontreal.ca>, July 1990. +# +# Rewritten to process correctly \n's in scanner input. +# BEGIN section modified to correct a collection of rules. +# Michal Jaegermann <michal@phys.ualberta.ca>, December 1993 +# +# Sample usage: +# flex -d PROGRAM.l +# gcc -o PROGRAM PROGRAM.c -lfl +# PROGRAM 2>&1 | gawk -f debflex.awk PROGRAM.l +# +# (VP's note: this script presently does not work with either "old" or +# "new" awk; fixes so it does will be welcome) + +BEGIN { + # Insure proper usage. + + if (ARGC != 2) { + print "usage: gawk -f debflex.awk FLEX_SOURCE <DEBUG_OUTPUT"; + exit (1); + } + + # Remove and save the name of flex source. + + source = ARGV[1]; + ARGC--; + + # Swallow the flex source file. + + line = 0; + section = 1; + while (getline <source) { + + # Count the lines. + + line++; + + # Count the sections. When encountering section 3, + # break out of the awk BEGIN block. + + if (match ($0, /^%%/)) { + section++; + if (section == 3) { + break; + } + } + else { + # Only the lines in section 2 which do not begin in a + # tab or space might be referred to by the flex debug + # trace. Save only those lines. + + if (section == 2 && match ($0, /^[^ \t]/)) { + rules[line] = $0; + } + } + } + dashes = "-----------------------------------------------------------"; + collect = ""; + line = 0; +} + +# collect complete rule output from a scanner +$0 !~ /^--/ { + collect = collect "\n" $0; + next; +} +# otherwise we have a new rule - process what we got so far +{ + process(); +} +# and the same thing if we hit EOF +END { + process(); +} + +function process() { + + # splitting this way we loose some double dashes and + # left parentheses from echoed input - a small price to pay + n = split(collect, field, "\n--|[(]"); + + # this loop kicks in only when we already collected something + for (i = 1; i <= n; i++) { + if (0 != line) { + # we do not care for traces of newlines. + if (0 == match(field[i], /\"\n+\"[)]/)) { + if (rules[line]) { + text = field[i]; + while ( ++i <= n) { + text = text field[i]; + } + printf("%s:%d: %-8s -- %s\n", + source, line, text, rules[line]); + } + else { + print; + printf "%s:%d: *** No such rule.\n", source, line; + } + } + line = 0; + break; + } + if ("" != field[i]) { + if ("end of buffer or a NUL)" == field[i]) { + print dashes; # Simplify trace of buffer reloads + continue; + } + if (match(field[i], /accepting rule at line /)) { + # force interpretation of line as a number + line = 0 + substr(field[i], RLENGTH); + continue; + } + # echo everything else + printf("--%s\n", field[i]); + } + } + collect = "\n" $0; # ... and start next trace +} |