My Links
Post Categories
Archives
- May, 2008 (1)
- March, 2008 (3)
- February, 2008 (2)
- January, 2008 (1)
- November, 2007 (2)
- October, 2007 (3)
- August, 2007 (1)
- July, 2007 (10)
- June, 2007 (3)
- May, 2007 (7)
- April, 2007 (1)
- February, 2007 (1)
- January, 2007 (6)
- December, 2006 (2)
- November, 2006 (1)
- August, 2006 (1)
- July, 2006 (1)
- February, 2006 (1)
- January, 2006 (6)
- November, 2005 (1)
- October, 2005 (1)
- September, 2005 (1)
- August, 2005 (2)
- July, 2005 (2)
- May, 2005 (1)
- March, 2005 (7)
- February, 2005 (4)
- January, 2005 (2)
- December, 2004 (1)
- November, 2004 (1)
- October, 2004 (3)
- September, 2004 (2)
- August, 2004 (6)
- July, 2004 (2)
- June, 2004 (2)
- May, 2004 (4)
- April, 2004 (2)
- March, 2004 (3)
- November, 2003 (8)
- October, 2003 (13)
|
**Update** This project eventually became Xamlon, and eventully became "no longer available". However if you are looking for a C# parser, there is a new one here. Promise I won't sell or otherwise tank this one : ).
So I've given up on using the CodeDom for this parser, instead I'm using a 'CSharpDom', and it should be easy enough to suck a valid CodeDom file out of it. There may be some ugliness, maybe even a required library with things like UnaryInc(ref expr) etc. Anyway, fair enough.
I'll post the Basic structure I have now, and once again when it is done. There are a few things that haven't been filled out, and some of the innards and niceties (like constructor overloads) etc are in progress. There will also be ways of walking it with a visitor. It is certainly still being juggled a bit, so if you have any comments... You *definitely* want an ide that does code folding if you look at it as all the classes are in two files, and there is a ton of gen'd code. (I've been using CodeSmith, wonderful tool!)
The good news is the CSharp parser now is very close to filling that all in. I've been working from top down, and only have expressions left to go. The parser is already parsing everything into an AST, so it isn't too hard to munge in -- that is, until it exposes errors in the parse ; ). I will try to throw that into some form of tree display in the end. Actually I've been making icons during breaks, wanna see?
Ok, don't quit the day job. If I had no shame I'd just steal Visual Studio's like everyone else. Wait - I have no shame. Timesaver god.
posted on Saturday, March 13, 2004 4:15 AM
Feedback
-
Posted @ 3/15/2004 3:45 PM
Sweet boob Robin. :)
-
Posted @ 3/25/2004 1:08 PM
Hi Robin,
I stumbled upon your blog while trying to find out if there were any C# and/or VB.NET code parsers available. I am working on a code generator and plan to use the codedom to generate both C# and VB.NET code to fit a predefined framework. I would love to be able to re-read the "generated code" at a later date and allow the user to modify it using the code generator (i.e. parse it and import it into a codedom). I would present the codedom in both a treeview and code preview format. I have to be honest here and admit that after viewing your work and reading your blogs, your work is a bit above me. I am afraid that I am not even sure of the right questions to ask here. Basically, what are my options in finding a C# and VB.NET parser that can read a class1.cs or class1.vb file and convert it to a codedom? Is what I am trying to do possible or should it be avoided? I am busy trying to figure out your CSharpDom and I've read a bit about ANTLR. I am beginning to visualize what you're accomplishing. Does Microsoft offer any tools that might help me. I am very familiar with CodeSmith and it is used by a lot of guys in the CSLA.NET forum. Although there are limitations to the codedom I think it will work for my limited scope.
Sincerely,
Chris Russi
-
Posted @ 3/27/2004 1:24 AM
Hey Chris,
All of what you are doing sounds very do-albe. The problem I think you will have is the first step, using the codeDom to generate the files. If you already have that creating the code you want, then you are probably better off serializing that and using that to regenerate the code. The problem is if you have generic code that wasn't created by your tool you have to parse it and get it into some form to tree or graph structure. For that you would need something like this parser - but if you can avoid it life is easier... That is were the CodeDom starts to fall down, because you are faced with having to reject valid code (or do a lot of work to get ugly code). I would say if you can gen code using the codeDom that is your best bet, esp if you are going to VB as well. For a tool that only generates and deals with code it generated that should work fine...
I don't think there is a parser from Microsoft that can give you the code tree to work with. I assume Mono has one if you are working within that environment. I will have a new version of this up soon, just hooking up the things I put off now, like attributes etc. That has the full c#Dom, as well as a less buggy and slightly more sensible antlr tree.
Cheers,
Robin
PS I'm really bad at explaining things, it isn't really that complicated. It looks gigantic and complex, but really it is about 10 concepts repeated over and over (and over and over!). The concepts don't really jump out from the code though, I will try to make a doc about some of the (good and poor) choices I made at one point...
-
Posted @ 3/28/2004 2:33 PM
Hi Robin,
Thanks for your reply. From your vantage point it might not seem that complicated. Your ability to recognize the pattern of roughly 10 concepts repeated over and over is sign of experience. That is, your mind is seeing the obvious pattern. To a novice, what you're doing seems quite complex.
Your advice on how best to use (or not use) the codedom was great. In fact, since leaving my post, I have seen this same advice on other sites. Hearing several experts saying the same thing leads me to accept the idea that there are limitations with the codedom. I particularly liked your idea of serializing the codedom and have the user deserialize the codedom and make modifications to THAT instead of trying to parse modified code. I like that idea and will explore it.
One thing that isn't clear to me is whether or not your parser is open source or not. In other words, when completed, will your product be available for download and for use in other people's projects. Will there be a cost? Will your parser read c# code and convert it to a code tree to work with?
Sincerely,
Chris Russi
-
Posted @ 3/29/2004 8:17 PM
Hey Chris,
Well I can recognise the patterns in what I made, all bets are off if I look at similar code from others though.. Also, antlr itself is pretty cryptic in its syntax and more so in the generated code (and still better than most there!). Ideally all people will have to look at is the c#dom part, unless they want to use just the antlr tree, in which case they just need the grammar.
There will be a free ($) component, and there will be charge part, I haven't decided where that line will go - but certainly for most uses at least the parser/csdom will be free. It won't be gpl or anything though - frankly I just don't give enough of a crap other people's development model for that. Either you want their money or you don't - no one should have to join a cult ; ).
-
Posted @ 6/26/2004 9:14 PM
Brrr. Yet another one of these libraries. Can't you just write the parser against the Reflector 4.0 CodeModel? That way we could benfit from using it in Reflector.
|
|
Blog Stats
- Posts - 121
- Stories - 1
- Comments - 1441
- Trackbacks - 47
.Net Blogs
01101 Blogs
Flash Blogs
Graphics
People
|
|