aboutsummaryrefslogtreecommitdiff
path: root/cibic.l
diff options
context:
space:
mode:
authorTeddy <ted.sybil@gmail.com>2014-03-25 21:50:31 +0800
committerTeddy <ted.sybil@gmail.com>2014-03-25 21:50:31 +0800
commite9c783cec3496c3b84681ce162f6133bec8a709d (patch)
treefa1063ba1eb69cd3e560c69f0bc9e6368b4a90ce /cibic.l
parentbebc7300ad6987e76db8fca785a83123ba08a927 (diff)
fixed bugs: str and char const recogn; fields wrapping
Diffstat (limited to 'cibic.l')
-rw-r--r--cibic.l17
1 files changed, 15 insertions, 2 deletions
diff --git a/cibic.l b/cibic.l
index 75244a0..e616325 100644
--- a/cibic.l
+++ b/cibic.l
@@ -10,6 +10,9 @@ int yycolumn = 1;
letter [a-zA-Z_$]
digit [0-9]
+string ((\\.|[^\n\"\\])*)
+char ([^'\\]|\\.|\\[0-7][0-7]?[0-7]?|\\[xX][0-9a-fA-F]+)
+
%s IN_BLOCK_COMMENT IN_INLINE_COMMENT IN_DIRECTIVE
%option yylineno
%%
@@ -72,16 +75,26 @@ digit [0-9]
return INT_CONST;
}
-'([^\'\\]|\\.|\\[0-7][0-7]?[0-7]?|\\[xX][0-9a-fA-F]+)' {
+'{char}' {
yylval.strval = strdup(yytext);
return CHAR_CONST;
}
-\"[^\n\"]*\" {
+'{char} {
+ yyerror("missing terminating ' character\n");
+ exit(1);
+}
+
+\"{string}\" {
yylval.strval = strndup(yytext + 1, strlen(yytext) - 2);
return STR_CONST;
}
+\"{string} {
+ yyerror("missing terminating \" character\n");
+ exit(1);
+}
+
"||" { return OPT_OR; }
"&&" { return OPT_AND; }
"==" { return OPT_EQ; }