Class AssemblySentential<NT extends AssemblyNonTerminal>
java.lang.Object
ghidra.app.plugin.assembler.sleigh.grammars.AssemblySentential<NT>
- Type Parameters:
NT
- the type of non-terminals
- All Implemented Interfaces:
Comparable<AssemblySentential<NT>>
,Iterable<AssemblySymbol>
public class AssemblySentential<NT extends AssemblyNonTerminal>
extends Object
implements Comparable<AssemblySentential<NT>>, Iterable<AssemblySymbol>
A "string" of symbols
To avoid overloading the word "string", we call this a "sentential". Technically, to be a "sentential" in the classic sense, it must be a possible element in the derivation of a sentence in the grammar starting with the start symbol. We ignore that if only for the sake of naming.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
The token consumed by a whitespace terminal when it anticipates the end of inputstatic class
The token consumed by a whitespace terminal -
Field Summary
-
Constructor Summary
ConstructorDescriptionConstruct a blank string This is suitable as a blank start, to add new symbols, or to use directly as the RHS, effectively creating an "epsilon" production.AssemblySentential
(AssemblySymbol... syms) Construct a string from any number of symbolsAssemblySentential
(List<? extends AssemblySymbol> symbols) Construct a string from the given list of symbols -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a comma followed by optional whitespace.void
addSeparatorPart
(String str) Add a syntactic terminal element, but with consideration for optional whitespace surrounding special charactersvoid
addSeparators
(String str) Add a syntactic terminal element, but considering that commas contained within may be followed by optional whitespaceboolean
addSymbol
(AssemblySymbol symbol) Add a symbol to the right of this sententialboolean
addWS()
Add optional whitespace, if not already preceded by whitespaceint
compareTo
(AssemblySentential<NT> that) void
finish()
Trim leading and trailing whitespace, and make the sentential immutablegetSymbol
(int pos) Get the symbols in this sententialint
hashCode()
iterator()
int
size()
Get the number of symbols, including whitespace, in this sententialsub
(int fromIndex, int toIndex) toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
WHITE_SPACE
-
-
Constructor Details
-
AssemblySentential
Construct a string from the given list of symbols- Parameters:
symbols
-
-
AssemblySentential
public AssemblySentential()Construct a blank string This is suitable as a blank start, to add new symbols, or to use directly as the RHS, effectively creating an "epsilon" production. -
AssemblySentential
Construct a string from any number of symbols- Parameters:
syms
-
-
-
Method Details
-
toString
-
compareTo
- Specified by:
compareTo
in interfaceComparable<NT extends AssemblyNonTerminal>
-
hashCode
public int hashCode() -
addSymbol
Add a symbol to the right of this sentential- Parameters:
symbol
- the symbol to add- Returns:
- true
-
addWS
public boolean addWS()Add optional whitespace, if not already preceded by whitespace- Returns:
- true if whitespace was added
-
addCommaWS
public void addCommaWS()Add a comma followed by optional whitespace. -
addSeparatorPart
Add a syntactic terminal element, but with consideration for optional whitespace surrounding special characters- Parameters:
str
- the expected terminal
-
getSymbols
Get the symbols in this sentential- Returns:
- the symbols;
-
getSymbol
-
addSeparators
Add a syntactic terminal element, but considering that commas contained within may be followed by optional whitespace- Parameters:
str
- the expected terminal
-
finish
public void finish()Trim leading and trailing whitespace, and make the sentential immutable -
iterator
- Specified by:
iterator
in interfaceIterable<NT extends AssemblyNonTerminal>
-
sub
-
size
public int size()Get the number of symbols, including whitespace, in this sentential- Returns:
- the number of symbols
-