Package jflex.generator
Class CountEmitter
- java.lang.Object
-
- jflex.generator.PackEmitter
-
- jflex.generator.CountEmitter
-
- Direct Known Subclasses:
HiCountEmitter
public class CountEmitter extends PackEmitter
An emitter for an array encoded as count/value pairs in a string.- Version:
- JFlex 1.9.1
-
-
Field Summary
Fields Modifier and Type Field Description protected intnumEntriesnumber of entries in expanded arrayprotected inttranslatetranslate all values by this amount-
Fields inherited from class jflex.generator.PackEmitter
chunks, name, out
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedCountEmitter(java.lang.String name)Create a count/value emitter for a specific field with values in the range of [0..0xFFFF].protectedCountEmitter(java.lang.String name, int translate)Create a count/value emitter for a specific field with translated values in the range of [0..0xFFFF].
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidemit(int count, int value)Emit one count/value pair.voidemitCountValueString(int[] a)Emits a plain int array as a count/value string.static CountEmitteremitter(int states, int translation, java.lang.String name)voidemitUnpack()Emits count/value unpacking code for the generated array.protected voidemitUnpackChunk()Emits count/value unpacking code for one chunk of the generated array.protected voidemitValue(int value)Emit one value.
-
-
-
Constructor Detail
-
CountEmitter
protected CountEmitter(java.lang.String name)
Create a count/value emitter for a specific field with values in the range of [0..0xFFFF].- Parameters:
name- name of the generated array
-
CountEmitter
protected CountEmitter(java.lang.String name, int translate)Create a count/value emitter for a specific field with translated values in the range of [0..0xFFFF].- Parameters:
name- name of the generated arraytranslate- translate all values by this amount, e.g provide +1 to allow values in [-1, 0xFFFE]
-
-
Method Detail
-
emitUnpack
public void emitUnpack()
Emits count/value unpacking code for the generated array.- Specified by:
emitUnpackin classPackEmitter- See Also:
PackEmitter.emitUnpack()
-
emitUnpackChunk
protected void emitUnpackChunk()
Emits count/value unpacking code for one chunk of the generated array. Base class assumes values are in [0, 0xFFFF]. Subclasses may override.- See Also:
emitUnpack()
-
emit
public void emit(int count, int value)Emit one count/value pair.Automatically translates value by the
translatevalue.- Parameters:
count- a int.value- a int.
-
emitValue
protected void emitValue(int value)
Emit one value. Base class assumes range [0, 0xFFFF], subclasses may override.- Parameters:
value- integer value to emit, assumed to be in the range [0, 0xFFFF]
-
emitCountValueString
public void emitCountValueString(int[] a)
Emits a plain int array as a count/value string. Expects the preamble code (declaration, javadoc) to already be emitted. Values in the array must be no larger than 0xFFFF (encoded as char), array must have at least one element.
-
emitter
public static CountEmitter emitter(int states, int translation, java.lang.String name)
-
-