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
29133b2f
Commit
29133b2f
authored
Nov 13, 2019
by
KOBAYASHI Shuji
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use `mrb_intern_lit` if possible in `parse.y`
parent
37c8cbe7
Changes
1
Show 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 @
29133b2f
...
@@ -103,12 +103,7 @@ intern_gen(parser_state *p, const char *s, size_t len)
...
@@ -103,12 +103,7 @@ intern_gen(parser_state *p, const char *s, size_t len)
}
}
#define intern(s,len) intern_gen(p,(s),(len))
#define intern(s,len) intern_gen(p,(s),(len))
static inline mrb_sym
#define intern_lit(s) mrb_intern_lit(p->mrb, s)
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))
static void
static void
cons_free_gen(parser_state *p, node *cons)
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)
...
@@ -875,7 +870,7 @@ new_op_asgn(parser_state *p, node *a, mrb_sym op, node *b)
static node*
static node*
new_imaginary(parser_state *p, node *imaginary)
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
#endif
...
@@ -883,7 +878,7 @@ new_imaginary(parser_state *p, node *imaginary)
...
@@ -883,7 +878,7 @@ new_imaginary(parser_state *p, node *imaginary)
static node*
static node*
new_rational(parser_state *p, node *rational)
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
#endif
...
@@ -1622,7 +1617,7 @@ command_asgn : lhs '=' command_rhs
...
@@ -1622,7 +1617,7 @@ command_asgn : lhs '=' command_rhs
}
}
| primary_value '[' opt_call_args ']' tOP_ASGN 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
| primary_value call_op tIDENTIFIER tOP_ASGN command_rhs
{
{
...
@@ -1851,7 +1846,7 @@ mlhs_node : variable
...
@@ -1851,7 +1846,7 @@ mlhs_node : variable
}
}
| primary_value '[' opt_call_args ']'
| primary_value '[' opt_call_args ']'
{
{
$$ = new_call(p, $1, intern
("[]",2
), $3, '.');
$$ = new_call(p, $1, intern
_lit("[]"
), $3, '.');
}
}
| primary_value call_op tIDENTIFIER
| primary_value call_op tIDENTIFIER
{
{
...
@@ -1890,7 +1885,7 @@ lhs : variable
...
@@ -1890,7 +1885,7 @@ lhs : variable
}
}
| primary_value '[' opt_call_args ']'
| primary_value '[' opt_call_args ']'
{
{
$$ = new_call(p, $1, intern
("[]",2
), $3, '.');
$$ = new_call(p, $1, intern
_lit("[]"
), $3, '.');
}
}
| primary_value call_op tIDENTIFIER
| primary_value call_op tIDENTIFIER
{
{
...
@@ -1974,36 +1969,36 @@ undef_list : fsym
...
@@ -1974,36 +1969,36 @@ undef_list : fsym
}
}
;
;
op : '|' { $$ = intern_
c('|'
); }
op : '|' { $$ = intern_
lit("|"
); }
| '^' { $$ = intern_
c('^'
); }
| '^' { $$ = intern_
lit("^"
); }
| '&' { $$ = intern_
c('&'
); }
| '&' { $$ = intern_
lit("&"
); }
| tCMP { $$ = intern
("<=>",3
); }
| tCMP { $$ = intern
_lit("<=>"
); }
| tEQ { $$ = intern
("==",2
); }
| tEQ { $$ = intern
_lit("=="
); }
| tEQQ { $$ = intern
("===",3
); }
| tEQQ { $$ = intern
_lit("==="
); }
| tMATCH { $$ = intern
("=~",2
); }
| tMATCH { $$ = intern
_lit("=~"
); }
| tNMATCH { $$ = intern
("!~",2
); }
| tNMATCH { $$ = intern
_lit("!~"
); }
| '>' { $$ = intern_
c('>'
); }
| '>' { $$ = intern_
lit(">"
); }
| tGEQ { $$ = intern
(">=",2
); }
| tGEQ { $$ = intern
_lit(">="
); }
| '<' { $$ = intern_
c('<'
); }
| '<' { $$ = intern_
lit("<"
); }
| tLEQ { $$ = intern
("<=",2
); }
| tLEQ { $$ = intern
_lit("<="
); }
| tNEQ { $$ = intern
("!=",2
); }
| tNEQ { $$ = intern
_lit("!="
); }
| tLSHFT { $$ = intern
("<<",2
); }
| tLSHFT { $$ = intern
_lit("<<"
); }
| tRSHFT { $$ = intern
(">>",2
); }
| tRSHFT { $$ = intern
_lit(">>"
); }
| '+' { $$ = intern_
c('+'
); }
| '+' { $$ = intern_
lit("+"
); }
| '-' { $$ = intern_
c('-'
); }
| '-' { $$ = intern_
lit("-"
); }
| '*' { $$ = intern_
c('*'
); }
| '*' { $$ = intern_
lit("*"
); }
| tSTAR { $$ = intern_
c('*'
); }
| tSTAR { $$ = intern_
lit("*"
); }
| '/' { $$ = intern_
c('/'
); }
| '/' { $$ = intern_
lit("/"
); }
| '%' { $$ = intern_
c('%'
); }
| '%' { $$ = intern_
lit("%"
); }
| tPOW { $$ = intern
("**",2
); }
| tPOW { $$ = intern
_lit("**"
); }
| tDSTAR { $$ = intern
("**",2
); }
| tDSTAR { $$ = intern
_lit("**"
); }
| '!' { $$ = intern_
c('!'
); }
| '!' { $$ = intern_
lit("!"
); }
| '~' { $$ = intern_
c('~'
); }
| '~' { $$ = intern_
lit("~"
); }
| tUPLUS { $$ = intern
("+@",2
); }
| tUPLUS { $$ = intern
_lit("+@"
); }
| tUMINUS { $$ = intern
("-@",2
); }
| tUMINUS { $$ = intern
_lit("-@"
); }
| tAREF { $$ = intern
("[]",2
); }
| tAREF { $$ = intern
_lit("[]"
); }
| tASET { $$ = intern
("[]=",3
); }
| tASET { $$ = intern
_lit("[]="
); }
| '`' { $$ = intern_
c('`'
); }
| '`' { $$ = intern_
lit("`"
); }
;
;
reswords : keyword__LINE__ | keyword__FILE__ | keyword__ENCODING__
reswords : keyword__LINE__ | keyword__FILE__ | keyword__ENCODING__
...
@@ -2030,7 +2025,7 @@ arg : lhs '=' arg_rhs
...
@@ -2030,7 +2025,7 @@ arg : lhs '=' arg_rhs
}
}
| primary_value '[' opt_call_args ']' tOP_ASGN 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
| primary_value call_op tIDENTIFIER tOP_ASGN arg_rhs
{
{
...
@@ -2915,11 +2910,11 @@ method_call : operation paren_args
...
@@ -2915,11 +2910,11 @@ method_call : operation paren_args
}
}
| primary_value call_op 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
| 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
| keyword_super paren_args
{
{
...
@@ -2931,7 +2926,7 @@ method_call : operation paren_args
...
@@ -2931,7 +2926,7 @@ method_call : operation paren_args
}
}
| primary_value '[' opt_call_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)
...
@@ -4818,7 +4813,7 @@ parser_yylex(parser_state *p)
case '*':
case '*':
if ((c = nextc(p)) == '*') {
if ((c = nextc(p)) == '*') {
if ((c = nextc(p)) == '=') {
if ((c = nextc(p)) == '=') {
pylval.id = intern
("**",2
);
pylval.id = intern
_lit("**"
);
p->lstate = EXPR_BEG;
p->lstate = EXPR_BEG;
return tOP_ASGN;
return tOP_ASGN;
}
}
...
@@ -4836,7 +4831,7 @@ parser_yylex(parser_state *p)
...
@@ -4836,7 +4831,7 @@ parser_yylex(parser_state *p)
}
}
else {
else {
if (c == '=') {
if (c == '=') {
pylval.id = intern_
c('*'
);
pylval.id = intern_
lit("*"
);
p->lstate = EXPR_BEG;
p->lstate = EXPR_BEG;
return tOP_ASGN;
return tOP_ASGN;
}
}
...
@@ -4952,7 +4947,7 @@ parser_yylex(parser_state *p)
...
@@ -4952,7 +4947,7 @@ parser_yylex(parser_state *p)
}
}
if (c == '<') {
if (c == '<') {
if ((c = nextc(p)) == '=') {
if ((c = nextc(p)) == '=') {
pylval.id = intern
("<<",2
);
pylval.id = intern
_lit("<<"
);
p->lstate = EXPR_BEG;
p->lstate = EXPR_BEG;
return tOP_ASGN;
return tOP_ASGN;
}
}
...
@@ -4974,7 +4969,7 @@ parser_yylex(parser_state *p)
...
@@ -4974,7 +4969,7 @@ parser_yylex(parser_state *p)
}
}
if (c == '>') {
if (c == '>') {
if ((c = nextc(p)) == '=') {
if ((c = nextc(p)) == '=') {
pylval.id = intern
(">>",2
);
pylval.id = intern
_lit(">>"
);
p->lstate = EXPR_BEG;
p->lstate = EXPR_BEG;
return tOP_ASGN;
return tOP_ASGN;
}
}
...
@@ -5082,7 +5077,7 @@ parser_yylex(parser_state *p)
...
@@ -5082,7 +5077,7 @@ parser_yylex(parser_state *p)
if ((c = nextc(p)) == '&') {
if ((c = nextc(p)) == '&') {
p->lstate = EXPR_BEG;
p->lstate = EXPR_BEG;
if ((c = nextc(p)) == '=') {
if ((c = nextc(p)) == '=') {
pylval.id = intern
("&&",2
);
pylval.id = intern
_lit("&&"
);
p->lstate = EXPR_BEG;
p->lstate = EXPR_BEG;
return tOP_ASGN;
return tOP_ASGN;
}
}
...
@@ -5094,7 +5089,7 @@ parser_yylex(parser_state *p)
...
@@ -5094,7 +5089,7 @@ parser_yylex(parser_state *p)
return tANDDOT;
return tANDDOT;
}
}
else if (c == '=') {
else if (c == '=') {
pylval.id = intern_
c('&'
);
pylval.id = intern_
lit("&"
);
p->lstate = EXPR_BEG;
p->lstate = EXPR_BEG;
return tOP_ASGN;
return tOP_ASGN;
}
}
...
@@ -5121,7 +5116,7 @@ parser_yylex(parser_state *p)
...
@@ -5121,7 +5116,7 @@ parser_yylex(parser_state *p)
if ((c = nextc(p)) == '|') {
if ((c = nextc(p)) == '|') {
p->lstate = EXPR_BEG;
p->lstate = EXPR_BEG;
if ((c = nextc(p)) == '=') {
if ((c = nextc(p)) == '=') {
pylval.id = intern
("||",2
);
pylval.id = intern
_lit("||"
);
p->lstate = EXPR_BEG;
p->lstate = EXPR_BEG;
return tOP_ASGN;
return tOP_ASGN;
}
}
...
@@ -5129,7 +5124,7 @@ parser_yylex(parser_state *p)
...
@@ -5129,7 +5124,7 @@ parser_yylex(parser_state *p)
return tOROP;
return tOROP;
}
}
if (c == '=') {
if (c == '=') {
pylval.id = intern_
c('|'
);
pylval.id = intern_
lit("|"
);
p->lstate = EXPR_BEG;
p->lstate = EXPR_BEG;
return tOP_ASGN;
return tOP_ASGN;
}
}
...
@@ -5153,7 +5148,7 @@ parser_yylex(parser_state *p)
...
@@ -5153,7 +5148,7 @@ parser_yylex(parser_state *p)
return '+';
return '+';
}
}
if (c == '=') {
if (c == '=') {
pylval.id = intern_
c('+'
);
pylval.id = intern_
lit("+"
);
p->lstate = EXPR_BEG;
p->lstate = EXPR_BEG;
return tOP_ASGN;
return tOP_ASGN;
}
}
...
@@ -5181,7 +5176,7 @@ parser_yylex(parser_state *p)
...
@@ -5181,7 +5176,7 @@ parser_yylex(parser_state *p)
return '-';
return '-';
}
}
if (c == '=') {
if (c == '=') {
pylval.id = intern_
c('-'
);
pylval.id = intern_
lit("-"
);
p->lstate = EXPR_BEG;
p->lstate = EXPR_BEG;
return tOP_ASGN;
return tOP_ASGN;
}
}
...
@@ -5515,7 +5510,7 @@ parser_yylex(parser_state *p)
...
@@ -5515,7 +5510,7 @@ parser_yylex(parser_state *p)
return tREGEXP_BEG;
return tREGEXP_BEG;
}
}
if ((c = nextc(p)) == '=') {
if ((c = nextc(p)) == '=') {
pylval.id = intern_
c('/'
);
pylval.id = intern_
lit("/"
);
p->lstate = EXPR_BEG;
p->lstate = EXPR_BEG;
return tOP_ASGN;
return tOP_ASGN;
}
}
...
@@ -5534,7 +5529,7 @@ parser_yylex(parser_state *p)
...
@@ -5534,7 +5529,7 @@ parser_yylex(parser_state *p)
case '^':
case '^':
if ((c = nextc(p)) == '=') {
if ((c = nextc(p)) == '=') {
pylval.id = intern_
c('^'
);
pylval.id = intern_
lit("^"
);
p->lstate = EXPR_BEG;
p->lstate = EXPR_BEG;
return tOP_ASGN;
return tOP_ASGN;
}
}
...
@@ -5711,7 +5706,7 @@ parser_yylex(parser_state *p)
...
@@ -5711,7 +5706,7 @@ parser_yylex(parser_state *p)
}
}
}
}
if ((c = nextc(p)) == '=') {
if ((c = nextc(p)) == '=') {
pylval.id = intern_
c('%'
);
pylval.id = intern_
lit("%"
);
p->lstate = EXPR_BEG;
p->lstate = EXPR_BEG;
return tOP_ASGN;
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