Child pages
  • Node type generation
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

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.

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:

  • Simple and easy to compose
    Cons:
  • Namespaces will collide with type names, e.g. for TypeDeclaration, and C# doesn't like this.

Nested types

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

Pros:

  • Cons:
  • You can't add "using" for type in C# and user have to specify full nested type name all the time

Problems

  • Too many types slows down assembly loading
  • Name ambiguity problem:
  • No labels