public static string GetLexeme(this TokenCode value) { FieldInfo fieldInfo = value.GetType().GetField(value.ToString()); if (fieldInfo == null) { return(null); } var attribute = (LexemeAttribute)fieldInfo.GetCustomAttribute(typeof(LexemeAttribute)); return(attribute.Text); }
public static Token expect(TokenCode code) { Token token = get(); if (token.code == code) { forget(); return(token); } // Else error: token 'code' expected but not found error(token, "not-found", code.ToString()); return(null); }