Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
db437383
Unverified
Commit
db437383
authored
Nov 13, 2019
by
Yukihiro "Matz" Matsumoto
Committed by
GitHub
Nov 13, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4821 from shuujii/use-mrb_intern_lit-if-possible-in-parse.y
Use `mrb_intern_lit` if possible in `parse.y`
parents
079aff17
29133b2f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
58 deletions
+53
-58
mrbgems/mruby-compiler/core/parse.y
mrbgems/mruby-compiler/core/parse.y
+53
-58
No files found.
mrbgems/mruby-compiler/core/parse.y
View file @
db437383
...
...
@@ -103,12 +103,7 @@ intern_gen(parser_state *p, const char *s, size_t len)
}
#define intern(s,len) intern_gen(p,(s),(len))
static inline mrb_sym
intern_gen_c(parser_state *p, const char c)
{
return mrb_intern(p->mrb, &c, 1);
}
#define intern_c(c) intern_gen_c(p,(c))
#define intern_lit(s) mrb_intern_lit(p->mrb, s)
static void
cons_free_gen(parser_state *p, node *cons)
...
...
@@ -875,7 +870,7 @@ new_op_asgn(parser_state *p, node *a, mrb_sym op, node *b)
static node*
new_imaginary(parser_state *p, node *imaginary)
{
return new_call(p, new_const(p, intern_
cstr("Kernel")), intern_cstr
("Complex"), list1(list2(list3((node*)NODE_INT, (node*)strdup("0"), nint(10)), imaginary)), 1);
return new_call(p, new_const(p, intern_
lit("Kernel")), intern_lit
("Complex"), list1(list2(list3((node*)NODE_INT, (node*)strdup("0"), nint(10)), imaginary)), 1);
}
#endif
...
...
@@ -883,7 +878,7 @@ new_imaginary(parser_state *p, node *imaginary)
static node*
new_rational(parser_state *p, node *rational)
{
return new_call(p, new_const(p, intern_
cstr("Kernel")), intern_cstr
("Rational"), list1(list1(rational)), 1);
return new_call(p, new_const(p, intern_
lit("Kernel")), intern_lit
("Rational"), list1(list1(rational)), 1);
}
#endif
...
...
@@ -1622,7 +1617,7 @@ command_asgn : lhs '=' command_rhs
}
| primary_value '[' opt_call_args ']' tOP_ASGN command_rhs
{
$$ = new_op_asgn(p, new_call(p, $1, intern
("[]",2
), $3, '.'), $5, $6);
$$ = new_op_asgn(p, new_call(p, $1, intern
_lit("[]"
), $3, '.'), $5, $6);
}
| primary_value call_op tIDENTIFIER tOP_ASGN command_rhs
{
...
...
@@ -1851,7 +1846,7 @@ mlhs_node : variable
}
| primary_value '[' opt_call_args ']'
{
$$ = new_call(p, $1, intern
("[]",2
), $3, '.');
$$ = new_call(p, $1, intern
_lit("[]"
), $3, '.');
}
| primary_value call_op tIDENTIFIER
{
...
...
@@ -1890,7 +1885,7 @@ lhs : variable
}
| primary_value '[' opt_call_args ']'
{
$$ = new_call(p, $1, intern
("[]",2
), $3, '.');
$$ = new_call(p, $1, intern
_lit("[]"
), $3, '.');
}
| primary_value call_op tIDENTIFIER
{
...
...
@@ -1974,36 +1969,36 @@ undef_list : fsym
}
;
op : '|' { $$ = intern_
c('|'
); }
| '^' { $$ = intern_
c('^'
); }
| '&' { $$ = intern_
c('&'
); }
| tCMP { $$ = intern
("<=>",3
); }
| tEQ { $$ = intern
("==",2
); }
| tEQQ { $$ = intern
("===",3
); }
| tMATCH { $$ = intern
("=~",2
); }
| tNMATCH { $$ = intern
("!~",2
); }
| '>' { $$ = intern_
c('>'
); }
| tGEQ { $$ = intern
(">=",2
); }
| '<' { $$ = intern_
c('<'
); }
| tLEQ { $$ = intern
("<=",2
); }
| tNEQ { $$ = intern
("!=",2
); }
| tLSHFT { $$ = intern
("<<",2
); }
| tRSHFT { $$ = intern
(">>",2
); }
| '+' { $$ = intern_
c('+'
); }
| '-' { $$ = intern_
c('-'
); }
| '*' { $$ = intern_
c('*'
); }
| tSTAR { $$ = intern_
c('*'
); }
| '/' { $$ = intern_
c('/'
); }
| '%' { $$ = intern_
c('%'
); }
| tPOW { $$ = intern
("**",2
); }
| tDSTAR { $$ = intern
("**",2
); }
| '!' { $$ = intern_
c('!'
); }
| '~' { $$ = intern_
c('~'
); }
| tUPLUS { $$ = intern
("+@",2
); }
| tUMINUS { $$ = intern
("-@",2
); }
| tAREF { $$ = intern
("[]",2
); }
| tASET { $$ = intern
("[]=",3
); }
| '`' { $$ = intern_
c('`'
); }
op : '|' { $$ = intern_
lit("|"
); }
| '^' { $$ = intern_
lit("^"
); }
| '&' { $$ = intern_
lit("&"
); }
| tCMP { $$ = intern
_lit("<=>"
); }
| tEQ { $$ = intern
_lit("=="
); }
| tEQQ { $$ = intern
_lit("==="
); }
| tMATCH { $$ = intern
_lit("=~"
); }
| tNMATCH { $$ = intern
_lit("!~"
); }
| '>' { $$ = intern_
lit(">"
); }
| tGEQ { $$ = intern
_lit(">="
); }
| '<' { $$ = intern_
lit("<"
); }
| tLEQ { $$ = intern
_lit("<="
); }
| tNEQ { $$ = intern
_lit("!="
); }
| tLSHFT { $$ = intern
_lit("<<"
); }
| tRSHFT { $$ = intern
_lit(">>"
); }
| '+' { $$ = intern_
lit("+"
); }
| '-' { $$ = intern_
lit("-"
); }
| '*' { $$ = intern_
lit("*"
); }
| tSTAR { $$ = intern_
lit("*"
); }
| '/' { $$ = intern_
lit("/"
); }
| '%' { $$ = intern_
lit("%"
); }
| tPOW { $$ = intern
_lit("**"
); }
| tDSTAR { $$ = intern
_lit("**"
); }
| '!' { $$ = intern_
lit("!"
); }
| '~' { $$ = intern_
lit("~"
); }
| tUPLUS { $$ = intern
_lit("+@"
); }
| tUMINUS { $$ = intern
_lit("-@"
); }
| tAREF { $$ = intern
_lit("[]"
); }
| tASET { $$ = intern
_lit("[]="
); }
| '`' { $$ = intern_
lit("`"
); }
;
reswords : keyword__LINE__ | keyword__FILE__ | keyword__ENCODING__
...
...
@@ -2030,7 +2025,7 @@ arg : lhs '=' arg_rhs
}
| primary_value '[' opt_call_args ']' tOP_ASGN arg_rhs
{
$$ = new_op_asgn(p, new_call(p, $1, intern
("[]",2
), $3, '.'), $5, $6);
$$ = new_op_asgn(p, new_call(p, $1, intern
_lit("[]"
), $3, '.'), $5, $6);
}
| primary_value call_op tIDENTIFIER tOP_ASGN arg_rhs
{
...
...
@@ -2915,11 +2910,11 @@ method_call : operation paren_args
}
| primary_value call_op paren_args
{
$$ = new_call(p, $1, intern
("call",4
), $3, $2);
$$ = new_call(p, $1, intern
_lit("call"
), $3, $2);
}
| primary_value tCOLON2 paren_args
{
$$ = new_call(p, $1, intern
("call",4
), $3, tCOLON2);
$$ = new_call(p, $1, intern
_lit("call"
), $3, tCOLON2);
}
| keyword_super paren_args
{
...
...
@@ -2931,7 +2926,7 @@ method_call : operation paren_args
}
| primary_value '[' opt_call_args ']'
{
$$ = new_call(p, $1, intern
("[]",2
), $3, '.');
$$ = new_call(p, $1, intern
_lit("[]"
), $3, '.');
}
;
...
...
@@ -4818,7 +4813,7 @@ parser_yylex(parser_state *p)
case '*':
if ((c = nextc(p)) == '*') {
if ((c = nextc(p)) == '=') {
pylval.id = intern
("**",2
);
pylval.id = intern
_lit("**"
);
p->lstate = EXPR_BEG;
return tOP_ASGN;
}
...
...
@@ -4836,7 +4831,7 @@ parser_yylex(parser_state *p)
}
else {
if (c == '=') {
pylval.id = intern_
c('*'
);
pylval.id = intern_
lit("*"
);
p->lstate = EXPR_BEG;
return tOP_ASGN;
}
...
...
@@ -4952,7 +4947,7 @@ parser_yylex(parser_state *p)
}
if (c == '<') {
if ((c = nextc(p)) == '=') {
pylval.id = intern
("<<",2
);
pylval.id = intern
_lit("<<"
);
p->lstate = EXPR_BEG;
return tOP_ASGN;
}
...
...
@@ -4974,7 +4969,7 @@ parser_yylex(parser_state *p)
}
if (c == '>') {
if ((c = nextc(p)) == '=') {
pylval.id = intern
(">>",2
);
pylval.id = intern
_lit(">>"
);
p->lstate = EXPR_BEG;
return tOP_ASGN;
}
...
...
@@ -5082,7 +5077,7 @@ parser_yylex(parser_state *p)
if ((c = nextc(p)) == '&') {
p->lstate = EXPR_BEG;
if ((c = nextc(p)) == '=') {
pylval.id = intern
("&&",2
);
pylval.id = intern
_lit("&&"
);
p->lstate = EXPR_BEG;
return tOP_ASGN;
}
...
...
@@ -5094,7 +5089,7 @@ parser_yylex(parser_state *p)
return tANDDOT;
}
else if (c == '=') {
pylval.id = intern_
c('&'
);
pylval.id = intern_
lit("&"
);
p->lstate = EXPR_BEG;
return tOP_ASGN;
}
...
...
@@ -5121,7 +5116,7 @@ parser_yylex(parser_state *p)
if ((c = nextc(p)) == '|') {
p->lstate = EXPR_BEG;
if ((c = nextc(p)) == '=') {
pylval.id = intern
("||",2
);
pylval.id = intern
_lit("||"
);
p->lstate = EXPR_BEG;
return tOP_ASGN;
}
...
...
@@ -5129,7 +5124,7 @@ parser_yylex(parser_state *p)
return tOROP;
}
if (c == '=') {
pylval.id = intern_
c('|'
);
pylval.id = intern_
lit("|"
);
p->lstate = EXPR_BEG;
return tOP_ASGN;
}
...
...
@@ -5153,7 +5148,7 @@ parser_yylex(parser_state *p)
return '+';
}
if (c == '=') {
pylval.id = intern_
c('+'
);
pylval.id = intern_
lit("+"
);
p->lstate = EXPR_BEG;
return tOP_ASGN;
}
...
...
@@ -5181,7 +5176,7 @@ parser_yylex(parser_state *p)
return '-';
}
if (c == '=') {
pylval.id = intern_
c('-'
);
pylval.id = intern_
lit("-"
);
p->lstate = EXPR_BEG;
return tOP_ASGN;
}
...
...
@@ -5515,7 +5510,7 @@ parser_yylex(parser_state *p)
return tREGEXP_BEG;
}
if ((c = nextc(p)) == '=') {
pylval.id = intern_
c('/'
);
pylval.id = intern_
lit("/"
);
p->lstate = EXPR_BEG;
return tOP_ASGN;
}
...
...
@@ -5534,7 +5529,7 @@ parser_yylex(parser_state *p)
case '^':
if ((c = nextc(p)) == '=') {
pylval.id = intern_
c('^'
);
pylval.id = intern_
lit("^"
);
p->lstate = EXPR_BEG;
return tOP_ASGN;
}
...
...
@@ -5711,7 +5706,7 @@ parser_yylex(parser_state *p)
}
}
if ((c = nextc(p)) == '=') {
pylval.id = intern_
c('%'
);
pylval.id = intern_
lit("%"
);
p->lstate = EXPR_BEG;
return tOP_ASGN;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment