简体   繁体   中英

Looking for C90 Grammar compatible with ANTLR 4 or MPlex/MPPG

I wrote a C90 cross-compiler in C# for a friend's custom CPU which produces a text file containg assembly language. I then feed this to an assembler he wrote in Python, which produces a text file containing machine code. We then transmit this to his machine via a serial connection, and at this point his custom CPU runs the program.

I would like to bundle this whole process into something as simple as pressing the 'compile' button, as you would do in any modern IDE. Also, speaking of modern IDE's, it would be nice to develop our C code in something other than Notepad and enjoy some of the amenities these modern IDE's have to offer such as file management, in-place compilation, syntax highlighting, and intelli-sense.

Now, I use Visual Studio for most of my development so I am well aware that it already comes bundled with a C/C++ compiler. It would be really nice to be able to use Visual C++ to develop C code for our custom CPU and override it's 'compile' feature so that it invokes my compiler tool-chain instead of its C++ compiler.

The problem I envision with this approach is that:

  1. I don't think it's possible to override the 'compile' feature and
  2. the syntax highlighting/intelli-sense will not conform to the C90 standard. I can live with #2 but I would like to know if #1 is possible.

Failing this I would need to bite the bullet and integrate my custom compiler into Visual Studio and doing so requires that I have a C90 grammar file that's compatible with either ANTLR or MPlex/MPPG so that I can output a parser/scanner in C# that Visual Studio can use for it's syntax highlighting/intelli-sense.

The grammar file I see listed on the ANTLR site is C99; does anyone know of a C90 implementation? http://slps.github.io/zoo/#ANSI_C90 seems to have one but the grammar is in BGF, EBNF, DMS BNF, and SDF formats that I believe are not compatible with either of the tools I mentioned. Any help would be appreciated.

The new MSBuild-based Visual C++ toolchain which shipped starting with Visual Studio 2010 provides framework-level support for non-Microsoft toolchains. You'll still need to provide build files specific to your compiler, but you would be able to cleanly integrate the result into Visual Studio.

I don't know of any cases where someone's actually done this though.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM