private void CheckAlias(string alias, Terminal terminal, LexSpan span) { // // Terminal already known in collection // String format = null; String oldAlias = terminal.Alias; if (oldAlias == null) { format = "Token {0} already declared, without alias {1}"; terminal.AddAlias(alias); } else if (oldAlias.Equals(alias)) { format = "Token {0} already declared, with same alias {1}"; } else { format = "Declaring an additional alias, {1}, for token {0}"; } handler.AddWarning(153, String.Format(CultureInfo.InvariantCulture, format, terminal.BaseString(), alias), span); aliasTerms[alias] = terminal; }
private void CheckAndSetAlias(string alias, Terminal terminal, LexSpan span) { // // Check if this alias already known. // if (aliasTerms.ContainsKey(alias)) { // // If an alias denotes more than one logical token then used // occurrences of the literal string alias must be disallowed. // Terminal other = aliasTerms[alias]; if (other != terminal) { handler.AddWarning(153, String.Format(CultureInfo.InvariantCulture, "Alias \"{0}\" also used for previous token: {1}, used occurrences forbidden", alias, other.BaseString()), span); aliasTerms[alias] = Terminal.Ambiguous; } } else { aliasTerms[alias] = terminal; } }