/// <summary> /// Asserts that a node has a particular kind. If it does /// not, then a message is sent to a log. /// </summary> /// <param name="node"> /// A node to inspect. /// </param> /// <param name="kind"> /// The expected node kind for <paramref name="node"/>. /// </param> /// <param name="log"> /// A log to send error and warning messages to. /// </param> /// <returns> /// <c>true</c> if the node is of the specified kind; otherwise, <c>false</c>. /// </returns> public static bool AssertOfKind(LNode node, LNodeKind kind, ILog log) { if (node.Kind != kind) { log.LogSyntaxError( node, QuoteEven( "expected ", SpellNodeKind(kind), " node, but got ", SpellNodeKind(node), " node instead.")); return(false); } return(true); }
/// <summary> /// Gets a human-readable string that identifies a node /// kind. /// </summary> /// <param name="kind"> /// A node kind to spell. /// </param> /// <returns> /// A string that identifies the node kind. /// </returns> public static string SpellNodeKind(LNodeKind kind) { return(kind.ToString().ToLower()); }
/// <summary> /// Gets a human-readable string that identifies a node /// kind. /// </summary> /// <param name="kind"> /// A node kind to spell. /// </param> /// <returns> /// A string that identifies the node kind. /// </returns> public static string SpellNodeKind(LNodeKind node) { return(node.ToString().ToLower()); }