Skip to content

Commit

Permalink
move ast_filters into original syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
bobzhang committed Jun 20, 2015
1 parent 7e8b83e commit 0c1bfab
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 144 deletions.
101 changes: 50 additions & 51 deletions src/cold/ast_filters.ml
@@ -1,53 +1,52 @@

open Util
open Astf
open Astf

type key = string
type 'a filter = 'a -> 'a
let interf_filters: (key,sigi filter) Hashtbl.t = Hashtbl.create 40
let implem_filters: (key,stru filter) Hashtbl.t = Hashtbl.create 40
let topphrase_filters: (key,stru filter) Hashtbl.t = Hashtbl.create 40
let applied_interf_filters: (string* sigi filter) Queue.t = Queue.create ()
let applied_implem_filters: (string* stru filter) Queue.t = Queue.create ()
let applied_topphrase_filters: (string* stru filter) Queue.t =
Queue.create ()
let apply_interf_filters =
function
| i ->
Queue.fold (function | ast -> (function | (_name,f) -> f ast)) i
applied_interf_filters
let apply_implem_filters =
function
| i ->
Queue.fold (function | ast -> (function | (_name,f) -> f ast)) i
applied_implem_filters
let apply_topphrase_filters =
function
| i ->
Queue.fold (function | ast -> (function | (_name,f) -> f ast)) i
applied_topphrase_filters
let use_interf_filter =
function
| s ->
let u =
try Hashtbl.find interf_filters s
with | Not_found -> failwithf "filter %s is not registered" s in
Queue.add (s, u) applied_interf_filters
let use_implem_filter =
function
| s ->
let u =
try Hashtbl.find implem_filters s
with | Not_found -> failwithf "filter %s is not registered" s in
Queue.add (s, u) applied_implem_filters
let use_topphrase_filter =
function
| s ->
let u =
try Hashtbl.find topphrase_filters s
with | Not_found -> failwithf "filter %s is not registered" s in
Queue.add (s, u) applied_topphrase_filters
let register_sigi_filter =
function | (k,f) -> Hashtbl.replace interf_filters k f
let register_stru_filter =
function | (k,f) -> Hashtbl.replace implem_filters k f
let register_topphrase_filter =
function | (k,f) -> Hashtbl.replace topphrase_filters k f
type 'a filter = 'a -> 'a


let interf_filters: ( key, sigi filter ) Hashtbl.t = Hashtbl.create 40
let implem_filters: (key, stru filter ) Hashtbl.t = Hashtbl.create 40

let topphrase_filters: (key, stru filter ) Hashtbl.t = Hashtbl.create 40

let applied_interf_filters: (string * sigi filter ) Queue.t = Queue.create ()
let applied_implem_filters: (string * stru filter ) Queue.t = Queue.create ()
let applied_topphrase_filters: (string * stru filter ) Queue.t = Queue.create ()

let apply_interf_filters i =
Queue.fold (fun ast (_name,f) -> f ast) i applied_interf_filters
let apply_implem_filters i =
Queue.fold (fun ast (_name,f) -> f ast) i applied_implem_filters
let apply_topphrase_filters i =
Queue.fold (fun ast (_name,f) -> f ast) i applied_topphrase_filters

let use_interf_filter s =
let u =
try Hashtbl.find interf_filters s
with Not_found -> failwithf "filter %s is not registered" s in
Queue.add (s,u) applied_interf_filters

let use_implem_filter s =
let u =
try Hashtbl.find implem_filters s
with Not_found -> failwithf "filter %s is not registered" s in
Queue.add (s,u) applied_implem_filters

let use_topphrase_filter s =
let u =
try Hashtbl.find topphrase_filters s
with Not_found -> failwithf "filter %s is not registered" s in
Queue.add (s,u) applied_topphrase_filters

let register_sigi_filter (k,f) =
Hashtbl.replace interf_filters k f

let register_stru_filter (k,f) =
Hashtbl.replace implem_filters k f


let register_topphrase_filter (k,f) =
Hashtbl.replace topphrase_filters k f

52 changes: 0 additions & 52 deletions src/main/ast_filters.ml

This file was deleted.

1 change: 1 addition & 0 deletions src/main/ast_filters.ml
39 changes: 0 additions & 39 deletions src/main/ast_filters.mli

This file was deleted.

1 change: 1 addition & 0 deletions src/main/ast_filters.mli
7 changes: 5 additions & 2 deletions src/main/ast_quotation.ml
@@ -1,14 +1,17 @@



(*
%import{
Format:
pp_print_string
bprintf
fprintf
;
};;

*)
let pp_print_string = Format.pp_print_string
let bprintf = Format.bprintf
let fprintf = Format.fprintf
(** [parse_quotation_result parse_function loc position_tag quotation quotation_result]
It's a parser wrapper, this function handles the error reporting for you. *)

Expand Down
5 changes: 5 additions & 0 deletions src/main/test.sh
@@ -0,0 +1,5 @@
#!/bin/sh
# echo $1
mv -f $1.ml $1.mli ../cold/
ln -s ../cold/$1.ml
ln -s ../cold/$1.mli

0 comments on commit 0c1bfab

Please sign in to comment.