Top Inners Fields Constructors Methods
org.antlr.codegen

public Class RubyTarget

extends Target
Class Inheritance
Imports
org.antlr.Tool, org.antlr.tool.Grammar, org.stringtemplate.v4.AttributeRenderer, .ST, .STGroup, java.io.IOException, java.util.*

Nested and Inner Type Summary

Modifier and TypeClass and Description
public class

Field Summary

Modifier and TypeField and Description
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

public static Map<String, Map<String, Object>>
Inherited from org.antlr.codegen.Target:
targetCharValueEscape

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String
protected void
public int
getMaxCharValue(CodeGenerator generator)

Overrides org.antlr.codegen.Target.getMaxCharValue.

Some targets only support ASCII or 8-bit chars/strings.
public String
getTargetCharLiteralFromANTLRCharLiteral(CodeGenerator generator, String literal)

Overrides org.antlr.codegen.Target.getTargetCharLiteralFromANTLRCharLiteral.

Convert from an ANTLR char literal found in a grammar file to an equivalent char literal in the target language.
public String
getTokenTypeAsTargetLabel(CodeGenerator generator, int ttype)

Overrides org.antlr.codegen.Target.getTokenTypeAsTargetLabel.

Target must be able to override the labels used for token types
public boolean
isValidActionScope(int grammarType, String scope)

Overrides org.antlr.codegen.Target.isValidActionScope.

Is scope in @scope::name {action} valid for this kind of grammar?
Inherited from org.antlr.codegen.Target:
genRecognizerHeaderFilegetTarget64BitStringFromValuegetTargetStringLiteralFromANTLRStringLiteralgetTargetStringLiteralFromStringgetTargetStringLiteralFromStringperformGrammarAnalysispostProcessActionuseBaseTemplatesForSynPredFragments

Field Detail

rubyKeywordsback to summary
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

sharedActionBlocksback to summary
public static Map<String, Map<String, Object>> sharedActionBlocks

Constructor Detail

RubyTargetback to summary
public RubyTarget()

Method Detail

encodeIntAsCharEscapeback to summary
public String encodeIntAsCharEscape(final int v)

Overrides org.antlr.codegen.Target.encodeIntAsCharEscape.

Annotations
@Override
genRecognizerFileback to summary
protected void genRecognizerFile(Tool tool, CodeGenerator generator, Grammar grammar, ST outputFileST) throws IOException

Overrides org.antlr.codegen.Target.genRecognizerFile.

Annotations
@Override
getMaxCharValueback to summary
public int getMaxCharValue(CodeGenerator generator)

Overrides org.antlr.codegen.Target.getMaxCharValue.

Doc from org.antlr.codegen.Target.getMaxCharValue.

Some targets only support ASCII or 8-bit chars/strings. For example, C++ will probably want to return 0xFF here.

Annotations
@Override
getTargetCharLiteralFromANTLRCharLiteralback to summary
public String getTargetCharLiteralFromANTLRCharLiteral(CodeGenerator generator, String literal)

Overrides org.antlr.codegen.Target.getTargetCharLiteralFromANTLRCharLiteral.

Doc from org.antlr.codegen.Target.getTargetCharLiteralFromANTLRCharLiteral.

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.

Annotations
@Override
getTokenTypeAsTargetLabelback to summary
public String getTokenTypeAsTargetLabel(CodeGenerator generator, int ttype)

Overrides org.antlr.codegen.Target.getTokenTypeAsTargetLabel.

Doc from org.antlr.codegen.Target.getTokenTypeAsTargetLabel.

Target must be able to override the labels used for token types

Annotations
@Override
isValidActionScopeback to summary
public boolean isValidActionScope(int grammarType, String scope)

Overrides org.antlr.codegen.Target.isValidActionScope.

Doc from org.antlr.codegen.Target.isValidActionScope.

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.

Annotations
@Override
org.antlr.codegen back to summary

public Class RubyTarget.RubyRenderer

extends Object
implements AttributeRenderer
Class Inheritance
All Implemented Interfaces
org.stringtemplate.v4.AttributeRenderer

Field Summary

Modifier and TypeField and Description
protected String[]

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private String
private String
private String
private String
label(String value)

private String
private String
private String
private String
snakecase(String value)

given an input string, which is presumed to contain a word, which may potentially be camelcased, and convert it to snake_case underscore style.

private String
private String
symbol(String value)

public String
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

rubyCharValueEscapeback to summary
protected String[] rubyCharValueEscape

Constructor Detail

RubyRendererback to summary
public RubyRenderer()

Method Detail

camelcaseback to summary
private String camelcase(String value)
constantcaseback to summary
private String constantcase(String value)
constantPathback to summary
private String constantPath(String value)
labelback to summary
private String label(String value)
lexerRuleback to summary
private String lexerRule(String value)
platformback to summary
private String platform(String value)
rubyStringback to summary
private String rubyString(String value)
snakecaseback to summary
private String snakecase(String value)

given an input string, which is presumed to contain a word, which may potentially be camelcased, and convert it to snake_case underscore style. algorithm -- iterate through the string with a sliding window 3 chars wide example -- aGUIWhatNot c c+1 c+2 action a G << 'a' << '_' // a lower-upper word edge G U I << 'g' U I W << 'w' I W h << 'i' << '_' // the last character in an acronym run of uppers W h << 'w' ... and so on

subcamelcaseback to summary
private String subcamelcase(String value)
symbolback to summary
private String symbol(String value)
toStringback to summary
public String toString(Object o, String formatName, Locale locale)

Implements org.stringtemplate.v4.AttributeRenderer.toString.

Annotations
@Override