There is a file in the ruby source parse.ythat contains the grammar. I'm sure Ruby uses a separate lexer (like most LR parsers). It also seems that the lexer has the state:
enum lex_state_e {
EXPR_BEG,
EXPR_END,
EXPR_ENDARG,
EXPR_ARG,
EXPR_CMDARG,
EXPR_MID,
EXPR_FNAME,
EXPR_DOT,
EXPR_CLASS,
EXPR_VALUE
};
, , , .. "" , , . 'x.class'.
.
: parse.y, :
superclass : //[...]
| '<'
{
lex_state = EXPR_BEG;
}