如何创建在Visual Studio中使用一种新的语言 [英] How to create a new language for use in Visual Studio

查看:474
本文介绍了如何创建在Visual Studio中使用一种新的语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写一个新的模板语言,我想Visual Studio的支持了。我需要知道的是:

I want to write a new templating language, and I want Visual Studio to "support" it. What I need to know is:


  1. 如何我分析我的新的语言?结果
    鉴于一些code在我的新模板语言,我怎么把它翻译成HTML?现在,我经常使用前pressions解析它​​通过令牌的道理,但我不认为这会很好地进行缩放的语言变得更为复杂,而且也没有错误检查。我听说过ANTLR的,但从来没有使用过。那会是这种工作的工具,或者是有可能更简单的东西?理想情况下,我想送的任何语法错误的错误窗口像其他语言做的尽可能详细的信息(行号,错误类型)。

  2. 如何创建的Visual Studio新的文件类型?

  3. 如何,我得到的语法高亮?结果
    我可以用我在步骤1中创建的同一个解析器,或者这是完全不同的东西?

  4. 如何获得智能感知?

  1. How do I parse my new language?
    Given some code in my new template language, how do I translate it into HTML? Right now I'm using regular expressions to parse it token by token, but I don't think this is going to scale very well as the language gets more complicated, and there's no error checking. I've heard of ANTLR but never used it. Would that be the right tool for this job, or is there perhaps something simpler? Ideally I'd like to send any syntax errors to the error window with as much information as possible (line #, type of error) like other languages do.
  2. How do I create a new file type for Visual Studio?
  3. How do I get syntax highlighting?
    Can I use the same parser I created in step 1, or is this something entirely different?
  4. How do I get Intellisense?

我倒是preFER写我的解析器在C#。

I'd prefer to write my parser in C#.

推荐答案

我想看看那个已经做好了与Visual Studio集成的跑腿另一种语言。一个很好的例子是嘘声。语言和Visual Studio集成都是开源的。所以,你可以看看究竟他们不得不做的事情。

I would take a look at another language that has already done the legwork of integrating with Visual Studio. A great example is Boo. The language and Visual Studio integration are open source. So you can take a look at exactly what they had to do.

  • Boo Language: https://github.com/boo/boo-lang
  • Boo Syntax Highlighting for VS2010 (VSX add-in): http://vs2010boo.codeplex.com/
  • Boo Language Studio (syntax highlighting for VS2008): http://boolangstudio.codeplex.com/

该嘘语法高亮VS2010包括在其主页上,我会为便于参考复制一些推荐的链接:

The Boo Syntax Highlighting for VS2010 includes some recommended links on its homepage, which I'll copy for easy reference:


  • 有关在VS 2010中分类(语法highligting)尼斯文章:的http://dotneteers.net/blogs/divedeeper/archive/2008/11/04/LearnVSXNowPart38.aspx

  • 为VSX例子加载项:<一href=\"http://blogs.msdn.com/vsxteam/archive/2009/06/17/new-editor-samples-for-visual-studio-2010-beta-1.aspx\" rel=\"nofollow\">http://blogs.msdn.com/vsxteam/archive/2009/06/17/new-editor-samples-for-visual-studio-2010-beta-1.aspx

这篇关于如何创建在Visual Studio中使用一种新的语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆