Tech Off Thread

4 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

Code test

Back to Forum: Tech Off
  • User profile image
    exoteric

    Dim [Date] As Date
    Dim foo As New List(Of String) From { "hello", "bye" }
    Dim doc = <?xml version="1.0">
              <Stuff d=<%= [Date] %> />

  • User profile image
    Sven Groot

    See, if they were still using my formatter for VB (which they aren't, even though it's still being used for C#), at least the [Date] and From would've worked. Big Smile

     

    XML literals were supported but you have to mark them, because it's not possible to reliably discover them using regular expressions.

  • User profile image
    W3bbo

    Sven Groot said:

    See, if they were still using my formatter for VB (which they aren't, even though it's still being used for C#), at least the [Date] and From would've worked. Big Smile

     

    XML literals were supported but you have to mark them, because it's not possible to reliably discover them using regular expressions.

    I understand the VB and C# editors for Visual Studio contain classes that implement interfaces for code-highlighting as part of the VS SDK. Isn't it then just a matter of extracting those assemblies and using those classes in our own code-highlighting projects?

     

    Other sites like Pastebin already have highlighters for pretty much every language under the sun, is it really that hard?

  • User profile image
    Sven Groot

    W3bbo said:
    Sven Groot said:
    *snip*

    I understand the VB and C# editors for Visual Studio contain classes that implement interfaces for code-highlighting as part of the VS SDK. Isn't it then just a matter of extracting those assemblies and using those classes in our own code-highlighting projects?

     

    Other sites like Pastebin already have highlighters for pretty much every language under the sun, is it really that hard?

    Pastebin's highlighters are just as limited as my own or most others. Nearly all highlighters use regular expression rather than actual language parsing. For languages like C# and especially VB, which are increasingly context-dependant (for a C# example, consider all the LINQ keywords that aren't keywords if you use them in any other context), regular expressions simply cannot correctly determine what is or isn't a keyword in all situations. I have to date not seen a single syntax highlighter for the web that can handle LINQ correctly.

     

    The problem is that a syntax highlighter for the web can't just use a regular parser, because it has to deal with code snippets rather than complete code files. The code above isn't valid VB code on its own because it has no context. The syntax highlighting services used for editors like those in VB are able to deal with that up to a point, but they're not exactly simple, and as far as they're exposed in libraries I don't know what the license says about using them for highlighting for the web, and in any case it would require Visual Studio on the web server.

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.