| Modifier and Type | Field and Description |
|---|---|
| protected String[] | targetCharValueEscape
For pure strings of Java 16-bit unicode char, how can we display it in the target language as a literal. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public String | |
| protected void | |
| protected void | genRecognizerHeaderFile(Tool tool, CodeGenerator generator, Grammar grammar, ST headerFileST, String extName)
|
| public int | |
| public String | getTarget64BitStringFromValue(long word)
Convert long to 0xNNNNNNNNNNNNNNNN by default for spitting out with bitsets. |
| public String | getTargetCharLiteralFromANTLRCharLiteral(CodeGenerator generator, String literal)
Convert from an ANTLR char literal found in a grammar file to an equivalent char literal in the target language. |
| public String | getTargetStringLiteralFromANTLRStringLiteral(CodeGenerator generator, String literal)
Convert from an ANTLR string literal found in a grammar file to an equivalent string literal in the target language. |
| public String | getTargetStringLiteralFromString(String s, boolean quoted)
Given a random string of Java unicode chars, return a new string with optionally appropriate quote characters for target language and possibly with some escaped characters. |
| public String | |
| public String | getTokenTypeAsTargetLabel(CodeGenerator generator, int ttype)
Target must be able to override the labels used for token types |
| public boolean | isValidActionScope(int grammarType, String scope)
Is scope in @scope::name {action} valid for this kind of grammar? |
| protected void | |
| public List | postProcessAction(List<Object> chunks, Token actionToken)
Give target a chance to do some postprocessing on actions. |
| public boolean |
| targetCharValueEscape | back to summary |
|---|---|
| protected String[] targetCharValueEscape For pure strings of Java 16-bit unicode char, how can we display it in the target language as a literal. Useful for dumping predicates and such that may refer to chars that need to be escaped when represented as strings. Also, templates need to be escaped so that the target language can hold them as a string. I have defined (via the constructor) the set of typical escapes, but your Target subclass is free to alter the translated chars or add more definitions. This is nonstatic so each target can have a different set in memory at same time. | |
| Target | back to summary |
|---|---|
| public Target() | |
| encodeIntAsCharEscape | back to summary |
|---|---|
| public String encodeIntAsCharEscape(int v) | |
| genRecognizerFile | back to summary |
|---|---|
| protected void genRecognizerFile(Tool tool, CodeGenerator generator, Grammar grammar, ST outputFileST) throws IOException | |
| genRecognizerHeaderFile | back to summary |
|---|---|
| protected void genRecognizerHeaderFile(Tool tool, CodeGenerator generator, Grammar grammar, ST headerFileST, String extName) throws IOException | |
| getMaxCharValue | back to summary |
|---|---|
| public int getMaxCharValue(CodeGenerator generator) Some targets only support ASCII or 8-bit chars/strings. For example, C++ will probably want to return 0xFF here. | |
| getTarget64BitStringFromValue | back to summary |
|---|---|
| public String getTarget64BitStringFromValue(long word) Convert long to 0xNNNNNNNNNNNNNNNN by default for spitting out with bitsets. I.e., convert bytes to hex string. | |
| getTargetCharLiteralFromANTLRCharLiteral | back to summary |
|---|---|
| public String getTargetCharLiteralFromANTLRCharLiteral(CodeGenerator generator, String literal) 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. | |
| getTargetStringLiteralFromANTLRStringLiteral | back to summary |
|---|---|
| public String getTargetStringLiteralFromANTLRStringLiteral(CodeGenerator generator, String literal) Convert from an ANTLR string literal found in a grammar file to an equivalent string literal in the target language. For Java, this is the translation 'a\n"' → "a\n\"". Expect single quotes around the incoming literal. Just flip the quotes and replace double quotes with \" Note that we have decided to allow poeple to use '\"' without penalty, so we must build the target string in a loop as Utils.replae cannot handle both \" and " without a lot of messing around. | |
| getTargetStringLiteralFromString | back to summary |
|---|---|
| public String getTargetStringLiteralFromString(String s, boolean quoted) Given a random string of Java unicode chars, return a new string with optionally appropriate quote characters for target language and possibly with some escaped characters. For example, if the incoming string has actual newline characters, the output of this method would convert them to the two char sequence \n for Java, C, C++, ... The new string has double-quotes around it as well. Example String in memory: a"[newlinechar]b'c[carriagereturnchar]d[tab]e\f would be converted to the valid Java s: "a\"\nb'c\rd\te\\f" or a\"\nb'c\rd\te\\f depending on the quoted arg. | |
| getTargetStringLiteralFromString | back to summary |
|---|---|
| public String getTargetStringLiteralFromString(String s) | |
| getTokenTypeAsTargetLabel | back to summary |
|---|---|
| public String getTokenTypeAsTargetLabel(CodeGenerator generator, int ttype) Target must be able to override the labels used for token types | |
| isValidActionScope | back to summary |
|---|---|
| public boolean isValidActionScope(int grammarType, 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. The action names themselves are not policed at the moment so targets can add template actions w/o having to recompile ANTLR. | |
| performGrammarAnalysis | back to summary |
|---|---|
| protected void performGrammarAnalysis(CodeGenerator generator, Grammar grammar) | |
| postProcessAction | back to summary |
|---|---|
| public List Give target a chance to do some postprocessing on actions. Python for example will have to fix the indention. | |
| useBaseTemplatesForSynPredFragments | back to summary |
|---|---|
| public boolean useBaseTemplatesForSynPredFragments() | |