Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What do the one-letter prefixes in Ruby error messages mean?

Tags:

ruby

Ruby error messages often contain lexical constants with one-letter prefixes, for example:

syntax error, unexpected tIDENTIFIER, expecting kEND

Where do the t and k come from? Are there other letters? A master list of possible keywords?

like image 947
jordanpg Avatar asked Aug 06 '12 21:08

jordanpg


1 Answers

For questions like this, parse.y usually is the place to look. If memory serves, 't' stands for token whereas 'k' signifies a keyword.

Here's the different tokens that signify identifiers (in the sense of names for other things):

%token <id>   tIDENTIFIER tFID tGVAR tIVAR tCONSTANT tCVAR tLABEL

The only definition for kEND I found with a quick search was for k_end:

k_end : keyword_end
        {
          token_info_pop("end");
        }
        ;
like image 104
Michael Kohl Avatar answered Sep 22 '22 04:09

Michael Kohl