From 56fdc449ebc1b0a6bd67881fdafbc271b6d00330 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Thu, 21 Jan 2021 14:42:39 +0900 Subject: Better error messages with yacc tokens. --- mrbgems/mruby-compiler/core/parse.y | 75 +++++++++++++++++++++---------------- 1 file changed, 43 insertions(+), 32 deletions(-) diff --git a/mrbgems/mruby-compiler/core/parse.y b/mrbgems/mruby-compiler/core/parse.y index 909dcef7c..e874a145a 100644 --- a/mrbgems/mruby-compiler/core/parse.y +++ b/mrbgems/mruby-compiler/core/parse.y @@ -1435,12 +1435,21 @@ heredoc_end(parser_state *p) keyword__FILE__ keyword__ENCODING__ -%token tIDENTIFIER tFID tGVAR tIVAR tCONSTANT tCVAR tLABEL_TAG -%token tINTEGER tFLOAT tCHAR tXSTRING tREGEXP +%token tIDENTIFIER "local variable or method" +%token tFID "method" +%token tGVAR "global variable" +%token tIVAR "instance variable" +%token tCONSTANT "constant" +%token tCVAR "class variable" +%token tLABEL_TAG "label" +%token tINTEGER "integer literal" +%token tFLOAT "float literal" +%token tCHAR "character literal" +%token tXSTRING tREGEXP %token tSTRING tSTRING_PART tSTRING_MID %token tNTH_REF tBACK_REF %token tREGEXP_END -%token tNUMPARAM +%token tNUMPARAM "numbered paraemeter" %type singleton string string_fragment string_rep string_interp xstring regexp %type literal numeric cpath symbol defn_head defs_head @@ -1468,39 +1477,41 @@ heredoc_end(parser_state *p) %type f_block_kwarg f_block_kw block_args_tail opt_block_args_tail %type f_label -%token tUPLUS /* unary+ */ -%token tUMINUS /* unary- */ -%token tPOW /* ** */ -%token tCMP /* <=> */ -%token tEQ /* == */ -%token tEQQ /* === */ -%token tNEQ /* != */ -%token tGEQ /* >= */ -%token tLEQ /* <= */ -%token tANDOP tOROP /* && and || */ -%token tMATCH tNMATCH /* =~ and !~ */ -%token tDOT2 tDOT3 /* .. and ... */ +%token tUPLUS "unary plus" +%token tUMINUS "unary minus" +%token tCMP "<=>" +%token tEQ "==" +%token tEQQ "===" +%token tNEQ "!=" +%token tGEQ ">=" +%token tLEQ "<=" +%token tANDOP "&&" +%token tOROP "||" +%token tMATCH "=~" +%token tNMATCH "!~" +%token tDOT2 ".." +%token tDOT3 "..." %token tBDOT2 tBDOT3 /* (.. and (... */ %token tAREF tASET /* [] and []= */ -%token tLSHFT tRSHFT /* << and >> */ -%token tCOLON2 /* :: */ +%token tLSHFT "<<" +%token tRSHFT ">>" +%token tCOLON2 "::" %token tCOLON3 /* :: at EXPR_BEG */ %token tOP_ASGN /* +=, -= etc. */ -%token tASSOC /* => */ -%token tLPAREN /* ( */ -%token tLPAREN_ARG /* ( */ -%token tRPAREN /* ) */ -%token tLBRACK /* [ */ -%token tLBRACE /* { */ -%token tLBRACE_ARG /* { */ -%token tSTAR /* * */ -%token tDSTAR /* ** */ -%token tAMPER /* & */ -%token tLAMBDA /* -> */ -%token tANDDOT /* &. */ -%token tSYMBEG tREGEXP_BEG tWORDS_BEG tSYMBOLS_BEG -%token tSTRING_BEG tXSTRING_BEG tSTRING_DVAR tLAMBEG -%token tHEREDOC_BEG /* <<, <<-, <<~ */ +%token tASSOC "=>" +%token tLPAREN tLPAREN_ARG "(" +%token tRPAREN ")" +%token tLBRACK "[" +%token tLBRACE tLBRACE_ARG "{" +%token tSTAR "*" +%token tPOW tDSTAR "**" +%token tAMPER "&" +%token tLAMBDA "->" +%token tANDDOT "&." +%token tSYMBEG "symbol" +%token tSTRING_BEG "string literal" +%token tXSTRING_BEG tSTRING_DVAR tREGEXP_BEG tWORDS_BEG tSYMBOLS_BEG tLAMBEG +%token tHEREDOC_BEG "here document" %token tHEREDOC_END tLITERAL_DELIM tHD_LITERAL_DELIM %token tHD_STRING_PART tHD_STRING_MID -- cgit v1.2.3