summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorFUKUZAWA-Tadashi <[email protected]>2013-03-12 21:54:17 +0900
committerMasaki Muranaka <[email protected]>2013-03-19 11:03:07 +0900
commit05e735595e05fbc37e130c788753df656ca0152f (patch)
treeea97d0f394d7bc7741ac640871b50a6a580180c6 /include
parenta4c30b93acf931c49d79fb4b0c474dd66fbedcf4 (diff)
downloadmruby-05e735595e05fbc37e130c788753df656ca0152f.tar.gz
mruby-05e735595e05fbc37e130c788753df656ca0152f.zip
implement literal %W %w %s
refactor string parsing
Diffstat (limited to 'include')
-rw-r--r--include/mruby/compile.h28
1 files changed, 21 insertions, 7 deletions
diff --git a/include/mruby/compile.h b/include/mruby/compile.h
index 382a5e6ff..45eb72403 100644
--- a/include/mruby/compile.h
+++ b/include/mruby/compile.h
@@ -58,16 +58,31 @@ struct mrb_parser_message {
char* message;
};
-/* heredoc parse type */
-enum heredoc_type {
- heredoc_type_norm, /* <<EOH */
- heredoc_type_quote, /* <<'EOH' */
+#define STR_FUNC_PARSING 0x01
+#define STR_FUNC_EXPAND 0x02
+#define STR_FUNC_REGEXP 0x04
+#define STR_FUNC_WORD 0x08
+#define STR_FUNC_SYMBOL 0x10
+#define STR_FUNC_ARRAY 0x20
+#define STR_FUNC_HEREDOC 0x40
+
+enum mrb_string_type {
+ str_not_parsing = (0),
+ str_squote = (STR_FUNC_PARSING),
+ str_dquote = (STR_FUNC_PARSING|STR_FUNC_EXPAND),
+ str_regexp = (STR_FUNC_PARSING|STR_FUNC_REGEXP|STR_FUNC_EXPAND),
+ str_sword = (STR_FUNC_PARSING|STR_FUNC_WORD|STR_FUNC_ARRAY),
+ str_dword = (STR_FUNC_PARSING|STR_FUNC_WORD|STR_FUNC_ARRAY|STR_FUNC_EXPAND),
+ str_ssym = (STR_FUNC_PARSING|STR_FUNC_SYMBOL),
+ str_sheredoc = (STR_FUNC_PARSING|STR_FUNC_HEREDOC),
+ str_dheredoc = (STR_FUNC_PARSING|STR_FUNC_HEREDOC|STR_FUNC_EXPAND),
};
+
/* heredoc structure */
struct mrb_parser_heredoc_info {
- enum heredoc_type type;
mrb_bool allow_indent:1;
mrb_bool line_head:1;
+ enum mrb_string_type type;
const char *term;
int term_len;
mrb_ast_node *doc;
@@ -85,8 +100,7 @@ struct mrb_parser_state {
int column;
enum mrb_lex_state_enum lstate;
- int sterm; /* string terminator : ' ' means heredoc */
- int regexp;
+ mrb_ast_node *lex_strterm; /* (type nest_level beg . end) */
unsigned int cond_stack;
unsigned int cmdarg_stack;