X-Git-Url: https://git.hcoop.net/bpt/coccinelle.git/blobdiff_plain/90aeb998d88488b4402e7b211b064056d175fcbb..f537ebc4bbd27866c9ac3e1198b6756ebab7f2ba:/parsing_cocci/lexer_script.mll diff --git a/parsing_cocci/lexer_script.mll b/parsing_cocci/lexer_script.mll index 5426f9c..d731460 100644 --- a/parsing_cocci/lexer_script.mll +++ b/parsing_cocci/lexer_script.mll @@ -33,7 +33,10 @@ let inc_line _ = Lexer_cocci.line := !Lexer_cocci.line + 1 (* ---------------------------------------------------------------------- *) (* tokens *) -let myrule = [^'"''@''/''\n''\r''\011''\012']+ +let oct = ['0'-'7'] +let hex = ['0'-'9' 'a'-'f' 'A'-'F'] + +let myrule = [^'\'''"''@''/''\n''\r''\011''\012']+ rule token = parse | myrule { TScriptData (tok lexbuf) } @@ -43,6 +46,7 @@ rule token = parse | "/" { TScriptData (tok lexbuf) } | "//" [^ '\n']* { token lexbuf } (* skip SmPL comments *) | '"' { TScriptData (Printf.sprintf "\"%s\"" (string lexbuf)) } + | "'" { TScriptData (Printf.sprintf "'%s'" (char lexbuf)) } | eof { EOF } | _ { raise (Lexical ("unrecognised symbol, in token rule:"^tok lexbuf)) } @@ -51,3 +55,9 @@ and string = parse | '"' { "" } | (_ as x) { Common.string_of_char x ^ string lexbuf } | ("\\" _) as x { x ^ string lexbuf } + +and char = parse + | (_ as x) "'" { String.make 1 x } + | (("\\" (oct | oct oct | oct oct oct)) as x "'") { x } + | (("\\x" (hex | hex hex)) as x "'") { x } + | (("\\" _ ) as x "'") { x }