lexicallyFirst static method

Token? lexicallyFirst([
  1. Token? t1,
  2. Token? t2,
  3. Token? t3,
  4. Token? t4,
  5. Token? t5,
])

Compare the given tokens to find the token that appears first in the source being parsed. That is, return the left-most of all of the tokens. Return the token with the smallest offset, or null if all of the tokens are null.

Implementation

static Token? lexicallyFirst(
    [Token? t1, Token? t2, Token? t3, Token? t4, Token? t5]) {
  Token? result = t1;
  if (result == null || t2 != null && t2.offset < result.offset) {
    result = t2;
  }
  if (result == null || t3 != null && t3.offset < result.offset) {
    result = t3;
  }
  if (result == null || t4 != null && t4.offset < result.offset) {
    result = t4;
  }
  if (result == null || t5 != null && t5.offset < result.offset) {
    result = t5;
  }
  return result;
}