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.

  • Field Details

  • Constructor Details

    • AssemblySentential

      public AssemblySentential(List<? extends AssemblySymbol> symbols)
      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

      public AssemblySentential(AssemblySymbol... syms)
      Construct a string from any number of symbols
      Parameters:
      syms -
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • compareTo

      public int compareTo(AssemblySentential<NT> that)
      Specified by:
      compareTo in interface Comparable<NT extends AssemblyNonTerminal>
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • addSymbol

      public boolean addSymbol(AssemblySymbol symbol)
      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

      public void addSeparatorPart(String str)
      Add a syntactic terminal element, but with consideration for optional whitespace surrounding special characters
      Parameters:
      str - the expected terminal
    • getSymbols

      public List<AssemblySymbol> getSymbols()
      Get the symbols in this sentential
      Returns:
      the symbols;
    • getSymbol

      public AssemblySymbol getSymbol(int pos)
    • addSeparators

      public void addSeparators(String str)
      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

      public Iterator<AssemblySymbol> iterator()
      Specified by:
      iterator in interface Iterable<NT extends AssemblyNonTerminal>
    • sub

      public AssemblySentential<NT> sub(int fromIndex, int toIndex)
    • size

      public int size()
      Get the number of symbols, including whitespace, in this sentential
      Returns:
      the number of symbols