Move Yang patterns: \n match from yang parse to regex compile stage

This commit is contained in:
Olof hagsand 2021-08-05 12:53:26 +02:00
parent 3ed41c5a04
commit 9aad253f1e
4 changed files with 10 additions and 90 deletions

View file

@ -89,6 +89,7 @@
* \p{Z} Separators [slp]?
* \p{S} Symbols [mcko]?
* \p{O} Other [cfon]?
* For non-printable, \n, \t, \r see https://www.regular-expressions.info/nonprint.html
*/
int
regexp_xsd2posix(char *xsd,
@ -124,6 +125,9 @@ regexp_xsd2posix(char *xsd,
case 'i': /* initial */
cprintf(cb, "[a-zA-Z_:]");
break;
case 'n': /* non-printable \n */
cprintf(cb, "\n");
break;
case 'p': /* category escape: \p{IsCategory} */
j = i+1;
if (j+2 < strlen(xsd) &&
@ -161,12 +165,18 @@ regexp_xsd2posix(char *xsd,
}
/* if syntax error, just leave it */
break;
case 'r': /* non-printable */
cprintf(cb, "\r");
break;
case 's':
cprintf(cb, "[ \t\r\n]");
break;
case 'S':
cprintf(cb, "[^ \t\r\n]");
break;
case 't': /* non-printable */
cprintf(cb, "\t");
break;
case 'w': /* word */
//cprintf(cb, "[0-9a-zA-Z_\\\\-]")
cprintf(cb, "[^[:punct:][:space:][:cntrl:]]");