bob@acornrc.UUCP (Bob Weissman) (06/18/88)
Does anyone have a filter which will raise all Modula-2 keywords to uppercase? I've just acquired a bunch of code which was obviously meant for some bizarre compiler which accepts keywords in lowercase. I'd rather avoid reinventing this wheel if someone has already done it. Thanks, -- Bob Weissman Internet: bob@acornrc.uucp UUCP: ...!{ ames | decwrl | oliveb | pyramid }!acornrc!bob Arpanet: bob%acornrc.uucp@ames.arc.nasa.gov
sullivan@marge.math.binghamton.edu (fred sullivan) (06/19/88)
In article <898@acornrc.UUCP> bob@acornrc.UUCP (Bob Weissman) writes: >Does anyone have a filter which will raise all Modula-2 keywords to >uppercase? I've just acquired a bunch of code which was obviously >meant for some bizarre compiler which accepts keywords in lowercase. > Here is a lex filter. I thought someone else might be interested so I'm posting it. (If you're not using a Unix system you're out of luck, but that goes without saying.) Run it through lex to produce lex.yy.c, and compile with -ll. Any word which is the same as a reserved word except for case is changed to uppercase, except for words appearing in strings or comments (nested comments are ok). E.g. "tYPe" becomes "TYPE". I usually use this to filter the buffer in Emacs. -- cut here -- a [aA] b [bB] c [cC] d [dD] e [eE] f [fF] g [gG] h [hH] i [iI] j [jJ] k [kK] l [lL] m [mM] n [nN] o [oO] p [pP] q [qQ] r [rR] s [sS] t [tT] u [uU] v [vV] w [wW] x [xX] y [yY] z [zZ] int commentlevel; %START OTHER COMMENT STRING DSTRING %a 2200 %o 2500 %% <OTHER>{a}{b}{s} printf("ABS"); <OTHER>{a}{n}{d} printf("AND"); <OTHER>{a}{r}{r}{a}{y} printf("ARRAY"); <OTHER>{b}{e}{g}{i}{n} printf("BEGIN"); <OTHER>{b}{i}{t}{s}{e}{t} printf("BITSET"); <OTHER>{b}{o}{o}{l}{e}{a}{n} printf("BOOLEAN"); <OTHER>{b}{y} printf("BY"); <OTHER>{c}{a}{p} printf("CAP"); <OTHER>{c}{a}{r}{d}{i}{n}{a}{l} printf("CARDINAL"); <OTHER>{c}{a}{s}{e} printf("CASE"); <OTHER>{c}{h}{a}{r} printf("CHAR"); <OTHER>{c}{h}{r} printf("CHR"); <OTHER>{c}{o}{n}{s}{t} printf("CONST"); <OTHER>{d}{e}{c} printf("DEC"); <OTHER>{d}{e}{f}{i}{n}{i}{t}{i}{o}{n} printf("DEFINITION"); <OTHER>{d}{i}{s}{p}{o}{s}{e} printf("DISPOSE"); <OTHER>{d}{i}{v} printf("DIV"); <OTHER>{d}{o} printf("DO"); <OTHER>{e}{l}{s}{e} printf("ELSE"); <OTHER>{e}{l}{s}{i}{f} printf("ELSIF"); <OTHER>{e}{n}{d} printf("END"); <OTHER>{e}{x}{c}{l} printf("EXCL"); <OTHER>{e}{x}{i}{t} printf("EXIT"); <OTHER>{e}{x}{p}{o}{r}{t} printf("EXPORT"); <OTHER>{f}{a}{l}{s}{e} printf("FALSE"); <OTHER>{f}{l}{o}{a}{t} printf("FLOAT"); <OTHER>{f}{o}{r} printf("FOR"); <OTHER>{f}{r}{o}{m} printf("FROM"); <OTHER>{h}{a}{l}{t} printf("HALT"); <OTHER>{h}{i}{g}{h} printf("HIGH"); <OTHER>{i}{f} printf("IF"); <OTHER>{i}{m}{p}{l}{e}{m}{e}{n}{t}{a}{t}{i}{o}{n} printf("IMPLEMENTATION"); <OTHER>{i}{m}{p}{o}{r}{t} printf("IMPORT"); <OTHER>{i}{n} printf("IN"); <OTHER>{i}{n}{c} printf("INC"); <OTHER>{i}{n}{c}{l} printf("INCL"); <OTHER>{i}{n}{t}{e}{g}{e}{r} printf("INTEGER"); <OTHER>{l}{o}{o}{p} printf("LOOP"); <OTHER>{m}{o}{d} printf("MOD"); <OTHER>{m}{o}{d}{u}{l}{e} printf("MODULE"); <OTHER>{n}{e}{w} printf("NEW"); <OTHER>{n}{i}{l} printf("NIL"); <OTHER>{n}{o}{t} printf("NOT"); <OTHER>{o}{d}{d} printf("ODD"); <OTHER>{o}{f} printf("OF"); <OTHER>{o}{r} printf("OR"); <OTHER>{o}{r}{d} printf("ORD"); <OTHER>{p}{o}{i}{n}{t}{e}{r} printf("POINTER"); <OTHER>{p}{r}{o}{c} printf("PROC"); <OTHER>{p}{r}{o}{c}{e}{d}{u}{r}{e} printf("PROCEDURE"); <OTHER>{q}{u}{a}{l}{i}{f}{i}{e}{d} printf("QUALIFIED"); <OTHER>{r}{e}{a}{l} printf("REAL"); <OTHER>{r}{e}{c}{o}{r}{d} printf("RECORD"); <OTHER>{r}{e}{p}{e}{a}{t} printf("REPEAT"); <OTHER>{r}{e}{t}{u}{r}{n} printf("RETURN"); <OTHER>{s}{e}{t} printf("SET"); <OTHER>{t}{h}{e}{n} printf("THEN"); <OTHER>{t}{o} printf("TO"); <OTHER>{t}{r}{u}{e} printf("TRUE"); <OTHER>{t}{r}{u}{n}{c} printf("TRUNC"); <OTHER>{t}{y}{p}{e} printf("TYPE"); <OTHER>{u}{n}{t}{i}{l} printf("UNTIL"); <OTHER>{v}{a}{l} printf("VAL"); <OTHER>{v}{a}{r} printf("VAR"); <OTHER>{w}{h}{i}{l}{e} printf("WHILE"); <OTHER>{w}{i}{t}{h} printf("WITH"); <OTHER>[a-zA-Z][a-zA-Z0-9]* ECHO; <OTHER>\(\* { ECHO; commentlevel = 1; BEGIN COMMENT; } <COMMENT>\*\) { ECHO; if (--commentlevel == 0) BEGIN OTHER; } <COMMENT>\(\* { ECHO; ++commentlevel; } <OTHER>\" { ECHO; BEGIN DSTRING; } <DSTRING>\" { ECHO; BEGIN OTHER; } <OTHER>\' { ECHO; BEGIN STRING; } <STRING>\' { ECHO; BEGIN OTHER; } %% main() { BEGIN OTHER; while (yylex()); } -- all done -- Fred Sullivan SUNY at Binghamton Dept. Math. Sciences Binghamton, NY 13903 sullivan@marge.math.binghamton.edu First you make a roux!
jfh@rpp386.UUCP (John F. Haugh II) (06/20/88)
In article <898@acornrc.UUCP> bob@acornrc.UUCP (Bob Weissman) writes:
]Does anyone have a filter which will raise all Modula-2 keywords to
]uppercase? I've just acquired a bunch of code which was obviously
]meant for some bizarre compiler which accepts keywords in lowercase.
this should be quite simple in lex. if you don't get a version, could
you post your solution to the net???
- john.
--
John F. Haugh II +--------- Cute Chemistry Quote ---------
River Parishes Programming | "If you aren't part of the solution,
UUCP: killer!rpp386!jfh | you are part of the precipitate."
DOMAIN: jfh@rpp386.uucp | -- Some FORTUNE program
aplusl@ethz.UUCP (Albert Meier) (06/28/88)
Expires: References: <898@acornrc.UUCP> Sender: Reply-To: aplusl@bernina.UUCP (Albert Meier) Followup-To: Distribution: Organization: ETH Zuerich, Switzerland Keywords: Compiler Generator, Transformation, Scanner Generator, Parser Generator In article <898@acornrc.UUCP> bob@acornrc.UUCP (Bob Weissman) writes: >Does anyone have a filter which will raise all Modula-2 keywords to >uppercase? I've just acquired a bunch of code which was obviously >meant for some bizarre compiler which accepts keywords in lowercase. > >I'd rather avoid reinventing this wheel if someone has already done >it. > >Thanks, > We don't have a tool that directly converts what you need but a more powerful one. We are working with a scanner/parser generator called Coco from Peter Moessenboeck. We think you can perfectly use it for this purpose. As far as we have heard the english description "Coco a Compiler Generator for Microcomputers" will soon be available from Prentice-Hall. At the moment it is only available in german from Hanser-Verlag, Munich. Coco is sold as a product but there is a special offer for universities and schools. They get it for a minimal cost from University of Linz Institute for Software Altenbergerstrasse 69 A-4040 Linz (Austria) We have prepared some kind of demonstration disk for Coco (parser) and Alex (scanner) with some english documentation. It includes the full software in object form but with the only restriction of 32 terminals. We think that this should be enough to resolve the problem mentioned. This disk is public domain and you can directly get it from us or from Interface Technologies Corp., 3336 Richmond, Suite 323, Houston TX 77098-9990 if you live in USA. The demo disk runs on M2SDS (PC) but Coco/Alex is also available for TaylorModula-2 and runs also on Atari (TDI), MacIntosh (MacMETH) and even on Turbo-Pascal (producing Modula-2 source code of course!). We've been told that there will soon be a version running on M2/370, our Modula-2 compiler on IBM /370 mainframes (VM and MVS). We hope you can find the solution of your problem this way. ..... .. .... Albert Meier Tel. +41/1/700 30 37 .. .... A+L AG, Im Spaeten 23, CH-8906 Bonstetten .......A+L. .. ....... E-Mail aplusl@komsys.ifi.ethz.ch.UUCP
hjm@cernvax.UUCP (hjm) (07/05/88)
In article <898@acornrc.UUCP> bob@acornrc.UUCP (Bob Weissman) writes: >Does anyone have a filter which will raise all Modula-2 keywords to >uppercase? I've just acquired a bunch of code which was obviously >meant for some bizarre compiler which accepts keywords in lowercase. I must confess to liking Modula-2, but I must also confess to disliking intensely any language which dictates coding style, namely where to use upper-case and where to use lower-case letters. The last language which did that was FORTRAN-77, which probably isn't very popular with people who subscribe to this newsgroup. Is this case restriction (which is, after all, entirely arbitary and without any valid engineering backing) in the standard? If so, I hope that there will be lots of 'bizarre compilers' available for people like me who prefer to choose for themselves. After all, CaSe SENsItiViTy Is a bORE ... Hubert Matthews