#define ONIG_SYN_OP2_INEFFECTIVE_ESCAPE (1U<<20) /* \ */
#define ONIG_SYN_OP2_QMARK_LPAREN_IF_ELSE (1U<<21) /* (?(n)) (?(...)...|...) */
#define ONIG_SYN_OP2_ESC_CAPITAL_R_GENERAL_NEWLINE (1U<<22) /* \R \r\n else [\x0a-\x0d] */
+#define ONIG_SYN_OP2_ESC_CAPITAL_N_NO_NEWLINE (1U<<23) /* \N [^\n] */
/* syntax (behavior) */
#define ONIG_SYN_CONTEXT_INDEP_ANCHORS (1U<<31) /* not implemented */
ONIG_SYN_OP2_QMARK_LT_NAMED_GROUP | ONIG_SYN_OP2_ESC_K_NAMED_BACKREF |
ONIG_SYN_OP2_QMARK_LPAREN_IF_ELSE |
ONIG_SYN_OP2_ESC_CAPITAL_R_GENERAL_NEWLINE |
+ ONIG_SYN_OP2_ESC_CAPITAL_N_NO_NEWLINE |
ONIG_SYN_OP2_ESC_G_SUBEXP_CALL |
ONIG_SYN_OP2_ESC_P_BRACE_CHAR_PROPERTY |
ONIG_SYN_OP2_ESC_P_BRACE_CIRCUMFLEX_NOT |
return 0;
}
+static int
+node_new_no_newline(Node** node, ScanEnv* env)
+{
+ Node* a;
+ Node* o;
+ OnigOptionType option = env->option;
+
+ ONOFF(option, ONIG_OPTION_MULTILINE, 1);
+ a = node_new_ctype(CTYPE_ANYCHAR, 0);
+ CHECK_NULL_RETURN_MEMERR(a);
+ o = node_new_option(option);
+ if (IS_NULL(o)) {
+ onig_node_free(a);
+ return ONIGERR_MEMORY;
+ }
+ NODE_BODY(o) = a;
+
+ *node = o;
+ return 0;
+}
enum TokenSyms {
TK_EOT = 0, /* end of token */
TK_CC_OPEN,
TK_QUOTE_OPEN,
TK_CHAR_PROPERTY, /* \p{...}, \P{...} */
- TK_GENERAL_NEWLINE,
+ TK_GENERAL_NEWLINE, /* \R */
+ TK_NO_NEWLINE, /* \N */
/* in cc */
TK_CC_CLOSE,
tok->type = TK_GENERAL_NEWLINE;
break;
+ case 'N':
+ if (! IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_CAPITAL_N_NO_NEWLINE)) break;
+ tok->type = TK_NO_NEWLINE;
+ break;
+
case 'A':
if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_AZ_BUF_ANCHOR)) break;
begin_buf:
if (r < 0) return r;
break;
+ case TK_NO_NEWLINE:
+ r = node_new_no_newline(np, env);
+ if (r < 0) return r;
+ break;
+
default:
return ONIGERR_PARSER_BUG;
break;
ONIG_SYN_OP2_QMARK_LPAREN_IF_ELSE |
ONIG_SYN_OP2_ESC_P_BRACE_CHAR_PROPERTY |
ONIG_SYN_OP2_ESC_P_BRACE_CIRCUMFLEX_NOT |
- ONIG_SYN_OP2_ESC_CAPITAL_R_GENERAL_NEWLINE )
+ ONIG_SYN_OP2_ESC_CAPITAL_R_GENERAL_NEWLINE |
+ ONIG_SYN_OP2_ESC_CAPITAL_N_NO_NEWLINE )
, SYN_GNU_REGEX_BV
, ONIG_OPTION_SINGLELINE
,
ONIG_SYN_OP2_QMARK_LT_NAMED_GROUP |
ONIG_SYN_OP2_ESC_K_NAMED_BACKREF |
ONIG_SYN_OP2_ESC_G_SUBEXP_CALL |
- ONIG_SYN_OP2_ESC_CAPITAL_R_GENERAL_NEWLINE )
+ ONIG_SYN_OP2_ESC_CAPITAL_R_GENERAL_NEWLINE |
+ ONIG_SYN_OP2_ESC_CAPITAL_N_NO_NEWLINE )
, ( SYN_GNU_REGEX_BV |
ONIG_SYN_CAPTURE_ONLY_NAMED_GROUP |
ONIG_SYN_ALLOW_MULTIPLEX_DEFINITION_NAME )