#!/usr/local/bin/awk -f # # Copyright (c) 1995, 1996 Gunther Schadow. All rights reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. BEGIN{ print ARGV[1] > "/dev/stderr" if (ARGV[1]=="-s") { FS="( +)| "; ARGV[1]=""; } else FS=" "; # Grammar definition for placement of commata. or="|"; ATOM = "[A-Za-z0-9]+" OPEN = "[(\[\{]+" CLOSE = "[)\]\}]+" TOKEN = ATOM or OPEN or CLOSE NIL="''"; event=NIL; } # Print error message and abort # function error(msg, obj) { printf("e:%s,%d at `%s': %s\n", FILENAME, FNR, obj, msg) > "/dev/stderr" ; ERROR=1 ; exit 3 ; } function warning(msg, obj) { printf("w:%s,%d at `%s': %s\n", FILENAME, FNR, obj, msg) > "/dev/stderr" ; } $0~"\\(Event Code [A-Z][A-Z0-9][A-Z0-9]\\)" { event=$0 gsub("^.*Event Code ","",event); gsub("\\).*$","",event); event=tolower(event); } $0~"\\(Trigger Event [A-Z][A-Z0-9][A-Z0-9]\\)" { event=$0 gsub("^.*Trigger Event ","",event); gsub("\\).*$","",event); event=tolower(event); } FNR==1 { # descriptive header printf("\n%% exmsg.awk output from `%s', %s\n%%\n", \ FILENAME, \ strftime("%D %T",systime())); } $1~"^[A-Z][A-Z][A-Z]" && ($0~"Chapter[ ]*$" || $0~"Appendix[ ]*$") { MESSAGE=1; name=$0; descr=$0; gsub("^[A-Z][A-Z][A-Z][ ]+","",descr); split(name,naml," "); name=tolower(naml[1]); descr=tolower(descr); gsub("[ ]+appendix[ ]*$","",descr); gsub("[ ]+chapter[ ]*$","",descr); printf("message(%s,%s,\"%s\",\n [", name, event, descr); WAS_OPEN=1; event=NIL; next; } MESSAGE && $0!~"^[ ]*$" && $0!~"Figure [IV]+-[0-9]+." { theline=$0; gsub("^[ [{]*Any","ANY",theline); gsub("[A-Za-z][a-z].*","",theline); gsub("[A-Z][A-Z][A-Z][A-Z].*","",theline); gsub("[ ]*","",theline); gsub("\\[","opt(",theline); gsub("\\]",")",theline); gsub("\\{","rep(",theline); gsub("\\}",")",theline); theline=tolower(theline); if(!WAS_OPEN && (theline!~"^\\)") && (theline!="")) COMMA=", " else COMMA=""; WAS_OPEN=(theline~"\\($"); printf("%s%s", COMMA, theline); next; } MESSAGE { MESSAGE=0; printf("]).\n"); next; } 1 { next; }