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 intcompareTo(AssemblyParseStateItem that)booleancompleted()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.booleanequals(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 generatedAssemblySymbolgetNext()Get the symbol immediately to the right of the dot This is the symbol which must be matched to advance the dot.intgetPos()Get the position of the dot The position is the number of symbols to the left of the dot.AssemblyProductiongetProduction()Get the production associated with this iteminthashCode()AssemblyParseStateItemread()Advance the dot by one position, producing a new itemjava.lang.StringtoString()
-
-
-
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:
equalsin classjava.lang.Object
-
compareTo
public int compareTo(AssemblyParseStateItem that)
- Specified by:
compareToin interfacejava.lang.Comparable<AssemblyParseStateItem>
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin 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
-
-