Syntactic Reader (Extension of Visual Studio 2013)

Asked

Viewed 155 times

4

By syntactically reading a language in a Visual Studio extension project I can already read the following:

<span class="myclass"></span>

It is relatively easy to manage read states InTag, AttributeNaming, AttributeValue (created these states). Make the correct color application by the Colorizer class and everything else.

The problem:

Visual Studio through its API sends me the code line by line waiting for me to return the tokens read. How do I read a broken line?

<span
      class="myclass"></span> <!-- Meu parser verá erros e textos apenas -->

Is there any way to group these lines? Code outlining helps in these cases? How do I use it?

inserir a descrição da imagem aqui

In this case for example, reading a more complex language, how could I create the outlining and indetify the states? A; In namespace, B: class name declaration, C: in class, D,: method declaration, E: method name, F: method body, for example.

  • 1

    Nice going there, huh? You’re writing in open source?

  • 1

    is an extension project of Visual Studio itself, using its own SDK.

1 answer

1

In his parser, if you are using regular expression to identify the tokens and C#, you must enable the option Multiline (m) when executing the match of tokens according to your standard.

I’ve had to create some parsers and I’ve always had a lot of basic problems, so I found the tool ANTLR.

This tool generates parsers from a grammar. Perhaps, in your case, it’s easier to write the grammar than you need to identify and have the ANTLR manage the parser for you.

The ASP.NET MVC Bundle uses ANTLR to interpret javascript and css and minify them. So this is a reliable tool and, let’s say, "well-tested".

  • I appreciate the @Maia answer but the question is not how to parse but how to work with the extension to read multiple lines, because I just implement an interface... and one of its methods brings me the code "line by line"

Browser other questions tagged

You are not signed in. Login or sign up in order to post.