While building parser assembly, we need to generate types for AST nodes. These type should have some organization making it easy to use them from different CLR languages.

Each syntax is identified by it's QSN (qualified syntax name), which include namespace, module(s) and syntax(es) on the way to syntax.

syntax module JetBrains.Languages.Java // module Java in namespace JetBrains.Languages
{
 syntax TypeDeclaration // QSN is JetBrains.Languages.Java.TypeDeclaration
 {
   syntax Modifiers // QSN is JetBrains.Languages.Java.TypeDeclaration.Modifiers
   { ... }
 }
}

We have to generate types for Java module, TypeDeclaration and Modifiers syntaxes. Hence, we are talking about mapping QSN to CLR type FQN.

Namespaces

For each name part of QSN except last generate namespace, last name part is type name. E.g. Modifiers type in JetBrains.Languages.Java.TypeDeclaration namespace.

Pros:

Nested types

Namespace maps to namespace, modules and syntaxes are mapped to types, nested within each other

namespace JetBrains.Languages
{
 class Java
 {
   class TypeDeclaration
   {
     class Modifiers {}
   }
 }
}

Pros:

Problems