Class AssemblyParseStateItem
- java.lang.Object
-
- ghidra.app.plugin.assembler.sleigh.parse.AssemblyParseStateItem
-
- All Implemented Interfaces:
java.lang.Comparable<AssemblyParseStateItem>
public class AssemblyParseStateItem extends java.lang.Object implements java.lang.Comparable<AssemblyParseStateItem>
An item in the state of an LR(0) parser An item is a production with a dot indicating a position while parsing
-
-
Constructor Summary
Constructors Constructor Description AssemblyParseStateItem(AssemblyProduction prod)
Construct a new item starting at the far left of the given productionAssemblyParseStateItem(AssemblyProduction prod, int pos)
Construct a new item starting immediately before the symbol at the given position in the given production
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(AssemblyParseStateItem that)
boolean
completed()
Check if this item is completed The item is completed if all symbols have been matched, i.e., the dot is at the far right of the production.boolean
equals(java.lang.Object that)
java.util.Collection<AssemblyParseStateItem>
getClosure(AssemblyGrammar grammar)
"Fill" one step out to close a state containing this item To compute the full closure, you must continue stepping out until no new items are generatedAssemblySymbol
getNext()
Get the symbol immediately to the right of the dot This is the symbol which must be matched to advance the dot.int
getPos()
Get the position of the dot The position is the number of symbols to the left of the dot.AssemblyProduction
getProduction()
Get the production associated with this itemint
hashCode()
AssemblyParseStateItem
read()
Advance the dot by one position, producing a new itemjava.lang.String
toString()
-
-
-
Constructor Detail
-
AssemblyParseStateItem
public AssemblyParseStateItem(AssemblyProduction prod)
Construct a new item starting at the far left of the given production- Parameters:
prod
- the production
-
AssemblyParseStateItem
public AssemblyParseStateItem(AssemblyProduction prod, int pos)
Construct a new item starting immediately before the symbol at the given position in the given production- Parameters:
prod
- the productionpos
- the position of the dot
-
-
Method Detail
-
read
public AssemblyParseStateItem read()
Advance the dot by one position, producing a new item- Returns:
- the new item
-
getNext
public AssemblySymbol getNext()
Get the symbol immediately to the right of the dot This is the symbol which must be matched to advance the dot.- Returns:
- the symbol, or null if the item is completed, i.e., the dot is at the far right
-
getClosure
public java.util.Collection<AssemblyParseStateItem> getClosure(AssemblyGrammar grammar)
"Fill" one step out to close a state containing this item To compute the full closure, you must continue stepping out until no new items are generated- Parameters:
grammar
- the grammar containing the production- Returns:
- a subset of items in the closure of a state containing this item
-
equals
public boolean equals(java.lang.Object that)
- Overrides:
equals
in classjava.lang.Object
-
compareTo
public int compareTo(AssemblyParseStateItem that)
- Specified by:
compareTo
in interfacejava.lang.Comparable<AssemblyParseStateItem>
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
completed
public boolean completed()
Check if this item is completed The item is completed if all symbols have been matched, i.e., the dot is at the far right of the production.- Returns:
- true iff the item is completed
-
getPos
public int getPos()
Get the position of the dot The position is the number of symbols to the left of the dot.- Returns:
-
getProduction
public AssemblyProduction getProduction()
Get the production associated with this item- Returns:
- the production
-
-