Can I parse C functions with a regular expression in C#? [duplicate] - c#

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
Improve this question
For my diploma thesis I need to implement certain static C code analysis and I am desperately looking for a framework/library that would allow me to parse C source code, split it up into single functions, for every function determine what variables are changed in the function body and derive certain annotations for the code automatically.
Is there any good framework written in C# or generally as .Net class for this purpose?

What about googling for "C Parser written in C#"?
I got this as first link: http://code.google.com/p/cpp-ripper/
Also, I think the C grammar can be found in quite a lot of places, so you might just want to open up your .NET variant of lex/yacc and go from there?

You might like to check ANTLR. It comes with versions of several versions, included C and C#. There are some free grammars on ANTLR web site, including C.

I had a similiar problem and having done a research about YACC tools for C# I have chosen Gold Parsing System with Semantic Engine. My project was parsing SQL queries and generating logical query plans (from T-SQL grammar subset).
I really recommend it. Those 2 libraries make parsing stuff painless and allow to map grammar to the object model in your code. It feels very intuitive and made my project successful :) However, it may lack some advanced ANTLR features, so recognize your needs carefully.
Gold Project http://www.devincook.com/goldparser/
Semantic Engine Lib http://code.google.com/p/bsn-goldparser

If you're ok with using GPL'd code, you might want to take a look at the GCC source code. If you need to do it within .Net, you can always use p/invoke to call code from the GCC libraries.

Related

Creating a Pseudo Code and Diagram from C# Program [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
I have developed an application which is used to parse user utterances for the extraction of relevant information stored in the database.
The developed application has been purely developed using C# and consists of few functions, procedures etc.
I have been asked to produce Pseudo Code and Pseudo diagram for it to be used in the report for others to understand the flow of the developed application.
I am currently looking for a tool or software, which can help in producing above (especially Pseudo Code), as at the minute it seems a huge exploration of the code.
The type of code I am having to create of developed is as follow:
Many thanks for your help.
If you can afford to buy it, I recommend AthTek's flowchart to code. Its got a nice UI and its easy to use and it will generate pseudo code for a variety of languages, including C#, based on the flowchart.
Another good one, especially if you would like to have Visual Studio integration is Code Rocket. It integrates directly within Visual Studio and you can edit your flowchart or your pseudocode and both views stay in sync. It is great and its a little cheaper then AthTek!
If you need something free, try out DRAKON Editor. It's interface is not as intuitive as AthTek's software and it has a little more of a steeper learning curve and it does require ActiveTcl to use, but it is free! Here is a PDF Tutorial to get you up and going with C# using DRAKON Editor.
I would recommend NClass for generating diagrams. It is a free tool that generates UML diagrams. I do not know of any programs for automatically generating pseudocode though.
Its possible you could reverse engineer this project to get the pseudo code generator that you are looking for.

C# class documentation in a printable form [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
Our C# source code is comprehensively documented using the usual Sandcastle/XML notation. We use SHFB to compile this into a MSDN-style documentation website.
We now need to*1 compile the documentation into a printable form. Ideally, we would like a PDF document but the specific format is less important than its printability. It is important, but not critical, that the documentation looks relatively professional and can be branded with the corporate logos, etc.
Is there a mostly pain-free way to do this? I don't think individually printing every page of the documentation website is a practical choice. The intermediate XML documentation files can, in principle, be transformed into a useable format but maybe there is already a viable and maintained solution for this task?
*1 - for reasons that I don't fully comprehend.
Is there a mostly pain-free way to do this?
No, DO not do it. It makes zero sense for a class level documentation - noone will ever read it. TAll hyperlinks do not work, would have to be changed to page references.
Our C# source code is comprehensively documented using the usual Sandcastle/XML notation.
No, it is not. It is documented the normal XML documentation notation. Sandcastle did not invent it.
NOw, if you really have to do it:
http://www.innovasys.com/products/dx2011/csdocumentation.aspx?cpid=gawdxcs&gclid=COiJq5To8qwCFQGHDgod900o0g
is pretty much the best you can get to. The are specialized in exactly that (multi target stuff). They also handle the additional pages etc. which is needed - the pure clas reference, without index, jsut printed, with hyperlinks instead of page references is basically tree destruction without any sense.
Apparently Help and Manual can import Sandcastle projects directly and then output them in various formats (including printable ones).
I haven't tried this myself, though. I'd be interested to hear experiences from anyone who has.
Ndoc has a Latex documentor plug-in. NDoc supports all documentation tags supported by Sandcastle, so that should be able to compile the documentation into a Latex file. This can then be used to create, for example, a Postscript document for printing.

Are there any C# to C converter tools? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
Improve this question
I know C# is different from .NET Framework, C# is a programming language that standard by ECMA (ECMA-334) and ISO (ISO/IEC 23270).
I don't want a converter that converts ANY C# source code (including .NET Framework) to C, but I want a tool that converts an ECMA standard C# source code to ANSI C source code.
Something like java2c but for ECMA C#.
There is not exactly such thing, but the Vala programming language is able to take a source code very similar to C#, and generate C codem or compile it directly.
http://live.gnome.org/Vala
Of course, the only problem are the libraries: C# has a lot of API's that you'll have to provide, or modify your source code to adapt to the Vala standard library.
If you wanted to translate this code to C because you need it compiled, there are other possibilities.
For example, ngen in the microsoft world:
http://msdn.microsoft.com/en-us/library/6t9t5wcf(v=vs.80).aspx
In the mono project, you can create a single exe file with the interpreter and the libraries. Look for mkbundle:
http://www.mono-project.com/Mono:Runtime
Mono is able to compile "ahead of time", i.e., generate the native code even before the program is going to be executed, so it will run faster.
http://www.mono-project.com/Mono:Runtime#Ahead-of-time_compilation
Depends on what you mean. If you mean "Is it possible to convert C# to readable and maintainable C-code?", then sorry, the answer is no — C# features don't directly map to C.

Is there a Fix implementation running under mono? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
Is there an implementation of the fix protocol running under mono (either free or commercial) ?
I found the following ones, but none indicates if the code it's mono compatible :
QuickFix
VersaFix
Onixs
B2Bits
RA-Cheetah
I tried the 2 open sources solutions :
QuickFix doesn't work on Mono because the .net bindings are developed in C++/CLI, which is not supported by Mono.
VersaFix however does run under mono without any changes, and its performances are quite similar under both platforms.
One possible solution: http://www.fixprotocol.org/discuss/read/adec4479
Other than this, there is nothing specifically designed that I know of, but it does look like each of the engines you mentioned does have a separate forum or mailing list you could try.
I can tell you that the way QuickFix is designed can be a real pain due to the way is uses identical classes in separate namespaces for each version of FIX.
Sorry dont have a better answer, good luck.
I suggest using the MoMA tool provided by http://www.mono-project.com/MoMA. I took the first one you specified "QuickFix" and downloaded the Binary version and scanned it with MoMA. The result was 273 Method calls that are not implemented.
It may sound like a lot but just like compiler errors, you fix a couple of things and the number goes down fast, also you have good odds that the parts you need will be fine and with the source for QuickFix available you may be able modify the code as needed or just throw some try{...}catch wrappers around those problem functions that you do need to use.
Of course you can try the same thing on the other available products, I just tried the first one. I believe MoMA will also work on obfuscated code, so you could test it on trial versions too.
I'm looking into Quickfix/N, which claims to be an open-source native .Net port of Quickfix, without native C++ bindings. In fact the API looks very similar to Quickfix/J (The java port). I will update this post if I find it not to be Mono-compatible.

What are good tools for identifying potentially duplicated code for C# Express users? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
see also "Any tools to check for duplicate VB.NET code?"
A friend of mine only has access to the Express editions of Visual Studio and I am trying to help him refactor to remove a lot of duplication.
You could take a look at Simian or DuplicateFinder. Neither have a dependency on the IDE, although you can integrate Simian quite easily.
Clone Detective appears as though it might work for you. I haven't used it before, but I stumbled across it on codeplex this week.
Your friend should take a look at Gendarme, a FOSS and cross-platform alternative to Microsoft's FxCop/Code Analysis which is part of the Mono project. It includes rules that check for duplicated code.
Try Atomiq:
Atomiq Code Similarity Finder is a tool for developers to find and eliminate duplicate code. It is designed for .NET developers, but works equally well for developers of other languages and even web designers!
Atomiq works with a wide variety of source code:
We currently support C#, VB.Net, ASPX, Ruby, Python, Java, C, C++,
ActionScript, and XAML, with more extensions on the way soon. It is
the perfect companion tool for someone who updates their code
infrequently and can't possibly remember everything in it or for a
team of 2 or more developers working on the same project that don't
know everything in it since they didn't write it all themselves.
Eliminate similar code
(and the banging your head against the wall that comes with it) Atomiq
doesn't just find exact matches, it finds similar code. It ignores
"fluff" like whitespace, string content, curly braces, comments and
using/import statements so you can find the duplicate code that causes
problems. In VB.NET, it will also ignore lines that contain only
"Next", "End While", "End Try", "End If", "End Property", "End Get"
and "End Set".
More as fyi, since you mentioned 'express edition' you might need to look for something that would work outside of VS, since I don't believe the express editions support plugins
See our CloneDR, which operates on many langauges, including C#.
EDIT October 2010: VB6, VBScript and VB.net added as languages supported by CloneDR.
There is no specific support for MS IDEs, but it operates on a simple list of source files, and produces a nice HTML report, so not much integration is needed. See sample reports at link.

Categories

Resources