Explorar o código

Fixed bug with string parsing in C/C++

There are 2 bugs fixed here:

1. The tokenizer did not recognize characters in the \xHH format. For
   example, '\x10'
2. The tokenizer interpreted '\0x10' as a proper character, which should
   actually be interpreted as '\0', 'x', '1', '0' (4 characters), which
   would not be valid if written as '\0x10'.
Roger Chen %!s(int64=11) %!d(string=hai) anos
pai
achega
ef3ea6fb0e
Modificáronse 1 ficheiros con 2 adicións e 2 borrados
  1. 2 2
      jplag.frontend.cpp/src/main/javacc/CPP.jj

+ 2 - 2
jplag.frontend.cpp/src/main/javacc/CPP.jj

@@ -248,7 +248,7 @@ TOKEN :
              ["n","t","v","b","r","f","a","\\","?","'","\""]
              ["n","t","v","b","r","f","a","\\","?","'","\""]
            | "0" (["0"-"7"])*
            | "0" (["0"-"7"])*
            | ["1"-"9"] (["0"-"9"])*
            | ["1"-"9"] (["0"-"9"])*
-           | ("0x" | "0X") (["0"-"9","a"-"f","A"-"F"])+
+           | ("X" | "x" | "U" | "u") (["0"-"9","a"-"f","A"-"F"])+
            )
            )
      )
      )
    )
    )
@@ -260,7 +260,7 @@ TOKEN :
              ["n","t","v","b","r","f","a","\\","?","'","\""]
              ["n","t","v","b","r","f","a","\\","?","'","\""]
            | "0" (["0"-"7"])*
            | "0" (["0"-"7"])*
            | ["1"-"9"] (["0"-"9"])*
            | ["1"-"9"] (["0"-"9"])*
-           | ("0")? ("X" | "x" | "u") (["0"-"9","a"-"f","A"-"F"])+
+           | ("X" | "x" | "U" | "u") (["0"-"9","a"-"f","A"-"F"])+
 	   | "\n"
 	   | "\n"
            )
            )
      )
      )