Ejemplo n.º 1
0
        static bool IsSpecialIdentifier(Symbol name, out bool backquote)
        {
            backquote = name.Name.Length == 0;
            bool special = false, first = true;

            foreach (char c in name.Name)
            {
                if (!Les2Lexer.IsIdContChar(c))
                {
                    if (Les2Lexer.IsSpecialIdChar(c))
                    {
                        special = true;
                    }
                    else
                    {
                        backquote = true;
                    }
                }
                else if (first && !Les2Lexer.IsIdStartChar(c))
                {
                    special = true;
                }
                first = false;
            }

            // Watch out for @`-inf_d` and @`-inf_f`, because they will be
            // interpreted as named literals if we don't backquote them.
            if (special && !backquote && (name.Name == "-inf_d" || name.Name == "-inf_f"))
            {
                backquote = true;
            }
            return(special || backquote);
        }
Ejemplo n.º 2
0
        static bool IsSpecialIdentifier(UString name, out bool backquote)
        {
            backquote = name.Length == 0;
            bool special = false, first = true;

            foreach (char c in name)
            {
                if (!Les2Lexer.IsIdContChar(c))
                {
                    if (Les2Lexer.IsSpecialIdChar(c))
                    {
                        special = true;
                    }
                    else
                    {
                        backquote = true;
                    }
                }
                else if (first && !Les2Lexer.IsIdStartChar(c))
                {
                    special = true;
                }
                first = false;
            }

            // Watch out for named literals with punctuation e.g. @`-inf_d` and @`-inf_f`:
            // they will be interpreted as named literals if we don't backquote them.
            if (special && !backquote && Les2Lexer.NamedLiterals.ContainsKey(name))
            {
                backquote = true;
            }
            return(special || backquote);
        }