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
f187fdd9
Commit
f187fdd9
authored
Sep 25, 2015
by
takahashim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support Regexp literal option: //n and //u
parent
524a0388
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
9 deletions
+33
-9
mrbgems/mruby-compiler/core/codegen.c
mrbgems/mruby-compiler/core/codegen.c
+16
-4
mrbgems/mruby-compiler/core/parse.y
mrbgems/mruby-compiler/core/parse.y
+17
-5
No files found.
mrbgems/mruby-compiler/core/codegen.c
View file @
f187fdd9
...
...
@@ -2216,7 +2216,8 @@ codegen(codegen_scope *s, node *tree, int val)
case
NODE_REGX
:
if
(
val
)
{
char
*
p1
=
(
char
*
)
tree
->
car
;
char
*
p2
=
(
char
*
)
tree
->
cdr
;
char
*
p2
=
(
char
*
)
tree
->
cdr
->
car
;
char
*
p3
=
(
char
*
)
tree
->
cdr
->
cdr
;
int
ai
=
mrb_gc_arena_save
(
s
->
mrb
);
int
sym
=
new_sym
(
s
,
mrb_intern_lit
(
s
->
mrb
,
REGEXP_CLASS
));
int
off
=
new_lit
(
s
,
mrb_str_new_cstr
(
s
->
mrb
,
p1
));
...
...
@@ -2226,11 +2227,22 @@ codegen(codegen_scope *s, node *tree, int val)
genop
(
s
,
MKOP_ABx
(
OP_GETMCNST
,
cursp
(),
sym
));
push
();
genop
(
s
,
MKOP_ABx
(
OP_STRING
,
cursp
(),
off
));
if
(
p2
)
{
if
(
p2
||
p3
)
{
push
();
if
(
p2
)
{
off
=
new_lit
(
s
,
mrb_str_new_cstr
(
s
->
mrb
,
p2
));
genop
(
s
,
MKOP_ABx
(
OP_STRING
,
cursp
(),
off
));
}
else
{
genop
(
s
,
MKOP_A
(
OP_LOADNIL
,
cursp
()));
}
argc
++
;
if
(
p3
)
{
push
();
off
=
new_lit
(
s
,
mrb_str_new
(
s
->
mrb
,
p3
,
1
));
genop
(
s
,
MKOP_ABx
(
OP_STRING
,
cursp
(),
off
));
argc
++
;
pop
();
}
pop
();
}
pop
();
...
...
mrbgems/mruby-compiler/core/parse.y
View file @
f187fdd9
...
...
@@ -761,9 +761,9 @@ new_dsym(parser_state *p, node *a)
/* (:str . (a . a)) */
static node*
new_regx(parser_state *p, const char *p1, const char* p2)
new_regx(parser_state *p, const char *p1, const char* p2
, const char* p3
)
{
return cons((node*)NODE_REGX, cons((node*)p1,
(node*)p2
));
return cons((node*)NODE_REGX, cons((node*)p1,
cons((node*)p2, (node*)p3)
));
}
/* (:dregx . a) */
...
...
@@ -3986,6 +3986,8 @@ parse_string(parser_state *p)
char *s = strndup(tok(p), toklen(p));
char flags[3];
char *flag = flags;
char enc = '\0';
char *encp;
char *dup;
newtok(p);
...
...
@@ -3994,6 +3996,8 @@ parse_string(parser_state *p)
case 'i': f |= 1; break;
case 'x': f |= 2; break;
case 'm': f |= 4; break;
case 'u': f |= 16; break;
case 'n': f |= 32; break;
default: tokadd(p, re_opt); break;
}
}
...
...
@@ -4009,12 +4013,20 @@ parse_string(parser_state *p)
if (f & 1) *flag++ = 'i';
if (f & 2) *flag++ = 'x';
if (f & 4) *flag++ = 'm';
dup = strndup(flags, (size_t)(flag - flags));
if (f & 16) enc = 'u';
if (f & 32) enc = 'n';
}
else {
if (flag > flags) {
dup = strndup(flags, (size_t)(flag - flags));
} else {
dup = NULL;
}
yylval.nd = new_regx(p, s, dup);
if (enc) {
encp = strndup(&enc, 1);
} else {
encp = NULL;
}
yylval.nd = new_regx(p, s, dup, encp);
return tREGEXP;
}
...
...
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