Class ParsingUtils
java.lang.Object
net.emustudio.emulib.plugin.compiler.antlr.ParsingUtils
Conversions of common ANTLR literal tokens shared by emuStudio compilers.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringnormalizeId(String id) Normalizes an identifier for case-insensitive lookup.static StringparseLabel(org.antlr.v4.runtime.Token token) Strips the trailing colon of a label definition token (label:).static StringparseLitString(org.antlr.v4.runtime.Token token) Strips the quotes of a string literal token ('text'or"text").static intparseNumber(org.antlr.v4.runtime.Token token) Parses a number literal token, e.g.
-
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,12dor12.- Parameters:
token- number token- Returns:
- parsed value
- Throws:
NumberFormatException- if the token is not a number; seeNumbers.parseRadix(String)
-
parseLitString
Strips the quotes of a string literal token ('text'or"text").- Parameters:
token- string token- Returns:
- the string without quotes
-
parseLabel
Strips the trailing colon of a label definition token (label:).- Parameters:
token- label token- Returns:
- the label name
-
normalizeId
-