Esempio n. 1
0
        } /* end GetPragma */

/* ---------------------------------------------------------------------------
 * private method GetIdent()
 * ------------------------------------------------------------------------ */

        private char GetIdent()
        {
            char nextChar;

            infile.MarkLexeme();
            nextChar = infile.NextChar();

            if (CompilerOptions.LowlineIdentifiers())
            {
                /* get alpha-numeric or foreign identifier */
                while (ASCII.IsAlnum(nextChar))
                {
                    nextChar = infile.ConsumeChar();

                    /* check for lowline in between two alpha-numeric characters */
                    if ((nextChar == '_') && (ASCII.IsAlnum(infile.LA2Char())))
                    {
                        nextChar = infile.ConsumeChar();
                    } /* end if */
                }     /* end while */
            }
            else      /* no lowline identifiers */
            {
                /* get alpha-numeric identifier */
                while (ASCII.IsAlnum(nextChar))
                {
                    nextChar = infile.ConsumeChar();
                } /* end while */
            }     /* end if */

            /* get lexeme */
            lookaheadSym.lexeme = infile.ReadMarkedLexeme();

            return(nextChar);
        } /* end GetIdent */
Esempio n. 2
0
        } /* end GetIdent */

/* ---------------------------------------------------------------------------
 * private method GetIdentOrResword()
 * ------------------------------------------------------------------------ */

        private char GetIdentOrResword(out Token token)
        {
            char  nextChar;
            Token intermediate;
            bool  possiblyResword = true;

            infile.MarkLexeme();
            nextChar = infile.NextChar();

            if (CompilerOptions.LowlineIdentifiers())
            {
                /* get alpha-numeric or foreign identifier */
                while (ASCII.IsAlnum(nextChar))
                {
                    /* check for uppercase */
                    if (ASCII.IsUpper(nextChar) == false)
                    {
                        possiblyResword = false;
                    } /* end if */

                    nextChar = infile.ConsumeChar();

                    /* check for lowline in between two alpha-numeric characters */
                    if ((nextChar == '_') && (ASCII.IsAlnum(infile.LA2Char())))
                    {
                        nextChar        = infile.ConsumeChar();
                        possiblyResword = false;
                    } /* end if */
                }     /* end while */
            }
            else      /* no lowline identifiers */
            {
                /* get alpha-numeric identifier */
                while (ASCII.IsAlnum(nextChar))
                {
                    /* check for uppercase */
                    if (ASCII.IsUpper(nextChar) == false)
                    {
                        possiblyResword = false;
                    } /* end if */

                    nextChar = infile.ConsumeChar();
                } /* end while */
            }     /* end if */

            lookaheadSym.lexeme = infile.ReadMarkedLexeme();

            /* check for reserved word */
            if (possiblyResword)
            {
                intermediate = Terminals.TokenForResword(lookaheadSym.lexeme);

                if (intermediate == Token.Unknown)
                {
                    token = Token.Identifier;
                }
                else
                {
                    token = intermediate;
                } /* end if */
            }
            else
            {
                token = Token.Identifier;
            } /* end if */

            return(nextChar);
        } /* end GetIdentOrResword */