Example #1
0
        internal Terminal LookupOrDefineTerminal(Token token, string name, string alias, LexSpan span)
        {
            bool     isIdent = (token == Token.ident);
            Terminal result  = null;

            // Canonicalize escaped char-literals
            if (!isIdent)
            {
                name = CharacterUtilities.CanonicalizeCharacterLiteral(name, 1);
            }
            else if (alias != null)
            {
                alias = CharacterUtilities.CanonicalizeAlias(alias);
            }
            // Check if already present in dictionary
            if (!terminals.ContainsKey(name))      // terminal not already known
            {
                result          = new Terminal(isIdent, name, alias);
                terminals[name] = result;
                if (alias != null)
                {
                    CheckAndSetAlias(alias, result, span);
                }
            }
            else
            {
                result = terminals[name];
                if (alias != null)
                {
                    CheckAlias(alias, result, span);
                }
            }
            return(result);
        }
Example #2
0
        internal static bool BumpsMax(string str)
        {
            string num = CharacterUtilities.CanonicalizeCharacterLiteral(str, 1);
            int    ord = CharacterUtilities.OrdinalOfCharacterLiteral(str, 1);

            return(ord > Terminal.max);
        }
Example #3
0
        internal Terminal LookupTerminal(Token token, string name)
        {
            bool isIdent = (token == Token.ident);

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