package pfff

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file test_analyze_cpp.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
open Common

module PI = Parse_info

(*****************************************************************************)
(* Helpers *)
(*****************************************************************************)

(*****************************************************************************)
(* Subsystem testing, no db *)
(*****************************************************************************)

let test_highlight_cpp file =

  let (ast2, _stat) = Parse_cpp.parse file in

  let h = Hashtbl.create 101 in

  ast2 +> List.iter (fun (ast, toks) ->
    (* computing the token attributes *)
    let prefs = Highlight_code.default_highlighter_preferences in

    Highlight_cpp.visit_toplevel 
      ~tag_hook:(fun info categ -> Hashtbl.add h info categ)
      prefs
      (ast, toks)
    ;

    (* getting the text *)
    let _ = toks +> Common.map_filter (fun tok -> 
      let info = Token_helpers_cpp.info_of_tok tok in
      let s = PI.str_of_info info in

      if not (PI.is_origintok info)
      then None
      else 
        let categ = Common2.hfind_option info h in
        let categ = categ +> Common2.fmap (fun categ ->
              (*
                rewrite_categ_using_entities s categ file hentities
              *)
          categ
        )
        in
        Some (s, categ,
              { Common2.l = PI.line_of_info info;
                c = PI.col_of_info info;
              })
    )
    in
    ()
  )

(*****************************************************************************)
(* Main entry for Arg *)
(*****************************************************************************)

let actions () = [
    "-test_highlight_cpp",  " <file>",
    Common.mk_action_1_arg test_highlight_cpp;
]
OCaml

Innovation. Community. Security.