Release coccinelle-0.2.4rc2
[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 let inc_line _ = Lexer_cocci.line := !Lexer_cocci.line + 1
8 }
9 (* ---------------------------------------------------------------------- *)
10 (* tokens *)
11
12 let myrule = [^'"''@''/''\n''\r''\011''\012']+
13
14 rule token = parse
15 | myrule { TScriptData (tok lexbuf) }
16 | ['\n' '\r' '\011' '\012'] { inc_line(); TScriptData (tok lexbuf) }
17 | "@@" { TArobArob }
18 | "@" { TArob }
19 | "/" { TScriptData (tok lexbuf) }
20 | "//" [^ '\n']* { token lexbuf } (* skip SmPL comments *)
21 | '"' { TScriptData (Printf.sprintf "\"%s\"" (string lexbuf)) }
22 | eof { EOF }
23 | _ { raise (Lexical ("unrecognised symbol, in token rule:"^tok lexbuf)) }
24
25 (* These are C strings. Perhaps they require some adjustment. *)
26 and string = parse
27 | '"' { "" }
28 | (_ as x) { Common.string_of_char x ^ string lexbuf }
29 | ("\\" _) as x { x ^ string lexbuf }