new try: optimized yang string parsing
This commit is contained in:
parent
8279c015d8
commit
a20865846e
2 changed files with 20 additions and 16 deletions
|
|
@ -191,14 +191,14 @@ identifier [A-Za-z_][A-Za-z0-9_\-\.]*
|
|||
<KEYWORD>\} { return *yytext; }
|
||||
<KEYWORD>; { return *yytext; }
|
||||
<KEYWORD>. { clixon_yang_parselval.string = strdup(yytext);
|
||||
BEGIN(UNKNOWN); return CHAR; }
|
||||
BEGIN(UNKNOWN); return CHARS; }
|
||||
|
||||
<UNKNOWN>: { return *yytext; }
|
||||
<UNKNOWN>; { BEGIN(KEYWORD); return *yytext; }
|
||||
<UNKNOWN>\" { _YY->yy_lex_string_state =UNKNOWN; BEGIN(STRINGDQ); return *yytext; }
|
||||
<UNKNOWN>\{ { BEGIN(KEYWORD); return *yytext; }
|
||||
<UNKNOWN>. { clixon_yang_parselval.string = strdup(yytext);
|
||||
return CHAR; }
|
||||
return CHARS; }
|
||||
|
||||
<BOOLEAN>true { clixon_yang_parselval.string = strdup(yytext);
|
||||
return BOOL; }
|
||||
|
|
@ -226,22 +226,26 @@ identifier [A-Za-z_][A-Za-z0-9_\-\.]*
|
|||
<STRING>\' { _YY->yy_lex_string_state =STRING; BEGIN(STRINGSQ); return SQ; }
|
||||
<STRING>\+ { return *yytext; }
|
||||
<STRING>. { clixon_yang_parselval.string = strdup(yytext);
|
||||
return CHAR;}
|
||||
return CHARS;}
|
||||
|
||||
<STRINGDQ>\\ { _YY->yy_lex_state = STRINGDQ; BEGIN(ESCAPE); }
|
||||
<STRINGDQ>\" { BEGIN(_YY->yy_lex_string_state); return *yytext; }
|
||||
<STRINGDQ>\n { _YY->yy_linenum++; clixon_yang_parselval.string = strdup(yytext); return CHAR;}
|
||||
<STRINGDQ>. { clixon_yang_parselval.string = strdup(yytext);
|
||||
return CHAR;}
|
||||
<STRINGDQ>\\ { _YY->yy_lex_state = STRINGDQ; BEGIN(ESCAPE); }
|
||||
<STRINGDQ>\" { BEGIN(_YY->yy_lex_string_state); return *yytext; }
|
||||
<STRINGDQ>\n { _YY->yy_linenum++;
|
||||
clixon_yang_parselval.string = strdup(yytext);
|
||||
return CHARS;}
|
||||
<STRINGDQ>[^\\"\n]+ { clixon_yang_parselval.string = strdup(yytext);
|
||||
return CHARS;}
|
||||
|
||||
<STRINGSQ>\' { BEGIN(_YY->yy_lex_string_state); return SQ; }
|
||||
<STRINGSQ>\n { _YY->yy_linenum++; clixon_yang_parselval.string = strdup(yytext); return CHAR;}
|
||||
<STRINGSQ>. { clixon_yang_parselval.string = strdup(yytext);
|
||||
return CHAR;}
|
||||
<STRINGSQ>\' { BEGIN(_YY->yy_lex_string_state); return SQ; }
|
||||
<STRINGSQ>\n { _YY->yy_linenum++;
|
||||
clixon_yang_parselval.string = strdup(yytext);
|
||||
return CHARS;}
|
||||
<STRINGSQ>[^'\n]+ { clixon_yang_parselval.string = strdup(yytext);
|
||||
return CHARS;}
|
||||
|
||||
<ESCAPE>. { BEGIN(_YY->yy_lex_state);
|
||||
clixon_yang_parselval.string = strdup(yytext);
|
||||
return CHAR; }
|
||||
return CHARS; }
|
||||
<COMMENT1>[^*\n]* /* eat anything that's not a '*' */
|
||||
<COMMENT1>"*"+[^*/\n]* /* eat up '*'s not followed by '/'s */
|
||||
<COMMENT1>"*"+"/" BEGIN(_YY->yy_lex_state);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue