Package jflex
Class Emitter
- java.lang.Object
-
- jflex.Emitter
-
public final class Emitter extends java.lang.Object
This class manages the actual code generation, putting the scanner together, filling in skeleton sections etc.Table compression, String packing etc. is also done here.
- Version:
- JFlex 1.7.0
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<Action,java.lang.Integer>
actionTable
maps actions to their switch labelprivate 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
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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 annotationsprivate java.lang.String
escapify(java.lang.String s)
Escapes all " ' \ tabs and newlinesprivate 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
-
-
-
Field Detail
-
JAVADOC_COMMENT_AND_MAYBE_ANNOTATIONS_PATTERN
private static final java.util.regex.Pattern JAVADOC_COMMENT_AND_MAYBE_ANNOTATIONS_PATTERN
-
FINAL
private static final int FINAL
- See Also:
- Constant Field Values
-
NOLOOK
private static final int NOLOOK
- See Also:
- Constant Field Values
-
inputFile
private java.io.File inputFile
-
out
private java.io.PrintWriter out
-
skel
private Skeleton skel
-
scanner
private LexScan scanner
-
parser
private LexParse parser
-
dfa
private DFA dfa
-
isTransition
private boolean[] isTransition
-
numRows
private int numRows
-
rowMap
private int[] rowMap
-
rowKilled
private boolean[] rowKilled
-
numCols
private int numCols
-
colMap
private int[] colMap
-
colKilled
private boolean[] colKilled
-
actionTable
private java.util.Map<Action,java.lang.Integer> actionTable
maps actions to their switch label
-
intervals
private CharClassInterval[] intervals
-
visibility
private java.lang.String visibility
-
-
Method Detail
-
getBaseName
public static java.lang.String getBaseName(java.lang.String className)
Computes base name of the class name. Needs to take into account generics.- Parameters:
className
- Class name for which to construct the base name- Returns:
- the
- See Also:
LexScan.className
-
normalize
public 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. Makes a backup if the file already exists.- Parameters:
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)- Returns:
- The constructed File
-
println
private void println()
-
println
private void println(java.lang.String line)
-
println
private void println(int i)
-
print
private void print(java.lang.String line)
-
print
private void print(int i)
-
print
private void print(int i, int tab)
-
hasGenLookAhead
private boolean hasGenLookAhead()
-
emitLookBuffer
private void emitLookBuffer()
-
emitScanError
private void emitScanError()
-
emitMain
private void emitMain()
-
emitNoMatch
private void emitNoMatch()
-
emitNextInput
private void emitNextInput()
-
emitHeader
private void emitHeader()
-
emitUserCode
private void emitUserCode()
-
emitClassName
private void emitClassName()
-
endsWithJavadoc
public 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- Parameters:
usercode
- the user code- Returns:
- true if it ends with a javadoc comment and zero or more annotations
-
emitLexicalStates
private void emitLexicalStates()
-
emitDynamicInit
private void emitDynamicInit()
-
emitCharMapInitFunction
private void emitCharMapInitFunction(int packedCharMapPairs)
-
emitCharMapArrayUnPacked
private void emitCharMapArrayUnPacked()
-
emitCharMapArray
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.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)
-
printUC
private void printUC(int c)
Print number as octal/unicode escaped string character.- Parameters:
c
- the value to print
-
emitRowMapArray
private void emitRowMapArray()
-
emitAttributes
private void emitAttributes()
-
emitClassCode
private void emitClassCode()
-
emitConstructorDecl
private void emitConstructorDecl()
-
emitConstructorDecl
private void emitConstructorDecl(boolean printCtorArgs)
-
emitCtorArgs
private void emitCtorArgs()
-
emitDoEOF
private void emitDoEOF()
-
emitLexFunctHeader
private void emitLexFunctHeader()
-
emitGetRowMapNext
private void emitGetRowMapNext()
-
escapify
private java.lang.String escapify(java.lang.String s)
Escapes all " ' \ tabs and newlines- Parameters:
s
- The string to escape- Returns:
- The escaped string
-
emitActionTable
public void emitActionTable()
emitActionTable.
-
emitActions
private void emitActions()
-
emitEOFVal
private void emitEOFVal()
-
findActionStates
private void findActionStates()
-
reduceColumns
private void reduceColumns()
-
reduceRows
private void reduceRows()
-
setupEOFCode
private void setupEOFCode()
Set up EOF code section according to scanner.eofcode
-
emit
public void emit()
Main Emitter method.
-
-