public final class Emitter
extends java.lang.Object
Table compression, String packing etc. is also done here.
Modifier and Type | Field and Description |
---|---|
private java.util.Map<Action,java.lang.Integer> |
actionTable
maps actions to their switch label
|
private boolean[] |
colKilled |
private int[] |
colMap |
private DFA |
dfa |
private static int |
FINAL |
private java.io.File |
inputFile |
private CharClassInterval[] |
intervals |
private boolean[] |
isTransition |
private static java.util.regex.Pattern |
JAVADOC_COMMENT_AND_MAYBE_ANNOTATIONS_PATTERN |
private static int |
NOLOOK |
private int |
numCols |
private int |
numRows |
private java.io.PrintWriter |
out |
private LexParse |
parser |
private boolean[] |
rowKilled |
private int[] |
rowMap |
private LexScan |
scanner |
private Skeleton |
skel |
private java.lang.String |
visibility |
Constructor and Description |
---|
Emitter(java.io.File inputFile,
LexParse parser,
DFA dfa)
Emits the java code.
|
Modifier and Type | Method and Description |
---|---|
void |
emit()
Main Emitter method.
|
private void |
emitActions() |
void |
emitActionTable()
emitActionTable.
|
private void |
emitAttributes() |
private int |
emitCharMapArray()
Returns the number of elements in the packed char map array, or zero if the char map array will
be not be packed.
|
private void |
emitCharMapArrayUnPacked() |
private void |
emitCharMapInitFunction(int packedCharMapPairs) |
private void |
emitClassCode() |
private void |
emitClassName() |
private void |
emitConstructorDecl() |
private void |
emitConstructorDecl(boolean printCtorArgs) |
private void |
emitCtorArgs() |
private void |
emitDoEOF() |
private void |
emitDynamicInit() |
private void |
emitEOFVal() |
private void |
emitGetRowMapNext() |
private void |
emitHeader() |
private void |
emitLexFunctHeader() |
private void |
emitLexicalStates() |
private void |
emitLookBuffer() |
private void |
emitMain() |
private void |
emitNextInput() |
private void |
emitNoMatch() |
private void |
emitRowMapArray() |
private void |
emitScanError() |
private void |
emitUserCode() |
static boolean |
endsWithJavadoc(java.lang.StringBuilder usercode)
Try to find out if user code ends with a javadoc comment, maybe followed by one or more
annotations
|
private java.lang.String |
escapify(java.lang.String s)
Escapes all " ' \ tabs and newlines
|
private void |
findActionStates() |
static java.lang.String |
getBaseName(java.lang.String className)
Computes base name of the class name.
|
private boolean |
hasGenLookAhead() |
static java.io.File |
normalize(java.lang.String name,
java.io.File input)
Constructs a file in Options.getDir() or in the same directory as another file.
|
private void |
print(int i) |
private void |
print(int i,
int tab) |
private void |
print(java.lang.String line) |
private void |
println() |
private void |
println(int i) |
private void |
println(java.lang.String line) |
private void |
printUC(int c)
Print number as octal/unicode escaped string character.
|
private void |
reduceColumns() |
private void |
reduceRows() |
private void |
setupEOFCode()
Set up EOF code section according to scanner.eofcode
|
private static final java.util.regex.Pattern JAVADOC_COMMENT_AND_MAYBE_ANNOTATIONS_PATTERN
private static final int FINAL
private static final int NOLOOK
private java.io.File inputFile
private java.io.PrintWriter out
private Skeleton skel
private LexScan scanner
private LexParse parser
private DFA dfa
private boolean[] isTransition
private int numRows
private int[] rowMap
private boolean[] rowKilled
private int numCols
private int[] colMap
private boolean[] colKilled
private java.util.Map<Action,java.lang.Integer> actionTable
private CharClassInterval[] intervals
private java.lang.String visibility
public static java.lang.String getBaseName(java.lang.String className)
className
- Class name for which to construct the base nameLexScan.className
public static java.io.File normalize(java.lang.String name, java.io.File input)
name
- the name (without path) of the fileinput
- fall back location if path = null (expected to be a file in the directory
to write to)private void println()
private void println(java.lang.String line)
private void println(int i)
private void print(java.lang.String line)
private void print(int i)
private void print(int i, int tab)
private boolean hasGenLookAhead()
private void emitLookBuffer()
private void emitScanError()
private void emitMain()
private void emitNoMatch()
private void emitNextInput()
private void emitHeader()
private void emitUserCode()
private void emitClassName()
public static boolean endsWithJavadoc(java.lang.StringBuilder usercode)
usercode
- the user codeprivate void emitLexicalStates()
private void emitDynamicInit()
private void emitCharMapInitFunction(int packedCharMapPairs)
private void emitCharMapArrayUnPacked()
private int emitCharMapArray()
This will be more than intervals.length if the count for any of the values is more than 0xFFFF, since the number of char map array entries per value is ceil(count / 0xFFFF)
private void printUC(int c)
c
- the value to printprivate void emitRowMapArray()
private void emitAttributes()
private void emitClassCode()
private void emitConstructorDecl()
private void emitConstructorDecl(boolean printCtorArgs)
private void emitCtorArgs()
private void emitDoEOF()
private void emitLexFunctHeader()
private void emitGetRowMapNext()
private java.lang.String escapify(java.lang.String s)
s
- The string to escapepublic void emitActionTable()
private void emitActions()
private void emitEOFVal()
private void findActionStates()
private void reduceColumns()
private void reduceRows()
private void setupEOFCode()
public void emit()