Package jflex.generator
Class Emitter
- java.lang.Object
-
- jflex.generator.Emitter
-
public final class Emitter extends java.lang.ObjectThis 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.9.1
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<Action,java.lang.Integer>actionTablemaps actions to their switch labelprivate boolean[]colKilledprivate int[]colMapprivate DFAdfaprivate java.lang.StringeofCodeprivate java.lang.StringeofThrowprivate static intFINALprivate java.io.FileinputFileprivate boolean[]isTransitionprivate static intNOLOOKprivate intnumColsprivate java.io.PrintWriterout(package private) java.lang.StringoutputFileNameprivate LexParseparserprivate boolean[]rowKilledprivate int[]rowMapprivate AbstractLexScanscannerprivate Skeletonskelprivate java.lang.Stringvisibility
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidemit()Main Emitter method.private voidemitActions()private voidemitActionTable()emitActionTable.private voidemitAttributes()private voidemitCharMapArrayUnPacked()private voidemitCharMapTables()Emits two-level character translation tables.private voidemitClassCode()private voidemitClassName()private voidemitCMapAccess()private voidemitConstructorDecl()private voidemitConstructorDecl(boolean printCtorArgs)private voidemitCtorArgs()private voidemitDoEOF()private voidemitDynamicInit()private voidemitEOFVal()private voidemitGetRowMapNext()private voidemitHeader()private voidemitLexFunctHeader(java.lang.String functionName)private voidemitLexicalStates()private voidemitLookBuffer()private voidemitMain(java.lang.String functionName)private voidemitNextInput()private voidemitNoMatch()private voidemitRowMapArray()private voidemitScanError()private voidemitTokenSizeLimit(java.lang.String limit)private voidemitUserCode()private voidemitVarDefs()Emityychar,yycolumn,zzAtBOL,zzEOFDonewith warning suppression when needed.private static java.lang.Stringescapify(java.lang.String s)Escapes all " ' \ tabs and newlinesprivate voidfindActionStates()(package private) static java.lang.StringgetBaseName(java.lang.String className)Computes base name of the class name.private booleanhasGenLookAhead()private voidmapColMap(int[] blocks)Performs an in-place update to map the colMap translation over the char classes in the second-level cmap table.static java.io.Filenormalize(java.lang.String name, java.io.File input)Constructs a file in Options.getDir() or in the same directory as another file.private voidprint(int i)private voidprint(int i, int tab)private voidprint(java.lang.String line)private voidprintln()private voidprintln(int i)private voidprintln(java.lang.String line)private voidreduceColumns()private voidreduceRows()private voidsetupEOFCode()Set up EOF code section according to scanner.eofcodestatic java.lang.StringsourceFileString(java.io.File file)
-
-
-
Field Detail
-
FINAL
private static final int FINAL
- See Also:
- Constant Field Values
-
NOLOOK
private static final int NOLOOK
- See Also:
- Constant Field Values
-
inputFile
private final java.io.File inputFile
-
outputFileName
final java.lang.String outputFileName
-
out
private final java.io.PrintWriter out
-
skel
private final Skeleton skel
-
scanner
private final AbstractLexScan scanner
-
parser
private final LexParse parser
-
dfa
private final DFA dfa
-
isTransition
private boolean[] isTransition
-
rowMap
private int[] rowMap
-
rowKilled
private boolean[] rowKilled
-
numCols
private int numCols
-
colMap
private int[] colMap
-
colKilled
private boolean[] colKilled
-
actionTable
private final java.util.Map<Action,java.lang.Integer> actionTable
maps actions to their switch label
-
visibility
private final java.lang.String visibility
-
eofCode
private java.lang.String eofCode
-
eofThrow
private java.lang.String eofThrow
-
-
Method Detail
-
getBaseName
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
-
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 ifpath = 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(java.lang.String functionName)
-
emitNoMatch
private void emitNoMatch()
-
emitNextInput
private void emitNextInput()
-
sourceFileString
public static java.lang.String sourceFileString(java.io.File file)
-
emitHeader
private void emitHeader()
-
emitUserCode
private void emitUserCode()
-
emitClassName
private void emitClassName()
-
emitLexicalStates
private void emitLexicalStates()
-
emitDynamicInit
private void emitDynamicInit()
-
emitCharMapArrayUnPacked
private void emitCharMapArrayUnPacked()
-
mapColMap
private void mapColMap(int[] blocks)
Performs an in-place update to map the colMap translation over the char classes in the second-level cmap table.
-
emitCharMapTables
private void emitCharMapTables()
Emits two-level character translation tables. The translation is from raw input codepoint to the column in the generated DFA table.For maxCharCode < 256, a single-level unpacked array is used instead.
-
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(java.lang.String functionName)
-
emitCMapAccess
private void emitCMapAccess()
-
emitGetRowMapNext
private void emitGetRowMapNext()
-
escapify
private static java.lang.String escapify(java.lang.String s)
Escapes all " ' \ tabs and newlines- Parameters:
s- The string to escape- Returns:
- The escaped string
-
emitActionTable
private void emitActionTable()
emitActionTable.
-
emitTokenSizeLimit
private void emitTokenSizeLimit(java.lang.String limit)
-
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
-
emitVarDefs
private void emitVarDefs()
Emityychar,yycolumn,zzAtBOL,zzEOFDonewith warning suppression when needed.
-
emit
public void emit()
Main Emitter method.
-
-