Package org.antlr.codegen
Class RubyTarget
- java.lang.Object
-
- org.antlr.codegen.Target
-
- org.antlr.codegen.RubyTarget
-
public class RubyTarget extends Target
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classRubyTarget.RubyRenderer
-
Field Summary
Fields Modifier and Type Field Description static java.util.Set<java.lang.String>rubyKeywordsA set of ruby keywords which are used to escape labels and method names which will cause parse errors in the ruby sourcestatic java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Object>>sharedActionBlocks-
Fields inherited from class org.antlr.codegen.Target
targetCharValueEscape
-
-
Constructor Summary
Constructors Constructor Description RubyTarget()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringencodeIntAsCharEscape(int v)protected voidgenRecognizerFile(Tool tool, CodeGenerator generator, Grammar grammar, org.stringtemplate.v4.ST outputFileST)intgetMaxCharValue(CodeGenerator generator)Some targets only support ASCII or 8-bit chars/strings.java.lang.StringgetTargetCharLiteralFromANTLRCharLiteral(CodeGenerator generator, java.lang.String literal)Convert from an ANTLR char literal found in a grammar file to an equivalent char literal in the target language.java.lang.StringgetTokenTypeAsTargetLabel(CodeGenerator generator, int ttype)Target must be able to override the labels used for token typesbooleanisValidActionScope(int grammarType, java.lang.String scope)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.-
Methods inherited from class org.antlr.codegen.Target
genRecognizerHeaderFile, getTarget64BitStringFromValue, getTargetStringLiteralFromANTLRStringLiteral, getTargetStringLiteralFromString, getTargetStringLiteralFromString, performGrammarAnalysis, postProcessAction, useBaseTemplatesForSynPredFragments
-
-
-
-
Field Detail
-
rubyKeywords
public static final java.util.Set<java.lang.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 java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Object>> sharedActionBlocks
-
-
Method Detail
-
genRecognizerFile
protected void genRecognizerFile(Tool tool, CodeGenerator generator, Grammar grammar, org.stringtemplate.v4.ST outputFileST) throws java.io.IOException
- Overrides:
genRecognizerFilein classTarget- Throws:
java.io.IOException
-
getTargetCharLiteralFromANTLRCharLiteral
public java.lang.String getTargetCharLiteralFromANTLRCharLiteral(CodeGenerator generator, java.lang.String literal)
Description copied from class:TargetConvert 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:
getTargetCharLiteralFromANTLRCharLiteralin classTarget
-
getMaxCharValue
public int getMaxCharValue(CodeGenerator generator)
Description copied from class:TargetSome targets only support ASCII or 8-bit chars/strings. For example, C++ will probably want to return 0xFF here.- Overrides:
getMaxCharValuein classTarget
-
getTokenTypeAsTargetLabel
public java.lang.String getTokenTypeAsTargetLabel(CodeGenerator generator, int ttype)
Description copied from class:TargetTarget must be able to override the labels used for token types- Overrides:
getTokenTypeAsTargetLabelin classTarget
-
isValidActionScope
public boolean isValidActionScope(int grammarType, java.lang.String scope)Description copied from class:TargetIs 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:
isValidActionScopein classTarget
-
encodeIntAsCharEscape
public java.lang.String encodeIntAsCharEscape(int v)
- Overrides:
encodeIntAsCharEscapein classTarget
-
-