sym_num = find_single_char(next_char);
if (sym_num != -1)
{
/* found one -- advance past it and return a Symbol for it */
advance();
return new Symbol(sym_num);
}
/* look for : or ::= */
if (next_char == ':')
{
/* if we don't have a second ':' return COLON */
if (next_char2 != ':')
{
advance();
return new Symbol(sym.COLON);
}
/* move forward and look for the '=' */
advance();
if (next_char2 == '=')
{
advance(); advance();
return new Symbol(sym.COLON_COLON_EQUALS);
}
else
{
/* return just the colon (already consumed) */
return new Symbol(sym.COLON);
}
}
/* find a "%prec" string and return it. otherwise, a '%' was found,
which has no right being in the specification otherwise */
if (next_char == '%') {
advance();
if ((next_char == 'p') && (next_char2 == 'r') && (next_char3 == 'e') &&
(next_char4 == 'c')) {
advance();
advance();
advance();
advance();
return new Symbol(sym.PERCENT_PREC);
} else {
emit_error("Found extraneous percent sign");
}
}
/* look for a comment */
if (next_char == '/' && (next_char2 == '*' || next_char2 == '/'))
{
/* swallow then continue the scan */
swallow_comment();
continue;
}
/* look for start of code string */
if (next_char == '{' && next_char2 == ':')
return do_code_string();
/* look for an id or keyword */
if (id_start_char(next_char)) return do_id();
/* look for EOF */
if (next_char == EOF_CHAR) return new Symbol(sym.EOF);
/* if we get here, we have an unrecognized character */
emit_warn("Unrecognized character '" +
new Character((char)next_char) + "'(" + next_char +
") -- ignored");