Class RubyTarget

java.lang.Object
org.antlr.codegen.Target
org.antlr.codegen.RubyTarget

public class RubyTarget extends Target
  • Field Details

    • rubyKeywords

      public static final Set<String> rubyKeywords
      A set of ruby keywords which are used to escape labels and method names which will cause parse errors in the ruby source
    • sharedActionBlocks

      public static Map<String,Map<String,Object>> sharedActionBlocks
  • Constructor Details

    • RubyTarget

      public RubyTarget()
  • Method Details

    • genRecognizerFile

      protected void genRecognizerFile(Tool tool, CodeGenerator generator, Grammar grammar, org.stringtemplate.v4.ST outputFileST) throws IOException
      Overrides:
      genRecognizerFile in class Target
      Throws:
      IOException
    • getTargetCharLiteralFromANTLRCharLiteral

      public String getTargetCharLiteralFromANTLRCharLiteral(CodeGenerator generator, String literal)
      Description copied from class: Target
      Convert from an ANTLR char literal found in a grammar file to an equivalent char literal in the target language. For most languages, this means leaving 'x' as 'x'. Actually, we need to escape ' ' so that it doesn't get converted to \n by the compiler. Convert the literal to the char value and then to an appropriate target char literal. Expect single quotes around the incoming literal.
      Overrides:
      getTargetCharLiteralFromANTLRCharLiteral in class Target
    • getMaxCharValue

      public int getMaxCharValue(CodeGenerator generator)
      Description copied from class: Target
      Some targets only support ASCII or 8-bit chars/strings. For example, C++ will probably want to return 0xFF here.
      Overrides:
      getMaxCharValue in class Target
    • getTokenTypeAsTargetLabel

      public String getTokenTypeAsTargetLabel(CodeGenerator generator, int ttype)
      Description copied from class: Target
      Target must be able to override the labels used for token types
      Overrides:
      getTokenTypeAsTargetLabel in class Target
    • isValidActionScope

      public boolean isValidActionScope(int grammarType, String scope)
      Description copied from class: Target
      Is scope in @scope::name {action} valid for this kind of grammar? Targets like C++ may want to allow new scopes like headerfile or some such. The action names themselves are not policed at the moment so targets can add template actions w/o having to recompile ANTLR.
      Overrides:
      isValidActionScope in class Target
    • encodeIntAsCharEscape

      public String encodeIntAsCharEscape(int v)
      Overrides:
      encodeIntAsCharEscape in class Target