//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// PLEASE DO NOT EDIT WITHOUT THE EXPLICIT CONSENT OF THE AUTHOR! \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
using System;
using Ilog.Language.Util;
namespace Ilog.Language.Syntax
{
/**
* This class is the type of tokens that are dynamic operators.
* It is used by the grammar at parser construction time.
*
* @see OperatorSymbol
*
* @version Last modified on Wed May 25 17:43:45 2005 by hak
* @author Hassan Aït-Kaci
* @copyright © 2000 ILOG, S.A.
*/
internal class Operator : OperatorSymbol
{
/** The grammar this symbol belongs to. */
private static Grammar grammar = Grammar.currentGrammar;
/**
* Constructs an operator symbol with the specified name,
* nonterminal category, precedence, and specifier.
*/
internal Operator (string name, NonTerminal category,
int precedence, string specifier)
// throws NonFatalParseErrorException
: base(name,grammar.Operators,precedence,specifier)
{
this.category = category;
}
/**
* Constructs an operator symbol with the specified name,
* nonterminal category, precedence, associativity, and fixity.
*/
internal Operator (string name, NonTerminal category,
int precedence, int associativity, int fixity)
: base(name,grammar.Operators,precedence,associativity,fixity)
{
this.category = category;
}
/** This operator nonterminal category. */
private NonTerminal category;
internal NonTerminal Category
{
get { return category; }
}
/** This operator symbol's nonterminal category name. */
public override string CategoryName
{
get { return category.Name; }
}
/**
* Operators are ordered by category names, and precedences in
* their categories.
*/
public override bool LessThan (Comparable other)
{
if (!(other is Operator))
return false;
Operator op = (Operator)other;
int comparison = String.Compare(category.Name,op.category.Name,true);
if (comparison < 0)
return true;
if (comparison > 0)
return false;
if (precedence < op.precedence)
return true;
if (precedence > op.precedence)
return false;
return String.Compare(name,op.name,true) < 0;
}
}
}