What do single-letter prefixes mean in Ruby error messages?

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

syntax error, unexpected tIDENTIFIER waiting for kEND

Where do t and k come from? Are there any other letters? Top list of possible keywords?

+6
source share
1 answer

For such questions, parse.y is usually the place to look. If memory is used, “t” stands for token, while “k” stands for keyword.

Here are the different tokens that denote identifiers (in the sense of names for other things):

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

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

 k_end : keyword_end { token_info_pop("end"); } ; 
+8
source

Source: https://habr.com/ru/post/922246/


All Articles