Class ParsingUtils

java.lang.Object
net.emustudio.emulib.plugin.compiler.antlr.ParsingUtils

public final class ParsingUtils extends Object
Conversions of common ANTLR literal tokens shared by emuStudio compilers.
  • Method Details

    • parseNumber

      public static int parseNumber(org.antlr.v4.runtime.Token token)
      Parses a number literal token, e.g. -0x1F, 1Fh, 101b, 17o, 17q, 12d or 12.
      Parameters:
      token - number token
      Returns:
      parsed value
      Throws:
      NumberFormatException - if the token is not a number; see Numbers.parseRadix(String)
    • parseLitString

      public static String parseLitString(org.antlr.v4.runtime.Token token)
      Strips the quotes of a string literal token ('text' or "text").
      Parameters:
      token - string token
      Returns:
      the string without quotes
    • parseLabel

      public static String parseLabel(org.antlr.v4.runtime.Token token)
      Strips the trailing colon of a label definition token (label:).
      Parameters:
      token - label token
      Returns:
      the label name
    • normalizeId

      public static String normalizeId(String id)
      Normalizes an identifier for case-insensitive lookup.
      Parameters:
      id - identifier
      Returns:
      lower-case identifier