From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,f5dbc8f688419657 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1994-12-02 13:36:21 PST Path: bga.com!news.sprintlink.net!howland.reston.ans.net!europa.eng.gtefsd.com!news.umbc.edu!eff!blanket.mitre.org!linus.mitre.org!linus!mbunix!emery From: emery@goldfinger.mitre.org (David Emery) Newsgroups: comp.lang.ada Subject: Ada formatter for MS-Word Date: 2 Dec 94 14:55:07 Organization: The Mitre Corp., Bedford, MA. Distribution: world Message-ID: References: <3bl980$jvs@pong.lasc.lockheed.com> <3bn9f6$8hl@cliffy.lfwc.lockheed.com> NNTP-Posting-Host: goldfinger.mitre.org In-reply-to: l107353@cliffy.lfwc.lockheed.com's message of 2 Dec 1994 14:03:18 GMT Date: 1994-12-02T14:55:07+00:00 List-Id: Here are two files for C and Lex. Run the second through Lex, and then compile with the first. Pipe Ada code into the result, and out comes marked-up Ada in RTF format. Then you can run this through your favorite RTF translator (we use MS-Word), and print away... Reserved words are in lower-case, bold font. Comments are in italics. The default font is Courier. It's important to use a fixed-width font. If you want to modify this, see hilite() and OTHERCMT. VERY IMPORTANT: To get the newsreader to accept this, the header string was 'broken' into multiple lines. This should be a single string, with no line feeds. Make this change BEFORE compiling! No warranty, express or implied... dave p.s. The derivation history on this: The 'root' is Herm Fisher's Ada Lex/Yacc grammar. Next came a tool Steve Rosen and I developed at Siemens to do Scribe mark-up, which I subsequently adapted for RTF. ------------------------------------------------------------------------ main() { char *header = "{\\rtf1\\mac\\deff2 {\\fonttbl{\\f0\\fswiss Chicago;}{\\f3\\fswiss Geneva;}{\\f4\\fmodern Monaco;}{\\f16\\fnil Palatino;}{\\f20\\froman Times;}{\\f21\\fswiss Helvetica;}{\\f22\\fmodern Courier;}{\\f23\\ftech Symbol;}{\\f33\\fnil Avant Garde;}{\\f200\\fnil MitreLogo;}\\015{\\f201\\fnil MitreSymbol;}}{\\colortbl\\red0\\green0\\blue0;\\red0\\green0\\blue255;\\red0\\green255\\blue255;\\red0\\green255\\blue0;\\red255\\green0\\blue255;\\red255\\green0\\blue0;\\red255\\green255\\blue0;\\red255\\green255\\blue255;}{\\stylesheet{\\s224\\tx360 \\b\\v\\f20\\fs20 \\015\\sbasedon0\\snext0 PostScript;}{\\s225\\li5760\\ri720\\tldot\\tx8280\\tqr\\tx8640 \\f20 \\sbasedon0\\snext0 toc 9;}{\\s226\\tx540\\tqr\\tx9000 \\f20 \\sbasedon228\\snext0 toc 8;}{\\s227\\sa240\\tx540\\tqr\\tx9000 \\f20 \\sbasedon229\\snext0 toc 7;}{\\s228\\sl260\\tx540\\tqr\\tx9000 \\015\\f20 \\sbasedon0\\snext0 toc 6;}{\\s229\\sa240\\tx540\\tqr\\tx9000 \\f20 \\sbasedon0\\snext0 toc 5;}{\\s230\\li1800\\tx2520\\tqr\\tx8820\\tqr\\tx9000 \\f20 \\sbasedon231\\snext0 toc 4;}{\\s231\\li1080\\sl260\\tx1800\\tqr\\tx8820\\tqr\\tx9000 \\f20 \\sbasedon232\\snext0 toc 3;}{\\015\\s232\\li360\\sl260\\tx1080\\tqr\\tx8820\\tqr\\tx9000 \\f20 \\sbasedon233\\snext0 toc 2;}{\\s233\\sa240\\sl260\\tqr\\tx8820\\tqr\\tx9000 \\f20 \\sbasedon0\\snext0 toc 1;}{\\s234\\li2160\\tx360 \\f20 \\sbasedon0\\snext0 index 7;}{\\s235\\li1800\\tx360 \\f20 \\sbasedon0\\snext0 index 6;}{\\015\\s236\\li1440\\tx360 \\f20 \\sbasedon0\\snext0 index 5;}{\\s237\\li1080\\tx360 \\f20 \\sbasedon0\\snext0 index 4;}{\\s238\\li720\\tx360 \\f20 \\sbasedon0\\snext0 index 3;}{\\s239\\li360\\tx360 \\f20 \\sbasedon0\\snext0 index 2;}{\\s240\\tx360 \\f20 \\sbasedon0\\snext0 index 1;}{\\015\\s241\\tx360 \\f20 \\sbasedon0\\snext0 line number;}{\\s242\\tx360 \\f20 \\sbasedon0\\snext0 page number;}{\\s243\\qc\\tx360 \\f20 \\sbasedon0\\snext243 footer;}{\\s244\\tqc\\tx4320\\tqr\\tx8640 \\f20 \\sbasedon0\\snext0 header;}{\\s245\\tx360 \\f20\\fs18\\up6 \\sbasedon0\\snext0 \\015footnote reference;}{\\s246\\fi-360\\li360\\sa240\\sl260\\tx360 \\f20 \\sbasedon0\\snext246 footnote text;}{\\s247\\li720\\tx360 \\i\\f20\\fs20 \\sbasedon0\\snext0 heading 9;}{\\s248\\qc\\tx360 \\f20 \\sbasedon0\\snext0 heading 8,Two Line Table Caption;}{\\s249\\qc\\sa480\\tx360 \\015\\f20 \\sbasedon0\\snext0 heading 7,Table Caption;}{\\s250\\qc\\sl260\\tx360 \\f20 \\sbasedon251\\snext0 heading 6,Two Line Figure Caption;}{\\s251\\qc\\sb480\\sl260\\tx360 \\f20 \\sbasedon0\\snext0 heading 5,Figure Caption;}{\\s252\\li360\\sa240\\keepn\\tx360 \\b\\f20 \\015\\sbasedon0\\snext0 heading 4,Level 3 Heading;}{\\s253\\sa240\\keepn\\tx360 \\b\\f20 \\sbasedon0\\snext0 heading 3,Level 2 Heading;}{\\s254\\sa240\\keepn\\tx360 \\b\\caps\\f20 \\sbasedon0\\snext0 heading 2,Level 1 Heading;}{\\s255\\qc\\sa480\\keepn\\tx360 \\b\\caps\\f20 \\015\\sbasedon0\\snext0 heading 1,Section Title;}{\\tx360 \\f20 \\sbasedon222\\snext0 Normal,Font: Times 12 Point,Flush left;}{\\s1\\sa240\\keepn\\tx360 \\b\\caps\\f20 \\sbasedon0\\snext0 Appendix Level 1 Heading;}{\\s2\\sa240\\keepn\\tx360 \\b\\f20 \\sbasedon0\\snext0 \\015Appendix Level 2 Heading;}{\\s3\\li360\\sa240\\keepn\\tx360 \\b\\f20 \\sbasedon0\\snext0 Appendix Level 3 Heading;}{\\s4\\tx360 \\f20 \\sbasedon0\\snext4 Distribution List ;}{\\s5\\sa240\\keepn\\tx360 \\b\\caps\\f20 \\sbasedon0\\snext0 Executive Summary Level 1 Heading;}{\\015\\s6\\sa240\\keepn\\tx360 \\b\\f20 \\sbasedon0\\snext0 Executive Summary Level 2 Heading;}{\\s7\\li360\\sa240\\keepn\\tx360 \\b\\f20 \\sbasedon0\\snext0 Executive Summary Level 3 Heading;}{\\s8\\sa240\\sl260\\tx360\\tqr\\tx9000 \\b\\caps\\f20 \\sbasedon0\\snext0 \\015Figure/Table/TOC Headings;}{\\s9\\qc\\ri29\\sa480\\sl260\\tx360 \\b\\caps\\f20 \\sbasedon0\\snext0 Front Matter Headings;}{\\s10\\fi-1080\\li1080\\tx360 \\f20 \\sbasedon0\\snext10 Glossary ;}{\\s11\\fi-360\\li360\\tx360 \\f20 \\sbasedon0\\snext11 Glossary (Long Terms);}{\\015\\s12\\fi-540\\li900\\tx360 \\f20 \\sbasedon0\\snext12 List - First Level;}{\\s13\\fi-540\\li1440\\tx360 \\f20 \\sbasedon0\\snext13 List - Second Level;}{\\s14\\tx360 \\f20 \\sbasedon0\\snext14 Name/Date Reference ;}{\\s15\\fi-360\\li360\\tx360 \\f20 \\sbasedon0\\snext15 \\015Numbered Reference ;}{\\s16\\li360 \\f20 \\sbasedon0\\snext16 Quotation;}{\\s17\\qc\\ri29\\sa240\\sl260\\keepn\\tx360 \\b\\caps\\f20 \\sbasedon0\\snext0 Section Number Heading;}}\\margl1620\\margr1620\\margt2160\\margb2160\\ftnbj \\sectd \\015\\pgnrestart\\linemod0\\linex0\\footery1080\\cols1\\endnhere \\pard\\plain \\tx360 \\f20 "; printf("%s", header); yylex(); printf("}"); } yywrap() { return (1); } ------------------------------------------------------------------------ /* modified from: */ /*------------------------------------------------------------------------*/ /* Lexical input for LEX for LALR(1) Grammar for ANSI Ada */ /* */ /* Herman Fischer */ /* Litton Data Systems */ /* March 26, 1984 */ /* */ /*------------------------------------------------------------------------*/ int my_start = 0; /* indicates that it's startup time */ int ignore_next_subprog = 0; /* when in a generic parameter */ /* declaration, indicates that */ /* the next subprogram is a */ /* formal parameter, and not */ /* the actual generic thing. */ int funct_defn = 0; /* indicates that this return is part */ /* of a function declaration, and should */ /* not be capitalized */ char class[20]; int do_index = 1; /* 1 if indexing wanted, 0 otherwise */ #include "stdio.h" #include "ctype.h" %} %e 3500 /* tree nodes array size */ %p 9500 /* positions */ %a 10000 /* transitions array size */ %k 500 /* packed character classes */ %o 10000 /* output array size */ %n 2000 /* states ?! */ %START IDENT Z COMMENT OTHERCMT PRAGMA KEEPNAME GENERICSPEC %% {BEGIN Z;} (ABORT|abort)|(ABS|abs)|(ACCEPT|accept)|(ACCESS|access) | (ALL|all)|(AND|and)|(ARRAY|array)|(AT|at) | (BEGIN|begin)|(BODY|body)|(CASE|case)|(CONSTANT|constant) | (DECLARE|declare)|(DELAY|delay)|(DELTA|delta)|(DIGITS|digits) | (DO|do)|(ELSE|else)|(ELSIF|elsif)|(END|end)|(ENTRY|entry) | (EXCEPTION|exception)|(FOR|for) | (IF|if)|(IN|in)|(IS|is)|(LIMITED|limited)|(LOOP|loop) | (MOD|mod)|(NEW|new)|(NOT|not)|(NULL|null)|(OF|of)|(OR|or) | (OTHERS|others)|(OUT|out)|(PRIVATE|private) | (RANGE|range)|(RECORD|record)|(REM|rem) | (RENAMES|renames)|(REVERSE|reverse) | (SELECT|select)|(SEPARATE|separate) | (TERMINATE|terminate)|(THEN|then)|(USE|use) | (WHEN|when)|(WHILE|while)|(XOR|xor) { MAKELOWER(yytext); hilite(yytext); BEGIN Z; } (WITH|with) { MAKELOWER(yytext); hilite(yytext); BEGIN Z; } (GOTO|goto)|(EXIT|exit)|(RAISE|raise) { MAKELOWER(yytext); hilite(yytext); BEGIN Z; } (RETURN|return) { MAKELOWER(yytext); hilite(yytext); BEGIN Z; } ("=>")|("..")|("**")|(":=")|("/=")|(">=")|("<=")|("<<") | (">>")|("<>")|("&")|("(")|("*")|("+")|(",")|("-")|(".") | ("/")|(":")|(";")|("<")|("=")|(">")|("|") { ECHO; BEGIN Z; } ")" {ECHO; BEGIN IDENT;} (PRAGMA|pragma) { MAKELOWER(yytext); hilite(yytext); BEGIN PRAGMA; } . { unput(yytext[0]); BEGIN Z; } TYPE|type | SUBTYPE|subtype | TASK|task | (PROCEDURE|procedure) | (PACKAGE|package) { MAKELOWER(yytext); hilite(yytext); BEGIN Z;} (FUNCTION|function) { MAKELOWER(yytext); hilite(yytext); BEGIN Z;} [a-zA-Z][a-z_A-Z0-9]* {ECHO;BEGIN Z;} (GENERIC|generic) { MAKELOWER(yytext); hilite(yytext); BEGIN GENERICSPEC;} (WITH|with) { MAKELOWER(yytext); hilite(yytext); } (PROCEDURE|procedure)|(FUNCTION|function) { MAKELOWER(yytext); hilite(yytext); } (PACKAGE|package) { MAKELOWER(yytext); hilite(yytext); BEGIN Z;} (ACCESS|access)|(ARRAY|array)|(CONSTANT|constant) | (DELTA|delta)|(DIGITS|digits)|(IN|in)|(IS|is) | (LIMITED|limited)|(OF|of)|(OTHERS|others)|(OUT|out) | (PRIVATE|private)|(RANGE|range)|(RETURN|return) | (SUBTYPE|subtype)|(TYPE|type) { MAKELOWER(yytext); hilite(yytext); } [a-zA-Z][a-z_A-Z0-9]* {ECHO;} . {ECHO;} \' {ECHO; BEGIN Z;} /* type mark only */ [a-zA-Z][a-z_A-Z0-9]* {ECHO; BEGIN IDENT; } [0-9][0-9_]*([.][0-9_]+)?([Ee][-+]?[0-9_]+)? { ECHO; BEGIN Z; } [0-9][0-9_]*#[0-9a-fA-F_]+([.][0-9a-fA-F_]+)?#([Ee][-+]?[0-9_]+)? { ECHO; BEGIN Z; } \"([^\"]*(\"\")*)*\" {ECHO; BEGIN Z; } \'([^\']|\'\')\' {ECHO; BEGIN Z; } [" "|"\t"] {ECHO;} /* ignore spaces and tabs */ . {ECHO; printf("?? lexical error [%s] ??\n(@\\)", yytext);} "--"([" "|"\t"]*) {ECHO; BEGIN COMMENT;} [\n] {printf("\\par \015"); BEGIN Z;} "-"+ {ECHO;} [\n] {printf("\\par \015"); BEGIN Z;} . { unput(yytext[0]); BEGIN OTHERCMT; } .* { printf("{\\i %s}", yytext); BEGIN Z; } %% hilite(it) char *it; {printf("{\\b %s}", it);} MAKEUPPER(s) char *s; { for (; *s != NULL; ++s) *s = (islower(*s) ? toupper(*s) : *s); } MAKELOWER(s) char *s; { for (; *s != NULL; ++s) *s = (isupper(*s) ? tolower(*s) : *s); } -- --The preceeding opinions do not necessarily reflect the opinions of --The MITRE Corporation or its sponsors. -- "A good plan violently executed -NOW- is better than a perfect plan -- next week" George Patton -- "Any damn fool can write a plan. It's the execution that gets you -- all screwed up" James Hollingsworth -------------------------------------------------------------------------