Release coccinelle-0.2.0rc1
[bpt/coccinelle.git] / parsing_cocci / lexer_script.mll
CommitLineData
34e49164
C
1{
2open Parser_cocci_menhir
3module D = Data
4module Ast = Ast_cocci
5exception Lexical of string
6let tok = Lexing.lexeme
7}
8(* ---------------------------------------------------------------------- *)
9(* tokens *)
10
002099fc 11let myrule = [^'"''@']+
34e49164
C
12
13rule token = parse
14 | myrule { TScriptData (tok lexbuf) }
15 | "@@" { TArobArob }
16 | "@" { TArob }
002099fc
C
17 | "//" [^ '\n']* { token lexbuf } (* skip SmPL comments *)
18 | '"' { TScriptData (Printf.sprintf "\"%s\"" (string lexbuf)) }
34e49164
C
19 | eof { EOF }
20 | _ { raise (Lexical ("unrecognised symbol, in token rule:"^tok lexbuf)) }
21
002099fc
C
22(* These are C strings. Perhaps they require some adjustment. *)
23and string = parse
24 | '"' { "" }
25 | (_ as x) { Common.string_of_char x ^ string lexbuf }
26 | ("\\" _) as x { x ^ string lexbuf }