Просмотр исходного кода

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 11 лет назад
Родитель
Сommit
ef3ea6fb0e
1 измененных файлов с 2 добавлено и 2 удалено
  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","\\","?","'","\""]
            | "0" (["0"-"7"])*
            | ["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","\\","?","'","\""]
            | "0" (["0"-"7"])*
            | ["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"
            )
      )