Advertisement

Online .cpp parsing into HTML

Started by November 06, 2000 04:59 PM
39 comments, last by baskuenen 24 years, 2 months ago
bah CGI''s arent too difficult.

Well if they written in C++, no.

As far as i remember, you write the application to read in the input from the console, and output the resulting html to the console (with a couple lines header whos format i forget).

And when the person tries to go to
http://www.mysite.com/cgi-bin/parser?source.cpp

It basically runs your parser executeable and sends it the information via the console (use cin or something) and then you just create the html and attach a small header to tell the browser its receiving html and whatever your cgi writes to the console before exiting is what is sent to the browser.



regards,

GeniX

www.cryo-genix.net
regards,GeniXwww.cryo-genix.net
I also did some C++ CGI programming some time ago, maybe this isn't the hard part

If you parse a string - the keywords and defines don't count, and the \" continues the string and doesn't end it. Maybe also chars like 'A' would be a nice thing to colour.

Keywords should be fine, but you would have to check the complete list of them, and put them all into a huge table. Reading ahead is important.

Defines are more difficult than you think. Keywords and strings dont count. It's only a define if the line starts with # (skipping white space). If the line ends with \ the define continues on the next line.

Did I miss anything? Oh yes - is it be possible to set the tabsize to 4?



Edited by - BasKuenen on November 7, 2000 11:29:47 AM
Advertisement
Whoah - almost forgot comment // /* */
The tool I have is a piece of cake to use, it has eveything u want syntax hightighting, tab/indent, italic and/or bold text. So if you want it, I will give it to u.
Erm, I guess if you guys already have tools that aren''t buggy, might as well not use my program...

-----------------------------

A wise man once said "A person with half a clue is more dangerous than a person with or without one."

The Micro$haft BSOD T-Shirt
-----------------------------A wise man once said "A person with half a clue is more dangerous than a person with or without one."The Micro$haft BSOD T-Shirt
If you have finnished it ImmaGNUman, then post a link to it, I''m currently teaching myself Perl before I start it at uni, so the more CGI / Perl code I can get my grubby little hands on the better.

I''d use it even if there is one already wrote out there, I''m too lazy to look for it. Plus I have no need to use it at this moment in time, but I might need it soon...
When I find my code in tons of trouble,Friends and colleages come to me,Speaking words of wisdom:"Write in C."My Web Site
Advertisement
Not finished yet, got home a little late. But if I finish it tonight ill post a link later.

-----------------------------

A wise man once said "A person with half a clue is more dangerous than a person with or without one."

The Micro$haft BSOD T-Shirt
-----------------------------A wise man once said "A person with half a clue is more dangerous than a person with or without one."The Micro$haft BSOD T-Shirt
Creating a whole new perl script might be overkill (or at least extra work). You can just take an existing C/C++ lex specification and override the action statements to print to standard out yytext surrounded by the html font statements.
How about this idea:
>>> Use custom style-sheets with the output!

Example:
    <FONT class=code_comment>...<\FONT>    


The call could be made with something like:
http://www.cgi.com/format.cgi?http://mydomain.com/myfile.cpp+style=http://mydomain.com/style.css

I''m not the programmer in this case (how can this be?) - but just sharing some idea''s


ImmaGNUman: I''m still very interrested! If you get it running, I''m sure to atleast put it on my site with big credits to the programmer!
Better - I''ll devote a page of to it (if you didn''t already) and let people fill in their URL to format it. I could also make good use of it when I need some (local) source converted for documents!!!


Now more than ever - really really really - interrested !!!

Hmm, still working on it, I got all the keywords and etc. into an array, just gotta:

1) Work on C-style comments
2) Work out bugs

-----------------------------

A wise man once said "A person with half a clue is more dangerous than a person with or without one."

The Micro$haft BSOD T-Shirt
-----------------------------A wise man once said "A person with half a clue is more dangerous than a person with or without one."The Micro$haft BSOD T-Shirt

This topic is closed to new replies.

Advertisement