diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-08-28 22:42:06 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-08-28 22:42:06 +0900 |
| commit | 1260d3b68a2b7ed3398804c89a9c5933b259ef7c (patch) | |
| tree | 131dfed106b33f61315a5bcd5519aeac1921b948 /mrbgems/mruby-compiler/core/parse.y | |
| parent | f1fa5bf1c6e353c7d18f2ca57cf2808ec46dd301 (diff) | |
| download | mruby-1260d3b68a2b7ed3398804c89a9c5933b259ef7c.tar.gz mruby-1260d3b68a2b7ed3398804c89a9c5933b259ef7c.zip | |
Add `__ENCODING__' support.
`__ENCODING__' returns the current encoding name (string), unlike
CRuby that returns the encoding object.
Diffstat (limited to 'mrbgems/mruby-compiler/core/parse.y')
| -rw-r--r-- | mrbgems/mruby-compiler/core/parse.y | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/mrbgems/mruby-compiler/core/parse.y b/mrbgems/mruby-compiler/core/parse.y index 5cecfc06b..0e425b189 100644 --- a/mrbgems/mruby-compiler/core/parse.y +++ b/mrbgems/mruby-compiler/core/parse.y @@ -2968,6 +2968,15 @@ var_ref : variable snprintf(buf, sizeof(buf), "%d", p->lineno); $$ = new_int(p, buf, 10); } + | keyword__ENCODING__ + { +#ifdef MRB_UTF8_STRING + const char *enc = "UTF-8"; +#else + const char *enc = "ASCII-8BIT"; +#endif + $$ = new_str(p, enc, strlen(enc)); + } ; backref : tNTH_REF |
