#5 Make generated if comparisons work with characters above 127

closed-fixed
nobody
None
5
2004-07-27
2004-05-03
Kevin Lin
No

On writing a lexer dealing with UTF-8 characters, I
came across a problem with generated if's. Here is a
code snippet:

if(yych <= '\277'){
//blah blah
}

The above comparison always fails (at least on MSVC
2003) since '\277' is negative. I believe it's
conformant to the C++ spec that the type of a character
literal is 'char'.

The patch changes code.cc so the above snippet becomes
if(yych <= L'\277'){
//blah blah
}

In fact, it might not be a bad idea to prefix L to
every character literal generated by RE2C.

Discussion

  • Kevin Lin
    Kevin Lin
    2004-05-03

    code.cc diff file

     
    Attachments
  • Dan Nuffer
    Dan Nuffer
    2004-07-27

    Logged In: YES
    user_id=67126

    Fixed to use hex chars.

     
  • Dan Nuffer
    Dan Nuffer
    2004-07-27

    • status: open --> closed-fixed