[前][次][番号順一覧][スレッド一覧]

ruby-changes:55042

From: nobu <ko1@a...>
Date: Thu, 14 Mar 2019 11:18:09 +0900 (JST)
Subject: [ruby-changes:55042] nobu:r67249 (trunk): More initializations of YYLTYPE

nobu	2019-03-14 11:18:05 +0900 (Thu, 14 Mar 2019)

  New Revision: 67249

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=67249

  Log:
    More initializations of YYLTYPE

  Modified files:
    trunk/parse.y
Index: parse.y
===================================================================
--- parse.y	(revision 67248)
+++ parse.y	(revision 67249)
@@ -71,6 +71,11 @@ https://github.com/ruby/ruby/blob/trunk/parse.y#L71
     rb_parser_set_location_of_none(p, &(Current))
 #define RUBY_SET_YYLLOC(Current)					\
     rb_parser_set_location(p, &(Current))
+#define RUBY_INIT_YYLLOC() \
+    { \
+	{p->ruby_sourceline, (int)(p->lex.ptok - p->lex.pbeg)}, \
+	{p->ruby_sourceline, (int)(p->lex.pcur - p->lex.pbeg)}, \
+    }
 
 enum lex_state_bits {
     EXPR_BEG_bit,		/* ignore newline, +/- is a sign. */
@@ -518,9 +523,9 @@ enum lex_state_e rb_parser_trace_lex_sta https://github.com/ruby/ruby/blob/trunk/parse.y#L523
 VALUE rb_parser_lex_state_name(enum lex_state_e state);
 void rb_parser_show_bitstack(struct parser_params *, stack_type, const char *, int);
 PRINTF_ARGS(void rb_parser_fatal(struct parser_params *p, const char *fmt, ...), 2, 3);
-void rb_parser_set_location_from_strterm_heredoc(struct parser_params *p, rb_strterm_heredoc_t *here, YYLTYPE *yylloc);
-void rb_parser_set_location_of_none(struct parser_params *p, YYLTYPE *yylloc);
-void rb_parser_set_location(struct parser_params *p, YYLTYPE *yylloc);
+YYLTYPE *rb_parser_set_location_from_strterm_heredoc(struct parser_params *p, rb_strterm_heredoc_t *here, YYLTYPE *yylloc);
+YYLTYPE *rb_parser_set_location_of_none(struct parser_params *p, YYLTYPE *yylloc);
+YYLTYPE *rb_parser_set_location(struct parser_params *p, YYLTYPE *yylloc);
 RUBY_SYMBOL_EXPORT_END
 
 static void parser_token_value_print(struct parser_params *p, enum yytokentype type, const YYSTYPE *valp);
@@ -4674,8 +4679,7 @@ parser_yyerror(struct parser_params *p, https://github.com/ruby/ruby/blob/trunk/parse.y#L4679
     YYLTYPE current;
 
     if (!yylloc) {
-	RUBY_SET_YYLLOC(current);
-	yylloc = &current;
+	yylloc = RUBY_SET_YYLLOC(current);
 	token_flush(p);
     }
     else if ((p->ruby_sourceline != yylloc->beg_pos.lineno &&
@@ -5636,8 +5640,7 @@ regx_options(struct parser_params *p) https://github.com/ruby/ruby/blob/trunk/parse.y#L5640
 	static const char sep[] = " - ";
 	const int mlen = (int)(sizeof(mesg) - 1 - (toklen(p) == 1));
 	const int seplen = (int)(sizeof(sep) - 1);
-	YYLTYPE loc;
-	RUBY_SET_YYLLOC(loc);
+	YYLTYPE loc = RUBY_INIT_YYLLOC();
 	tokfix(p);
 	tokspace(p, toklen(p) + mlen + seplen);
 	memmove(tok(p) + mlen + seplen, tok(p), toklen(p) + 1);
@@ -9159,7 +9162,7 @@ rb_parser_fatal(struct parser_params *p, https://github.com/ruby/ruby/blob/trunk/parse.y#L9162
     p->debug = TRUE;
 }
 
-void
+YYLTYPE *
 rb_parser_set_location_from_strterm_heredoc(struct parser_params *p, rb_strterm_heredoc_t *here, YYLTYPE *yylloc)
 {
     const char *eos = RSTRING_PTR(here->term);
@@ -9169,24 +9172,27 @@ rb_parser_set_location_from_strterm_here https://github.com/ruby/ruby/blob/trunk/parse.y#L9172
     yylloc->beg_pos.column = (int)(here->u3.lastidx - term_len);
     yylloc->end_pos.lineno = (int)here->sourceline;
     yylloc->end_pos.column = (int)(here->u3.lastidx);
+    return yylloc;
 }
 
-void
+YYLTYPE *
 rb_parser_set_location_of_none(struct parser_params *p, YYLTYPE *yylloc)
 {
     yylloc->beg_pos.lineno = p->ruby_sourceline;
     yylloc->beg_pos.column = (int)(p->lex.ptok - p->lex.pbeg);
     yylloc->end_pos.lineno = p->ruby_sourceline;
     yylloc->end_pos.column = (int)(p->lex.ptok - p->lex.pbeg);
+    return yylloc;
 }
 
-void
+YYLTYPE *
 rb_parser_set_location(struct parser_params *p, YYLTYPE *yylloc)
 {
     yylloc->beg_pos.lineno = p->ruby_sourceline;
     yylloc->beg_pos.column = (int)(p->lex.ptok - p->lex.pbeg);
     yylloc->end_pos.lineno = p->ruby_sourceline;
     yylloc->end_pos.column = (int)(p->lex.pcur - p->lex.pbeg);
+    return yylloc;
 }
 #endif /* !RIPPER */
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]