summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorFUKUZAWA-Tadashi <[email protected]>2013-03-14 23:05:05 +0900
committerFUKUZAWA-Tadashi <[email protected]>2013-03-19 00:41:15 +0900
commitcdf8114e27288612139b544a6dea34e33217c88c (patch)
treefee62d7f3be856a78e4360fbc830a96f76670a03 /src
parent5217d889633fc556458b2327c30ba483e02ce6d7 (diff)
downloadmruby-cdf8114e27288612139b544a6dea34e33217c88c.tar.gz
mruby-cdf8114e27288612139b544a6dea34e33217c88c.zip
%I %i literal
Diffstat (limited to 'src')
-rw-r--r--src/codegen.c4
-rw-r--r--src/node.h1
-rw-r--r--src/parse.y30
3 files changed, 33 insertions, 2 deletions
diff --git a/src/codegen.c b/src/codegen.c
index 992275052..7a91d597d 100644
--- a/src/codegen.c
+++ b/src/codegen.c
@@ -2027,6 +2027,10 @@ codegen(codegen_scope *s, node *tree, int val)
gen_literal_array(s, tree, FALSE, val);
break;
+ case NODE_SYMBOLS:
+ gen_literal_array(s, tree, TRUE, val);
+ break;
+
case NODE_REGX:
if (val) {
char *p1 = (char*)tree->car;
diff --git a/src/node.h b/src/node.h
index bcf02e8ff..4f9db8265 100644
--- a/src/node.h
+++ b/src/node.h
@@ -108,6 +108,7 @@ enum node_type {
NODE_HEREDOC,
NODE_LITERAL_DELIM,
NODE_WORDS,
+ NODE_SYMBOLS,
NODE_LAST
};
diff --git a/src/parse.y b/src/parse.y
index 33688e45a..ee95cfb73 100644
--- a/src/parse.y
+++ b/src/parse.y
@@ -763,6 +763,13 @@ new_words(parser_state *p, node *a)
return cons((node*)NODE_WORDS, a);
}
+// (:symbols . a)
+static node*
+new_symbols(parser_state *p, node *a)
+{
+ return cons((node*)NODE_SYMBOLS, a);
+}
+
// xxx -----------------------------
// (:call a op)
@@ -991,7 +998,7 @@ heredoc_end(parser_state *p)
%type <nd> mlhs mlhs_list mlhs_post mlhs_basic mlhs_item mlhs_node mlhs_inner
%type <id> fsym sym basic_symbol operation operation2 operation3
%type <id> cname fname op f_rest_arg f_block_arg opt_f_block_arg f_norm_arg
-%type <nd> heredoc words
+%type <nd> heredoc words symbols
%token tUPLUS /* unary+ */
%token tUMINUS /* unary- */
@@ -1020,7 +1027,7 @@ heredoc_end(parser_state *p)
%token tSTAR /* * */
%token tAMPER /* & */
%token tLAMBDA /* -> */
-%token tSYMBEG tREGEXP_BEG tWORDS_BEG
+%token tSYMBEG tREGEXP_BEG tWORDS_BEG tSYMBOLS_BEG
%token tSTRING_BEG tSTRING_DVAR tLAMBEG
%token <nd> tHEREDOC_BEG /* <<, <<- */
%token tHEREDOC_END tLITERAL_DELIM
@@ -2535,6 +2542,7 @@ opt_ensure : keyword_ensure compstmt
literal : numeric
| symbol
| words
+ | symbols
;
string : tCHAR
@@ -2653,6 +2661,16 @@ sym : fname
}
;
+symbols : tSYMBOLS_BEG tSTRING
+ {
+ $$ = new_symbols(p, list1($2));
+ }
+ | tSYMBOLS_BEG string_rep tSTRING
+ {
+ $$ = new_symbols(p, push($2, $3));
+ }
+ ;
+
numeric : tINTEGER
| tFLOAT
| tUMINUS_NUM tINTEGER %prec tLOWEST
@@ -4625,6 +4643,14 @@ parser_yylex(parser_state *p)
p->lex_strterm = new_strterm(p, str_ssym, term, paren);
return tSYMBEG;
+ case 'I':
+ p->lex_strterm = new_strterm(p, str_dsymbols, term, paren);
+ return tSYMBOLS_BEG;
+
+ case 'i':
+ p->lex_strterm = new_strterm(p, str_ssymbols, term, paren);
+ return tSYMBOLS_BEG;
+
default:
yyerror(p, "unknown type of %string");
return 0;