* Re: gnathtml in Ada ? [not found] <3A351287.8628BCFA@dpqwd.zblf> @ 2000-12-11 19:32 ` Robert Dewar 2000-12-11 21:47 ` Pascal Obry 1 sibling, 0 replies; 14+ messages in thread From: Robert Dewar @ 2000-12-11 19:32 UTC (permalink / raw) In article <3A351287.8628BCFA@dpqwd.zblf>, Gautier <grounfs6xy6723@dpqwd.zblf> wrote: > Hullo. A small question: would it be possible, with > the portable GNAT.OS*** packages, to build a gnathtml > in Ada (with some GNAT dependency) ? > > It's essentialy technical curiosity - replies like "Don't you like > Perl ?" or "What are you waitin' for, Christmas ?" unwelcome ;-) > > OK, why in Ada ? > 1) no need to install perl [disclaimer: nothing against it] > 2) another cool Ada tool in Ada > 3) customisable for the poor ones who don't understand Perl at all... This would definitely be possible, and definitely a useful project. If you are interested in working on this, that would be great! Sent via Deja.com http://www.deja.com/ Before you buy. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: gnathtml in Ada ? [not found] <3A351287.8628BCFA@dpqwd.zblf> 2000-12-11 19:32 ` gnathtml in Ada ? Robert Dewar @ 2000-12-11 21:47 ` Pascal Obry 2000-12-11 23:04 ` Ted Dennison 2000-12-12 11:44 ` Gautier 1 sibling, 2 replies; 14+ messages in thread From: Pascal Obry @ 2000-12-11 21:47 UTC (permalink / raw) Gautier <grounfs6xy6723@dpqwd.zblf> writes: > Hullo. A small question: would it be possible, with > the portable GNAT.OS*** packages, to build a gnathtml > in Ada (with some GNAT dependency) ? Do you really have to use GNAT.OS* to implement gnathtml in Ada ! I would think not but I do not know all the gnathtml goodies... Pascal. -- --|------------------------------------------------------ --| Pascal Obry Team-Ada Member --| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE --|------------------------------------------------------ --| http://perso.wanadoo.fr/pascal.obry --| --| "The best way to travel is by means of imagination" ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: gnathtml in Ada ? 2000-12-11 21:47 ` Pascal Obry @ 2000-12-11 23:04 ` Ted Dennison 2000-12-12 0:11 ` David Botton 2000-12-12 10:32 ` gnathtml in Ada ? Gautier 2000-12-12 11:44 ` Gautier 1 sibling, 2 replies; 14+ messages in thread From: Ted Dennison @ 2000-12-11 23:04 UTC (permalink / raw) In article <u8zpmljfh.fsf@wanadoo.fr>, Pascal Obry <p.obry@wanadoo.fr> wrote: > Gautier <grounfs6xy6723@dpqwd.zblf> writes: > > > Hullo. A small question: would it be possible, with > > the portable GNAT.OS*** packages, to build a gnathtml > > in Ada (with some GNAT dependency) ? > > Do you really have to use GNAT.OS* to implement gnathtml in Ada ! > > I would think not but I do not know all the gnathtml goodies... It looks like it traverses the user's program library and html-izes all withed units too. That may very well require OS support. Without that feature, the whole thing could be done quite trivially using OpenToken... {T.E.D. turns and runs for his life from an irate mob of pitchfork, torch, and rolled-up LRM weidling c.l.a. denziens} -- T.E.D. http://www.telepath.com/~dennison/Ted/TED.html Sent via Deja.com http://www.deja.com/ Before you buy. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: gnathtml in Ada ? 2000-12-11 23:04 ` Ted Dennison @ 2000-12-12 0:11 ` David Botton 2000-12-12 15:11 ` Ted Dennison 2000-12-13 5:54 ` gnathtml in Ada ? (LONG!) Ted Dennison 2000-12-12 10:32 ` gnathtml in Ada ? Gautier 1 sibling, 2 replies; 14+ messages in thread From: David Botton @ 2000-12-12 0:11 UTC (permalink / raw) To: comp.lang.ada > Without that feature, the whole thing could be done quite trivially > using OpenToken... I assume this means you have volunteered for the task. DB ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: gnathtml in Ada ? 2000-12-12 0:11 ` David Botton @ 2000-12-12 15:11 ` Ted Dennison 2000-12-13 7:23 ` Brian Orpin 2000-12-13 5:54 ` gnathtml in Ada ? (LONG!) Ted Dennison 1 sibling, 1 reply; 14+ messages in thread From: Ted Dennison @ 2000-12-12 15:11 UTC (permalink / raw) In article <000d01c063d0$1e0d7640$0502a8c0@db2000>, comp.lang.ada@ada.eu.org wrote: > > Without that feature, the whole thing could be done quite trivially > > using OpenToken... ("that feature" referring to support for traversing the user's Ada lib) > > I assume this means you have volunteered for the task. :-) Actually, I almost went ahead and did it. It wouldn't take too long, and I think the sources would be small enough to post here. (Remember that OpenToken already comes with an Ada tokenizer.) I decided against it because without the trans-file cross-references, it wouldn't be horribly useful (you might as well use a colorizing text editor). But if there's interst, I suppose I could whip it up real quick and post it. Someone else with more free time could then take it and figure out the Ada library traversal issues. Also, once all this gets written, it would be trivial to write similar htmlizers for the other languages that have OpenToken tokenizers; namely Java and Modula-2. -- T.E.D. http://www.telepath.com/~dennison/Ted/TED.html Sent via Deja.com http://www.deja.com/ Before you buy. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: gnathtml in Ada ? 2000-12-12 15:11 ` Ted Dennison @ 2000-12-13 7:23 ` Brian Orpin 0 siblings, 0 replies; 14+ messages in thread From: Brian Orpin @ 2000-12-13 7:23 UTC (permalink / raw) On Tue, 12 Dec 2000 15:11:56 GMT, Ted Dennison <dennison@telepath.com> wrote: >In article <000d01c063d0$1e0d7640$0502a8c0@db2000>, > comp.lang.ada@ada.eu.org wrote: >> > Without that feature, the whole thing could be done quite trivially >> > using OpenToken... >("that feature" referring to support for traversing the user's Ada lib) >> >> I assume this means you have volunteered for the task. >:-) > >Actually, I almost went ahead and did it. It wouldn't take too long, and >I think the sources would be small enough to post here. (Remember that >OpenToken already comes with an Ada tokenizer.) I decided against it >because without the trans-file cross-references, it wouldn't be horribly >useful (you might as well use a colorizing text editor). The cross linking is the useful bit. >But if there's interst, I suppose I could whip it up real quick and post >it. Someone else with more free time could then take it and figure out >the Ada library traversal issues. You could simply offer the option to include library paths in the call (or by config file) and any unit which is not found does not have links produced. -- Brian Orpin BAE SYSTEMS, Edinburgh "If you really know C++, there isn't much you can't do with it, though it may not always be what you intended!" Tucker Taft 1998 ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: gnathtml in Ada ? (LONG!) 2000-12-12 0:11 ` David Botton 2000-12-12 15:11 ` Ted Dennison @ 2000-12-13 5:54 ` Ted Dennison 1 sibling, 0 replies; 14+ messages in thread From: Ted Dennison @ 2000-12-13 5:54 UTC (permalink / raw) In article <000d01c063d0$1e0d7640$0502a8c0@db2000>, comp.lang.ada@ada.eu.org wrote: > > Without that feature, the whole thing could be done quite trivially > > using OpenToken... > > I assume this means you have volunteered for the task. Well, I got bored this evening, so attached is my first wag at it (sans headers). It took me all of 1 hour to write (most of that time spent learning what HTML is supposed to like these days. Its been a while...). It is only 54 lines of code, but it would actually be much shorter if I hadn't designed it for later expansion. I should also mention that it requires a recent version of OpenToken to compile. As far as an official release, it (or a later version) will be included in the next distribution of OpenToken. Good points: Its generates strictly HTML 4 compliant output. I colorizes the same way emacs Ada mode does. It should be compiler-agnostic. Its 100% Ada source. Bad points: It doesn't do anything yet besides colorizing comments and keywords. Its only been tested on my Win2k-gnat system. The latest OpenToken has known incompatabilites with some compilers. As usual, my apologies ahead of time for what deja may do with the formatting: --- with Ada.Command_Line; with Ada.Text_IO; with HTML_Compiler; ------------------------------------------------------------------------------- -- This routine provides for converting Ada source files into HTML. ------------------------------------------------------------------------------- procedure HTMLify is ---------------------------------------------------------------------------- -- Print a description of the proper usage of this program ---------------------------------------------------------------------------- procedure Print_Usage is begin Ada.Text_IO.Put_Line ("usage: " & Ada.Command_Line.Command_Name & " filename"); Ada.Text_IO.New_Line; end Print_Usage; begin -- Verify the arguments if Ada.Command_Line.Argument_Count = 0 or else Ada.Command_Line.Argument(1) = "--help" then Print_Usage; return; end if; for File_Index in 1..Ada.Command_Line.Argument_Count loop HTML_Compiler.Compile (Ada.Command_Line.Argument(File_Index)); end loop; end HTMLify; ----------------------------------------------------------------------------- -- -- This package provides for compiling the given Ada source file into an HTML -- file. ----------------------------------------------------------------------------- -- package HTML_Compiler is ---------------------------------------------------------------------------- -- Open the given Ada file and compile it into HTML source. The HTML file -- will be given the same name as the Source_File, with ".html" on the end. ---------------------------------------------------------------------------- procedure Compile (Source_File : in String); end HTML_Compiler; -- Ada units with Ada.Text_IO; -- Standard OpenToken units with OpenToken; with OpenToken.Text_Feeder.Text_IO; -- The lexer with Ada_Lexer; use type Ada_Lexer.Ada_Token; ------------------------------------------------------------------------------- -- This package provides for compiling the given Ada source file into an HTML -- file. ------------------------------------------------------------------------------- package body HTML_Compiler is ---------------------------------------------------------------------------- -- Parse an Ada token into normal text HTML on the given file. ---------------------------------------------------------------------------- procedure Parse_Text (Destination : in out Ada.Text_IO.File_Type) is begin Ada.Text_IO.Put (File => Destination, Item => Ada_Lexer.Tokenizer.Lexeme (Ada_Lexer.Analyzer) ); Ada_Lexer.Tokenizer.Find_Next (Ada_Lexer.Analyzer); end Parse_Text; ---------------------------------------------------------------------------- -- Parse an Ada comment token into HTML on the given file. ---------------------------------------------------------------------------- procedure Parse_Comment (Destination : in out Ada.Text_IO.File_Type) is begin Ada.Text_IO.Put (File => Destination, Item => "<SPAN class=""comment"">" & Ada_Lexer.Tokenizer.Lexeme (Ada_Lexer.Analyzer) & "</SPAN>" ); Ada_Lexer.Tokenizer.Find_Next (Ada_Lexer.Analyzer); end Parse_Comment; ---------------------------------------------------------------------------- -- Parse an Ada keyword token into HTML on the given file. ---------------------------------------------------------------------------- procedure Parse_Keyword (Destination : in out Ada.Text_IO.File_Type) is begin Ada.Text_IO.Put (File => Destination, Item => "<SPAN class=""keyword"">" & Ada_Lexer.Tokenizer.Lexeme (Ada_Lexer.Analyzer) & "</SPAN>" ); Ada_Lexer.Tokenizer.Find_Next (Ada_Lexer.Analyzer); end Parse_Keyword; ---------------------------------------------------------------------------- -- Parse a block of Ada code into HTML on the given file. ---------------------------------------------------------------------------- procedure Parse_Block (Destination : in out Ada.Text_IO.File_Type) is begin case Ada_Lexer.Tokenizer.ID (Ada_Lexer.Analyzer) is when Ada_Lexer.Comment_T => Parse_Comment (Destination); when Ada_Lexer.Abort_T..Ada_Lexer.Xor_T => Parse_Keyword (Destination); when others => Parse_Text (Destination); end case; end Parse_Block; ---------------------------------------------------------------------------- -- Open the given Ada file and compile it into HTML source. The HTML file -- will be given the same name as the Source_File, with ".html" on the end. ---------------------------------------------------------------------------- procedure Compile (Source_File : in String) is Ada_File : aliased Ada.Text_Io.File_Type; HTML_File : Ada.Text_Io.File_Type; begin -- Turn on Ada whitespace reporting Ada_Lexer.Syntax(Ada_Lexer.Whitespace_T).Recognizer.Report := True; Ada_Lexer.Syntax(Ada_Lexer.Comment_T).Recognizer.Report := True; -- Open the Ada file Ada.Text_Io.Open (File => Ada_File, Mode => Ada.Text_Io.In_File, Name => Source_File); Ada_Lexer.Tokenizer.Input_Feeder := OpenToken.Text_Feeder.Text_IO.Create (Ada_File'Unchecked_Access); -- Open the target HTML file, and put its name and header information in. Ada.Text_IO.Create (File => HTML_File, Mode => Ada.Text_IO.Out_File, Name => Source_File & ".html"); Ada.Text_IO.Put_Line (File => HTML_File, Item => "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.01//EN"" ""http://www.w3.org/TR/html4/strict.dtd"">" ); Ada.Text_IO.Put_Line (File => HTML_File, Item => "<HTML><HEAD><TITLE>" & Source_File & "</TITLE><STYLE type=""text/css""> H1 { text-align: center}" ); Ada.Text_IO.Put_Line (File => HTML_File, Item => "SPAN.comment { color: red } SPAN.keyword { color: purple }</STYLE></HEAD>" ); Ada.Text_IO.Put_Line (File => HTML_File, Item => "<BODY><H1>" & Source_File & "</H1><HR><PRE>" ); Ada_Lexer.Tokenizer.Find_Next (Ada_Lexer.Analyzer); while Ada_Lexer.Tokenizer.ID (Ada_Lexer.Analyzer) /= Ada_Lexer.End_Of_File_T loop Parse_Block (HTML_File); end loop; Ada.Text_IO.Put_Line (File => HTML_File, Item => "</PRE></BODY></HTML>" ); Ada.Text_IO.Close (HTML_File); Ada.Text_IO.Close (Ada_File); end Compile; end HTML_Compiler; --- -- T.E.D. http://www.telepath.com/~dennison/Ted/TED.html Sent via Deja.com http://www.deja.com/ ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: gnathtml in Ada ? 2000-12-11 23:04 ` Ted Dennison 2000-12-12 0:11 ` David Botton @ 2000-12-12 10:32 ` Gautier 2000-12-12 15:46 ` Ted Dennison 1 sibling, 1 reply; 14+ messages in thread From: Gautier @ 2000-12-12 10:32 UTC (permalink / raw) Ted Dennison: > It looks like it traverses the user's program library and html-izes all > withed units too. That may very well require OS support. For that I think the parameters given with "-o" options suffice: you add the prefix for searching files. At least the present version in Perl needs explicit paths. So (I think) you could do the library traversing in 100%-portable Ada. The only need for some GNAT.OS*** could be the creation of directories. > Without that feature, the whole thing could be done quite trivially > using OpenToken... Oh, what is OpenToken ? (*) ______________________________________________________ Gautier -- http://members.nbci.com/gdemont/gsoft.htm (*) ;-) ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: gnathtml in Ada ? 2000-12-12 10:32 ` gnathtml in Ada ? Gautier @ 2000-12-12 15:46 ` Ted Dennison 2000-12-12 22:20 ` tmoran ` (2 more replies) 0 siblings, 3 replies; 14+ messages in thread From: Ted Dennison @ 2000-12-12 15:46 UTC (permalink / raw) In article <3A35FEC3.7F525B27@zxblr2f.grbl>, Gautier <grounfxyz@zxblr2f.grbl> wrote: > Ted Dennison: > > > It looks like it traverses the user's program library and html-izes > > all withed units too. That may very well require OS support. > > For that I think the parameters given with "-o" options suffice: you > add the prefix for searching files. At least the present version in > Perl needs explicit paths. So (I think) you could do the library > traversing in 100%-portable Ada. Ahh. So the perl version didn't bother to solve this problem either? I guess I should have expected a hack from a perl program. :-) I suppose in a Gnat environment that would probably be acceptable, because the compiler is typically invoked with the explicit search path anyway. For other compilers that information is hidden from typical users. Knowing the directories a unit is in isn't very helpful anyway, as you still don't know what *file* it is in. It would be nice for users of Averstar-FE compilers if it would just read the unit.map file. Is the perl version smart enough to check the gnat.adc file for alternative unit name mappings? I suppose you might be able to make it somewhat compiler-portable by using ASIS. But since not everyone supports ASIS, that won't get you all the way there. However, I suppose support for ASIS will only become universal when there is a large suite of useful ASIS tools, so the best line may be to just go with ASIS and let users left out in the cold complain to their vendors. -- T.E.D. http://www.telepath.com/~dennison/Ted/TED.html Sent via Deja.com http://www.deja.com/ Before you buy. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: gnathtml in Ada ? 2000-12-12 15:46 ` Ted Dennison @ 2000-12-12 22:20 ` tmoran 2000-12-12 23:15 ` (null) 2000-12-13 16:38 ` Gautier 2 siblings, 0 replies; 14+ messages in thread From: tmoran @ 2000-12-12 22:20 UTC (permalink / raw) Presumably with any compiler you need a way to translate from "with" name to directory/file. If the naming convention for a particular compiler makes that easy, great. Another option is to generate a file list (dir *.ads > files), then read those files looking for package names and generate your own translate table. That should be easy to do in a portable way. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: gnathtml in Ada ? 2000-12-12 15:46 ` Ted Dennison 2000-12-12 22:20 ` tmoran @ 2000-12-12 23:15 ` (null) 2000-12-13 16:38 ` Gautier 2 siblings, 0 replies; 14+ messages in thread From: (null) @ 2000-12-12 23:15 UTC (permalink / raw) In article <915h95$hj6$1@nnrp1.deja.com>, Ted Dennison <dennison@telepath.com> wrote: > >I suppose you might be able to make it somewhat compiler-portable by >using ASIS. But since not everyone supports ASIS, that won't get you all >the way there. However, I suppose support for ASIS will only become >universal when there is a large suite of useful ASIS tools, so the best >line may be to just go with ASIS and let users left out in the cold >complain to their vendors. There's at least a partial ASIS solution already coded at Swiss Fed Inst of Technology. You can get the source code for ada2html at ftp://lglftp.epfl.ch/pub/Ada/format.tar.gz It will perform syntax highlighting but I'm not sure if it creates links. -- ======================================================================= Life is short. | Craig Spannring Bike hard, ski fast. | cts@internetcds.com --------------------------------+------------------------------------ ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: gnathtml in Ada ? 2000-12-12 15:46 ` Ted Dennison 2000-12-12 22:20 ` tmoran 2000-12-12 23:15 ` (null) @ 2000-12-13 16:38 ` Gautier 2000-12-13 17:35 ` Ted Dennison 2 siblings, 1 reply; 14+ messages in thread From: Gautier @ 2000-12-13 16:38 UTC (permalink / raw) Ted Dennison: > > For that I think the parameters given with "-o" options suffice: you > > add the prefix for searching files. At least the present version in > > Perl needs explicit paths. So (I think) you could do the library > > traversing in 100%-portable Ada. > > Ahh. So the perl version didn't bother to solve this problem either? I > guess I should have expected a hack from a perl program. :-) If you know a bit of perl, why not add the ada_include_path and ada_object_path yourself ?... The script is in the /bin directory of your GNAT distrib. But I feel there is a good reason to make these options _explicit_. [...] For use with non-GNAT sources, it doesn't harm: you gnatmake it and if the Ada is valid, all .ali files are created, even if link fails due to such and such import. I'm doing so to html-ize a project made with DEC Ada. > Is the perl version smart enough to check the gnat.adc file for > alternative unit name mappings? Didn't find it in the .pl, but again it is surely too much: - perhaps the .ali contains already the right alternative name (-> GNAT RM) - for alternernative naming, it is *easy* to do. Say you have plenty of .ada files (some with spec+body, some with non-GNAT naming - my case). You type "gnatchop *.ada", and 1 second later you have all .ads and .adb ! Then gnatmake xxxx, you have the .ali files. Finally: perl gnathtml ... and you have the Web site. The tool works well. It would *just* be cool to customise the tool. E.g. allow to add headers, links outside the main page, "A HREF"-ize the URLs in strings, why not add a tag for a background image ;-) ? I don't understand much of Perl, but who knows, with a bit of guess-work ?... But isn't the author of gnathtml.pl reading here ?... Gautier ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: gnathtml in Ada ? 2000-12-13 16:38 ` Gautier @ 2000-12-13 17:35 ` Ted Dennison 0 siblings, 0 replies; 14+ messages in thread From: Ted Dennison @ 2000-12-13 17:35 UTC (permalink / raw) In article <3A37A5FC.7E10DDAF@zxblr2f.grbl>, Gautier <grounfxyz@zxblr2f.grbl> wrote: > the URLs in strings, why not add a tag for a background image ;-) ? > I don't understand much of Perl, but who knows, with a bit of The quick version I just wrote uses HTML 4 cascading style sheets, which theoreticaly can be referenced in from another document. What this means in plain english is that if you want to change stuff like the colors used for keywords and comments, or the background image, all you'd have to do is edit the default style sheet html file. No code would have to be changed at all (well...HTML is pretty much code too). Of course its not currently using referenced style sheets. But it would be a trivial change. I'll probably make that change next time I go into it. -- T.E.D. http://www.telepath.com/~dennison/Ted/TED.html Sent via Deja.com http://www.deja.com/ ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: gnathtml in Ada ? 2000-12-11 21:47 ` Pascal Obry 2000-12-11 23:04 ` Ted Dennison @ 2000-12-12 11:44 ` Gautier 1 sibling, 0 replies; 14+ messages in thread From: Gautier @ 2000-12-12 11:44 UTC (permalink / raw) A note for those that the subject could confuse: the present version of gnathtml (in Perl) *works very well*. G. ^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2000-12-13 17:35 UTC | newest] Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <3A351287.8628BCFA@dpqwd.zblf> 2000-12-11 19:32 ` gnathtml in Ada ? Robert Dewar 2000-12-11 21:47 ` Pascal Obry 2000-12-11 23:04 ` Ted Dennison 2000-12-12 0:11 ` David Botton 2000-12-12 15:11 ` Ted Dennison 2000-12-13 7:23 ` Brian Orpin 2000-12-13 5:54 ` gnathtml in Ada ? (LONG!) Ted Dennison 2000-12-12 10:32 ` gnathtml in Ada ? Gautier 2000-12-12 15:46 ` Ted Dennison 2000-12-12 22:20 ` tmoran 2000-12-12 23:15 ` (null) 2000-12-13 16:38 ` Gautier 2000-12-13 17:35 ` Ted Dennison 2000-12-12 11:44 ` Gautier
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox