Petr Onderka
On Tue, Mar 27, 2012 at 23:56, Mike Krüger <mkru...@xamarin.com> wrote:
> Hi
>
> Try to look at NRefactory git://github.com/icsharpcode/NRefactory.git
> The structural visitor was built for that. NRefactory does:
> Text -> Mcs AST -> NRefactory AST
> That AST can generate C# code as text - using the output visitor, or just
> node.GetText(). Therefore it's half way done,
> however I'm sure that there are still things not fully correct, any help
> improving that would be appreciated.
>
> The NRefactory AST holds lexical informations about the tokens as well, they
> could be checked against the input text. There are 2 projects inside the
> NRefactory solution that may be helful: ConsistencyCheck and AstVerifier
> (it's very, very basic).
>
> Regards
> Mike
>>
>> Hi,
>>
>> as a backup if my first proposed project doesn't get selected,
>> I'm looking into implementing the project “AST Verifier for C# compiler”.
>>
>> The project statement says to implement an AST visitor and I have
>> looked around and found the class StructuralVisitor.
>> It seems to be exactly what I need, except it doesn't do anything by
>> itself.
>> I would expect it to visit the whole tree (just like ExpressionVisitor
>> does for Expressions),
>> so that I can implement only the parts that are relevant to me (in
>> this case, generating the C# code).
>>
>> Is there some code that already does that?
>> Or at least some code that implements StructuralVisitor that I could look
>> at?
>>
>> If not, that's fine, and I can do it myself. I just don't want to
>> duplicate work already done by others.
>>
>> Petr Onderka
>> _______________________________________________
>> Mono-devel-list mailing list
>> Mono-de...@lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
>
_______________________________________________
Mono-devel-list mailing list
Mono-de...@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list
some more questions:
I see that NRefactory doesn't deal with whitespace at all and
processes comments and preprocessor directives using SpecialsBag
that's not present in Mono.CSharp.
Can I ignore whitespace too? And does that mean I have to add (or copy
from NRefactory) support for comments and preprocessor directives to
the AST?
Thanks,
I would like to have whitespaces (and EOL as other special node) in the
ast as well as non compileable stuff as maybe TextNode, but that kills
performance even more. Doing pre processor directives and comments with
the specials bag and inserting them afterwards slows done the parse
process much. But they are semantically required (XmlDocs, #define etc.)
- and they are included in the AST, therefore it's all done on this
side. (Except there is some kind of comment/pre processor directive
missing there)
Would be easier if we had a lexer that was build for generating such AST
(btw. I think it may be possible to do it and use mcs as parser, but
that's another story).
Doing that for whitespaces isn't worth it atm - to have all information
about a file you need the CompilationUnit AND the text. It's possible to
get the whitespace information (that's the space between two nodes.
GetTextBetween (curNode.EndLocation, curNode.NextNode.StartLocation)
gives you that. (And lastNode.EndLocation - document.EndLocation is the
unparseable text). That is the major difference between us and rolyn,
but not a major drawback IMO the original text is always available.
The NRefactory version of mcs has some patches to make such thing as
NRefactory possible. We try to keep the change set low, but #1 prio is
that it works for monodevelop features.
Regards
Mike
> Hi,
>
> some more questions:
> I see that NRefactory doesn't deal with whitespace at all and
> processes comments and preprocessor directives using SpecialsBag
> that's not present in Mono.CSharp.
> Can I ignore whitespace too? And does that mean I have to add (or copy
> from NRefactory) support for comments and preprocessor directives to
> the AST?
>
> Thanks,
> Petr Onderka
>
_______________________________________________