[Mono-dev] GSoC - AST Verifier for C# compiler
Mike Krüger
mkrueger at xamarin.com
Thu Mar 29 08:09:04 UTC 2012
Hi
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
>
More information about the Mono-devel-list
mailing list