I'm having some trouble using flex to setup a regular expression to match C-like literal chars.
I need to match the literal chars that are correct according to syntax and the incorrect ones, such has the unterminated char literals.
2 rules, one for the correct one's and one for the unterminated.
chrlit (\')([^\\\'\n]|(\\.))(\')
untermchrlit (\')([\\|\']|(.))*
I need help with the regular expressions because they're not working as I need them. Here are some examples how they should work:
' -> unterminated char constant
'/' -> CHRLIT('/')
'(' -> CHRLIT('(')
'a"b"c"de -> unterminated char constant
'abc -> unterminated char constant
'abc\ -> unterminated char constant
'\\' -> CHRLIT('\\')
';' -> CHRLIT(';')
'' -> unterminated char constant
'a' -> CHRLIT('a')
'\' -> unterminated char constant
'\;' -> CHRLIT('\;')
'\\\' -> unterminated char constant
'\\\ -> unterminated char constant
'\/' -> CHRLIT('\/')
'a\' -> unterminated char constant
'\\ -> unterminated char constant
'\t' -> CHRLIT('\t')