How to parse antlr grammar's written in JAVA using C# - antlr3

Can we able to use antlr grammars (written in java) in visual studio using C#?
I am facing one problem with antlr grammar's that are JAVA target but I want C# target grammars and i couldn't get C# target grammars. So, my question is can we use those antlr JAVA targeted grammars in C#.

Your question title is misleading. ANTLR grammars are written in ANTLR's grammar language, not Java or C#. But I guess your real question is: can we use a parser, generated for the Java target, also with C#. And the obvious answer is: no. The generated code is Java, how can you use that in C#? You have to generate C# code.

Related

how do I create readable C++/CX document from XML generated by Visual Studio 2015

My project is written in C++/CX on VS2015 and I am seeking a way to generate API documentation.
After googling and stackoverflow, I have tried doxygen, VSDocman,NDoc, Atomineer Pro Documentation and SandCastle, I found these tools do not support C++/CX syntax, therefore, they cannot generate correct document.
I also tried to generate XML file which VS supports. But it's hard to read XML file.
How do I generate API documentation from C++/CX? Thanks for any suggestion
There are a lot of misconceptions about the C++/CX language extension. You tried too many products that have no hope of getting you anywhere. First and foremost is that it is a native C++ extension and does not generate a .NET compatible assembly. So knock out any that try to use Reflection to parse metadata. Out goes NDoc, VSDocman, Sandcastle. Atomineer is out, it is just an editor add-in.
So all you got left is doxygen.
Sure, it doesn't know about C++/CX out of the box. The FAQ points out that in order to make it compatible with a language, you need to modify src/scanner.l
Having a look at it, I see it already supports the C++/CLI extension. That's another C++ language extension that supports generating MSIL. C++/CX syntax is very close to C++/CLI. Just some minor differences, like the gcnew keyword is too misleading and replaced by ref new. But that's not the kind of syntax that doxygen cares about, it just wants to know about declarations. Those keywords are the same.
So the only obstacle I can guess at is that you just forgot to tell it about the language. It can't guess at it correctly from just the filename extension, .cpp and .h will get it to parse plain C++. Modify or add this line in the config file:
CPP_CLI_SUPPORT = YES
And tweak scanner.l if necessary.

What is CustomBuildRule equivalent in C#?

I'd like to add a code generator for given filetype. I came across this example which uses CustomBuildRule. It seems this is only available for C++ projects. Is there an equivalent for C# projects?

Can ANTLR lexers/parsers be used for VS syntax highlighting and Error List?

I'm happily developing a language in ANTLR 4.4 / ANTLR4CS, and I'd like to start integrating my language into an IDE. The natural place for me feels like integrating it into Visual Studio. It occurs to me that someone might have figured out a general way to plug an ANTLR lexer into the Visual Studio syntax highlighting system, or ANTLR parsers into an MSBuild task such that errors appear in the Visual Studio error list.
Is there any kind of starting point, base package, plugin system, or similar which lets you integrate an ANTLR4CS language with Visual Studio's language support mechanisms?
Alternatively, has anyone had any success building, say, a Sublime Text build system / language def automatically from their grammar?
#Lucas Trzesniewski wrote:
I did this by reparsing the whole file every time, doing it on a line-by line basis was too much of a PITA for my needs (and our DSL files are small so it works fine).
I don't know if it'll be suitable for your needs, but you can implement a single file generator from a VS extension. The Generate method takes a IVsGeneratorProgress parameter which lets you report errors easily.

Syntax-Highlighting for lex and yacc in Visual-Studio

I want to add support for syntax highlighting for lex and yacc-files in Visual Studio 2010.
How can I do this?
Following the given link to Syntax Coloring leads to another, more pertinent page Implementing Syntax Coloring, where it is noted
Visual Studio does not specify a parser interface, and parser implementation is completely up to you. However, a default parser implementation is provided in the Visual Studio Language Package project. For managed code, the managed package framework (MPF) provides complete support for colorizing text.
Depending on what you want:
trivial, coloring only the C code portions of the lex/yacc files
much harder, coloring the patterns so that one can make sense of them
you could in principle make a parser using just lex (yacc isn't necessary). For yacc files, that's not so hard, but for lex there's the complication of regular expressions. vi-like-emacs does that and while the interface differs in detail, conceptually it's similar. Reading the lexers might give you some ideas how to apply that approach:
lex syntax filter
yacc syntax filter
There is documentation from Microsoft on integrating yacc/bison & flex/lex with Visual Studio. Although a URL only link is discouraged on SO, its best to go to the source for this kind of detailed information:
https://msdn.microsoft.com/en-us/library/aa730877(VS.80).aspx#vccustombr_topic3
It lays out all the steps necessary for integrating with the build tools. Syntax highlighting is covered elsewhere as described in Add a new language to Visual Studio 2010 with syntax highlighting and intellisense. In particular the guidance for syntax colouring can be found here: https://msdn.microsoft.com/en-us/library/bb166778(v=vs.100).aspx.
However, I'm not aware of anyone who has published extra colouring rules for the grammar specific components of flex and yacc. However, most of the body of flex and yacc files are written in C or C++ for which there are syntax highlighting rules that can be applied, and suit most peoples needs.

T4 template for Ruby or Java

I am using T4 for generating code. With Visual Studio I could generate code in C# or VB. What is required for generating code in Ruby or Java ?
I have a some utility classes that is required in multiple language (C#, Ruby and Java). I am looking for defining T4 templates...
Thanks
With a standard T4 template, you can generate any code, but what comes out is part of your project. While you can generate any kind of text, this is really most useful if you're compiling the code that comes out.
With VS2010, you can now use a T4 PreProcessed Template. Instead of generating a text file, you generate the generator. Making the generator instead of the resulting code should give you lots of flexibility with integrating your Java/Ruby output.
Anything can come out of the generator, but I think you still have to write the actual T4 code in VB or C#.
You can generate code in any language using T4 or indeed any other textual artifact.
You just need to start with an example of what you want to generate and begin to parameterize it.
Only the code generation control code inside the template needs to be in C# or VB.

Resources