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