} /* end PrintLineAndMarkColumn */ /* -------------------------------------------------------------------------- * private method GetNewLookaheadSym() * -------------------------------------------------------------------------- * Reads the next symbol from infile, sets currentSym and lookaheadSym. * ----------------------------------------------------------------------- */ private void GetNewLookaheadSym() { Token token; char nextChar; uint line = 0; uint column = 0; /* no token yet */ token = Token.Unknown; /* get the lookahead character */ nextChar = infile.NextChar(); while (token == Token.Unknown) { /* skip all whitespace and line feeds */ while ((nextChar == ASCII.SPACE) || (nextChar == ASCII.TAB) || (nextChar == ASCII.LF)) { /* consume the character and get new lookahead */ nextChar = infile.ConsumeChar(); } /* end while */ line = infile.CurrentLine(); column = infile.CurrentColumn(); switch (nextChar) { case ASCII.EOT: /* End-of-File marker */ if (infile.Status() == InfileStatus.AttemptToReadPastEOF) { token = Token.EndOfFile; } else /* invalid char */ { // TO DO : report error with offending character token = Token.Unknown; } /* end if */ break; case '!': /* line comment */ if (Capabilities.LineComments()) { nextChar = SkipLineComment(); } else /* illegal character */ { // TO DO : report error with offending character token = Token.Unknown; } /* end if */ break; case '"': /* string literal */ nextChar = GetStringLiteral(out token); if (token == Token.MalformedString) { // TO DO : report error with offending position } /* end if */ break; case '#': /* not-equal operator */ nextChar = infile.ConsumeChar(); token = Token.NotEqual; break; case '&': /* ampersand synonym */ if (Capabilities.Synonyms()) { nextChar = infile.ConsumeChar(); token = Token.AND; } else /* illegal character */ { // TO DO : report error with offending character token = Token.Unknown; } /* end if */ break; case '\'': /* string literal */ nextChar = GetStringLiteral(out token); if (token == Token.MalformedString) { // TO DO : report error with offending position } /* end if */ break; case '(': /* left parenthesis */ if (infile.LA2Char() != '*') { nextChar = infile.ConsumeChar(); token = Token.LeftParen; } else /* block comment */ { nextChar = SkipBlockComment(); token = Token.Unknown; } break; case ')': /* right parenthesis */ nextChar = infile.ConsumeChar(); token = Token.RightParen; break; case '*': /* asterisk operator */ nextChar = infile.ConsumeChar(); token = Token.Asterisk; break; case '+': /* plus operator */ nextChar = infile.ConsumeChar(); token = Token.Plus; break; case ',': /* comma */ nextChar = infile.ConsumeChar(); token = Token.Comma; break; case '-': /* minus operator */ nextChar = infile.ConsumeChar(); token = Token.Minus; break; case '.': /* range or period */ nextChar = infile.ConsumeChar(); if /* range */ (nextChar == '.') { nextChar = infile.ConsumeChar(); token = Token.Range; } else /* period */ { token = Token.Period; } /* end if */ break; case '/': /* solidus operator */ nextChar = infile.ConsumeChar(); token = Token.Solidus; break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': /* number literal */ nextChar = GetNumberLiteral(out token); if (token == Token.MalformedInteger) { // TO DO : report error with position } else if (token == Token.MalformedReal) { // TO DO : report error with position } /* end if */ break; case ':': /* assignment or colon*/ nextChar = infile.ConsumeChar(); if /* assignment */ (nextChar == '=') { nextChar = infile.ConsumeChar(); token = Token.Assign; } else /* colon */ { token = Token.Colon; } /* end if */ break; case ';': /* semicolon */ nextChar = infile.ConsumeChar(); token = Token.Semicolon; break; case '<': if (Capabilities.IsoPragmaDelimiters() && (infile.LA2Char() == '*')) { /* pragma */ nextChar = GetPragma(); token = Token.Pragma; break; } /* end if */ /* not-equal, less-equal or less operator */ nextChar = infile.ConsumeChar(); if (Capabilities.Synonyms() && (nextChar == '>')) { /* not-equal synonym */ nextChar = infile.ConsumeChar(); token = Token.NotEqual; } else if /* less-equal */ (nextChar == '=') { nextChar = infile.ConsumeChar(); token = Token.LessEqual; } else /* less */ { token = Token.Less; } /* end if */ break; case '=': /* equal operator */ nextChar = infile.ConsumeChar(); token = Token.Equal; break; case '>': /* greater-equal or greater operator */ nextChar = infile.ConsumeChar(); if /* greater-equal */ (nextChar == '=') { nextChar = infile.ConsumeChar(); token = Token.GreaterEqual; } else /* greater */ { token = Token.Greater; } /* end if */ break; case '?': /* disabled code section tag */ if ((column == 1) && (infile.LA2Char() == '<')) { nextChar = SkipCodeSection(); } else /* invalid character */ { // TO DO : report error with offending character token = Token.Unknown; } /* end if */ break; case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': /* identifier or reserved word */ nextChar = GetIdentOrResword(out token); break; case '[': /* left bracket */ nextChar = infile.ConsumeChar(); token = Token.LeftBracket; break; case ASCII.BACKSLASH: /* backslash */ if (Capabilities.BackslashSetDiffOp()) { nextChar = infile.ConsumeChar(); token = Token.Backslash; } else /* illegal character */ { // TO DO : report error with offending character token = Token.Unknown; } /* end if */ break; case ']': /* right bracket */ nextChar = infile.ConsumeChar(); token = Token.RightBracket; break; case '^': /* caret */ nextChar = infile.ConsumeChar(); token = Token.Deref; break; case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': /* identifier */ nextChar = GetIdent(); token = Token.Identifier; break; case '{': /* left brace */ nextChar = infile.ConsumeChar(); token = Token.LeftBrace; break; case '|': /* vertical bar */ nextChar = infile.ConsumeChar(); token = Token.Bar; break; case '}': /* right brace */ nextChar = infile.ConsumeChar(); token = Token.RightBrace; break; case '~': /* tilde synonym */ if (Capabilities.Synonyms()) { nextChar = infile.ConsumeChar(); token = Token.NOT; } else /* illegal character */ { // TO DO : report error with offending character token = Token.Unknown; } /* end if */ break; default: /* invalid character */ break; } /* end switch */ } /* end while */ /* update lexer's lookahead symbol */ lookaheadSym.token = token; lookaheadSym.line = line; lookaheadSym.column = column; return; } /* end GetNewLookaheadSym */