Package jflex.core
Class Action
- java.lang.Object
-
- jflex.core.Action
-
public final class Action extends java.lang.Object
Encapsulates an action in the specification.It stores the Java code as String together with a priority (line number in the specification).
- Version:
- JFlex 1.9.1
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Action.Kind
-
Field Summary
Fields Modifier and Type Field Description java.lang.String
content
The Java code this Action representsprivate int
entryState
The entry state of the corresponding forward DFA (if general lookahead)private Action.Kind
kind
Which kind of action this is.private int
len
The length of the lookahead (if fixed)int
priority
The priority (i.e.
-
Constructor Summary
Constructors Constructor Description Action(java.lang.String content, int priority)
Creates a new Action object with specified content and line number.Action(Action.Kind kind)
Creates a new Action object of the specified kind.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Action
copyChoice(int length)
copyChoice.boolean
equals(java.lang.Object o)
int
getEntryState()
Return the corresponding entry state for the forward DFA (if this is a general lookahead expression)Action
getHigherPriority(Action other)
Compares the priority value of this Action with the specified action.int
getLookLength()
The length of the lookahead or base if this is a fixed length lookahead action.int
hashCode()
boolean
isEmittable()
Return true if code for this is action should be emitted, false if it is a BACK/FORWARD lookahead action.boolean
isEquiv(Action a)
Returnstrue
iff the parameter is an Action with the same content as this one.boolean
isGenLookAction()
Return true iff this is action belongs to a general lookahead rule.Action.Kind
lookAhead()
Return kind of lookahead.java.lang.String
lookString()
String representation of the lookahead kind of this action.void
setEntryState(int entryState)
Set the corresponding entry state for the forward DFA of this action (if this is a general lookahead expression)void
setLookAction(Action.Kind kind, int data)
Sets the lookahead kind and data for this actionjava.lang.String
toString()
-
-
-
Field Detail
-
content
public final java.lang.String content
The Java code this Action represents
-
priority
public final int priority
The priority (i.e. line number in the specification) of this Action.
-
kind
private Action.Kind kind
Which kind of action this is. (normal,a/b
with fixed length a, fixed length b, etc)
-
len
private int len
The length of the lookahead (if fixed)
-
entryState
private int entryState
The entry state of the corresponding forward DFA (if general lookahead)
-
-
Constructor Detail
-
Action
public Action(java.lang.String content, int priority)
Creates a new Action object with specified content and line number.- Parameters:
content
- java codepriority
- line number
-
Action
public Action(Action.Kind kind)
Creates a new Action object of the specified kind. Only accepts FORWARD_ACTION or BACKWARD_ACTION.- Parameters:
kind
- the kind of action- See Also:
Action.Kind.FORWARD_ACTION
,Action.Kind.BACKWARD_ACTION
-
-
Method Detail
-
getHigherPriority
public Action getHigherPriority(Action other)
Compares the priority value of this Action with the specified action.- Parameters:
other
- the other Action to compare this Action with.- Returns:
- this Action if it has higher priority - the specified one, if not.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
isEquiv
public boolean isEquiv(Action a)
Returnstrue
iff the parameter is an Action with the same content as this one.- Parameters:
a
- the object to compare this Action with- Returns:
- true if the action strings are equal
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
isGenLookAction
public boolean isGenLookAction()
Return true iff this is action belongs to a general lookahead rule.- Returns:
- true if this actions belongs to a general lookahead rule.
-
isEmittable
public boolean isEmittable()
Return true if code for this is action should be emitted, false if it is a BACK/FORWARD lookahead action.- Returns:
- true if code should be emitted for this action.
-
lookAhead
public Action.Kind lookAhead()
Return kind of lookahead.- Returns:
- a int.
-
setLookAction
public void setLookAction(Action.Kind kind, int data)
Sets the lookahead kind and data for this action- Parameters:
kind
- which kind of lookahead it isdata
- the length for fixed length lookaheads.
-
getLookLength
public int getLookLength()
The length of the lookahead or base if this is a fixed length lookahead action.- Returns:
- a int.
-
getEntryState
public int getEntryState()
Return the corresponding entry state for the forward DFA (if this is a general lookahead expression)- Returns:
- the forward DFA entry state (+1 is the backward DFA)
-
setEntryState
public void setEntryState(int entryState)
Set the corresponding entry state for the forward DFA of this action (if this is a general lookahead expression)- Parameters:
entryState
- a int.
-
copyChoice
public Action copyChoice(int length)
copyChoice.- Parameters:
length
- a int.- Returns:
- a
Action
object.
-
lookString
public java.lang.String lookString()
String representation of the lookahead kind of this action.- Returns:
- the string representation
-
-