Class TokenBuffer

java.lang.Object
io.karatelabs.parser.TokenBuffer

public class TokenBuffer extends Object
Flyweight container for tokens. Holds shared Resource and parallel arrays for rarely-used token data (comments, prev/next navigation).
  • Field Details

    • resource

      public final Resource resource
  • Constructor Details

    • TokenBuffer

      public TokenBuffer(Resource resource)
  • Method Details

    • addToken

      public int addToken(Token token)
      Registers a token and returns its index in the buffer.
    • getToken

      public Token getToken(int index)
    • getPrev

      public Token getPrev(int index)
    • getNext

      public Token getNext(int index)
    • setComments

      public void setComments(int index, List<Token> tokenComments)
    • getComments

      public List<Token> getComments(int index)
    • size

      public int size()