Child pages
  • Module syntax

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

With the nested syntax rules, there is hardly any difference between syntax and module
We discussed and decided that syntax module is good for isolation, grouping and validation purpose.

Code Block
syntax module JetBrains.Nitra.N2Syntax
{
  token field OpenBrace           = "(";
  span class String;

  ...
}

Import syntax directive can be explicit and is not confused with namespace imports:

Code Block
using System; // types from System namespace are available unqualified in this scope

import JetBrains.Nitra.N2Syntax; // rules from N2 syntax module are available unqualified in this scope

syntax module JetBrains.Nitra.N2SyntaxExtensions
{
  extend syntax TokenRule
  { // syntax from JetBrains.Nitra.N2Syntax.TokenRule is available unqualified in this scope implicitly
  ...
  }

  syntax CustomRule
  {
    import JetBrains.Json; // json syntax available inside CustomRule without qualification

    | Identifier // json identifier
    | String
  }
}