Class TextDfnGenerator

java.lang.Object
org.ek9lang.compiler.phase7.AbstractDfnGenerator
org.ek9lang.compiler.phase7.TextDfnGenerator
All Implemented Interfaces:
Function<EK9Parser.TextDeclarationContext, IRConstruct>

final class TextDfnGenerator extends AbstractDfnGenerator implements Function<EK9Parser.TextDeclarationContext, IRConstruct>
Creates the appropriate IR Construct for a text declaration.

Text constructs are EK9's first-class internationalization (i18n) system that provides:

  • Compile-time validation of translation completeness
  • Type-safe parameters for text templates
  • String interpolation within text bodies
  • Runtime locale selection

Deals with the following ANTLR grammar:

  textDeclaration
    : identifier AS? NL+ INDENT NL* (directive? textBodyDeclaration NL+)+ DEDENT
    ;

  textBodyDeclaration
    : identifier (LPAREN RPAREN)? NL+ INDENT NL* argumentParam? directive? stringLit NL+ DEDENT
    ;

Text body methods have an implicit String return type. The stringLit IS the return value. This is different from regular methods where you declare <- rtn as String.