Canonicalize() public static method

Take a possibly escaped character literal and convert it to a canonical form. Thus @"'\377'", @"'\xff'" and @"'\u00FF'" all return @"'\xFF'". Throws a StringInterpretException if character ordinal exceeds "symLimit".
public static Canonicalize ( string source, int startIndex ) : string
source string
startIndex int start index of character
return string
Ejemplo n.º 1
0
        internal static bool BumpsMax(string str)
        {
            string num = CharacterUtilities.Canonicalize(str, 1);
            int    ord = CharacterUtilities.OrdinalOfCharacterLiteral(str, 1);

            return(ord > Terminal.max);
        }
Ejemplo n.º 2
0
        internal Terminal LookupTerminal(Token token, string name)
        {
            bool isIdent = (token == Token.ident);

            // Canonicalize escaped char-literals
            if (!isIdent)
            {
                name = CharacterUtilities.Canonicalize(name, 1);
            }
            // Check if already present in dictionary
            if (!terminals.ContainsKey(name))  // else insert ...
            {
                terminals[name] = new Terminal(isIdent, name);
            }
            return(terminals[name]);
        }
Ejemplo n.º 3
0
        internal Terminal LookupOrDefineTerminal(Token token, string name, string alias)
        {
            bool isIdent = (token == Token.ident);

            // Canonicalize escaped char-literals
            if (!isIdent)
            {
                name = CharacterUtilities.Canonicalize(name, 1);
            }
            // Check if already present in dictionary
            if (!terminals.ContainsKey(name))     // else insert ...
            {
                Terminal newTerm = new Terminal(isIdent, name, alias);
                terminals[name] = newTerm;
                if (alias != null)
                {
                    aliasTerms[alias] = newTerm;
                }
            }
            return(terminals[name]);
        }