Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

RE:(4) Automatic CODE tags

by swiftone (Curate)
on Jun 20, 2000 at 20:16 UTC ( #19051=note: print w/replies, xml ) Need Help??

in reply to RE: RE:(2) Automatic CODE tags
in thread Automatic CODE tags

Of course, there should be some more logic added, as most code that gets posted, won't compile. That's why it was posted in the first place. But then again, the analyzer should simply lean more towards code than towards text, because a monospaced text is far easier to read than vario-spaced and line-joined code.

I thought of that, but if you are taking it line-by-line (rather than whole post), any program of more than a few lines will have plenty of lines that compile.

eval's, even if it doesn't do much. That's why I thought the code was so nicely elegant. You don't need much logic.

Replies are listed 'Best First'.
Automatic CODE-tag creation (Prototype)
by Corion (Pope) on Jun 21, 2000 at 20:01 UTC

    I played around with the idea a bit yesterday night (the nights are really hot this time in .de :)), and here's a prototype that does some good formatting on my coding style. I don't know how well it works for other coding styles, and the implementation is a bit crude ... I couldn't get your elegant idea of "most single lines should compile" to work for me, so I resorted mostly to static REs - quite unelegant, as any such list is bound to be incomplete ...

    Anyway, if anybody wants to have a look at how a heuristic markup could be done, here's the code (the code is still a bit confused about CODE and PRE tags, but you should get the intention ...) :

    Update :D'oh - as soon as I go offline, I see many problems with the code. So here's an updated version ... Hmm - and I follow the suggestion and put the code into the Code Catacombs instead of posting it here ... The Code

      This is nice, but don't you think it really belongs in the Code Catacombs?

      The Perl Gods have said that the Perl interpreter is the best way to interpret Perl, so I'm still thinking that something that works with that would work better. After some testing though, I've discovered that the Safe Module will not do what I wanted. What we really need is the perl -c command function. I know nothing about the guts of perl, but there should be someway to access this. Do any of the Perl Gods have ideas?
        What about something as simple as calling the perl interpreter with a system call? Something as simple as this:
        qx {perl -c $function_to_be_executed}
        It's clumsy, yes, but it should work.

        - Ozymandias

        I also know that the only thing that can determine if some sequence of characters is valid Perl is Perl itself, but the main idea is to have some heuristics to format posts by people who don't know how to use the site ...

        This is not thought as a general Perl formatter, but only for quick weeding of AM posts.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://19051]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2021-01-24 01:15 GMT
Find Nodes?
    Voting Booth?