Building Syntax Trees

Started by
11 comments, last by evolutional 19 years, 10 months ago
The C# compiler is recursive descent. You can see the main parser file here: http://sharedsourcecli.sscli.net/source/browse/sharedsourcecli/clr/src/csharp/csharp/sccomp/parser.cpp?rev=1.1.1.1&content-type=text/vnd.viewcvs-markup

The JScript.NET compiler included in Rotor is also recursive descent, but written in C#: http://sharedsourcecli.sscli.net/source/browse/sharedsourcecli/jscript/engine/jsparser.cs?rev=1.1.1.1&content-type=text/vnd.viewcvs-markup

--
AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.
[Project site] [Blog] [RSS] [Browse the source] [IRC channel]
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
Advertisement
quote:Original post by downgraded
Out of interest, which features of C++/C# would make it harder to parse? Are we talking class structures or pointer indirection?
There are a bunch of wrinkles (particularly in C++) that require that the parser get all mixed up with the semantic analyzer. For instance i < j && k > l could either be an expression or a template instantiation, depending on what i is.

As long as you''re willing for your language to not ape C++, it shouldn''t be a big deal.
"There is only one everything"
That is interesting that C# is a recursive descent parser.

The C++ language requires alot of state management and I would think that complexity is what would drive you mad. The state management of the compiler is what becomes complex, not really the parser, but because the state management is mixed in with the parser it becomes a nightmare to remember what you were doing.

The original K&R C compilers were very simple really.


Peace

This topic is closed to new replies.

Advertisement